Download src/get_completion_from_messages.py from kkAIGC/SQLBot: direct link, hf CLI and curl.
- Browser
- Download file 363 Bytes
-
https://huggingface.co/spaces/kkAIGC/SQLBot/resolve/10da04c9ffa2cd103d5bcb9df0c5aecd4f5c232f/src/get_completion_from_messages.py
- Command line
-
hf download hf://spaces/kkAIGC/SQLBot@10da04c9ffa2cd103d5bcb9df0c5aecd4f5c232f/src/get_completion_from_messages.py
-
curl -L -o get_completion_from_messages.py https://huggingface.co/spaces/kkAIGC/SQLBot/resolve/10da04c9ffa2cd103d5bcb9df0c5aecd4f5c232f/src/get_completion_from_messages.py
363 Bytes
| import openai | |
| #对话函数 | |
| def get_completion_from_messages( | |
| messages, | |
| model="gpt-3.5-turbo-16k", | |
| temperature=0, | |
| max_tokens=3000): | |
| response = openai.ChatCompletion.create( | |
| model=model, | |
| messages=messages, | |
| temperature=temperature, | |
| max_tokens=max_tokens, | |
| ) | |
| return response.choices[0].message["content"] | |