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/b3ed070977de2a2f1a95229bbcd1c6f8cbda450a/src/get_completion_from_messages.py
- Command line
-
hf download hf://spaces/kkAIGC/SQLBot@b3ed070977de2a2f1a95229bbcd1c6f8cbda450a/src/get_completion_from_messages.py
-
curl -L -o get_completion_from_messages.py https://huggingface.co/spaces/kkAIGC/SQLBot/resolve/b3ed070977de2a2f1a95229bbcd1c6f8cbda450a/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"] | |