forked from cloud-ru/evolution-openai-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_async.py
More file actions
30 lines (26 loc) · 889 Bytes
/
basic_async.py
File metadata and controls
30 lines (26 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import asyncio
import os
from evolution_openai import create_async_client
key_id = os.environ["KEY_ID"]
secret = os.environ["SECRET"]
project = os.environ["PROJECT"]
url = "https://foundation-models.api.cloud.ru/api/gigacube/openai/v1"
MODEL: str = "deepseek-ai/DeepSeek-R1-Distill-Llama-70B"
USER_PROMPT: str = "Как написать хороший код? Не более 100 слов"
params = {
"model": MODEL,
"max_tokens": 5000,
"presence_penalty": 0,
"top_p": 0.95,
"temperature": 0.5,
"messages": [
{"role": "user", "content": USER_PROMPT},
],
}
async def main():
client = create_async_client(key_id=key_id, secret=secret, base_url=url, project=project)
response = await client.chat.completions.create(**params)
content = response.choices[0].message.content
print(content)
if __name__ == '__main__':
asyncio.run(main())