Skip to content

Commit 50a420f

Browse files
authored
feat(model/chat): add cache_control test case (#49)
1 parent 87bf172 commit 50a420f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

samples/test_generation.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,31 @@
33

44
messages = [
55
{"role": "system", "content": "You are a helpful assistant."},
6-
{"role": "user", "content": "你是谁?"},
6+
{
7+
"role": "user",
8+
"content": [
9+
{
10+
"type": "text",
11+
"text": "abc" * 1024 + "你是谁?",
12+
"cache_control": {
13+
"type": "ephemeral",
14+
"ttl": "5m"
15+
}
16+
}
17+
]
18+
}
719
]
820
response = Generation.call(
921
api_key=os.getenv("DASHSCOPE_API_KEY"),
10-
model="qwen-plus",
22+
model=os.getenv("MODEL_NAME"),
1123
messages=messages,
1224
result_format="message",
13-
enable_encryption=True,
25+
incremental_output=True,
1426
stream=True,
1527
)
1628

1729
for chunk in response:
18-
print(chunk.output.choices[0].message.content)
30+
print(chunk)
1931

2032
# if response.status_code == 200:
2133
# print(response.output.choices[0].message.content)

0 commit comments

Comments
 (0)