zej97's picture
Upload folder using huggingface_hub
4d7183d
raw
history blame
599 Bytes
import openai
openai.api_key = "sk-DQ1nFYzAVzGMznofdi0nig7MebfA9PWrTxCHlLIZIqc4X8xu"
openai.api_base = "https://api.chatanywhere.cn/v1"
def generator():
messages = [{
"role": "user",
"content": "What is the meaning of life?",
}]
response = ""
for chunk in openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages,
temperature=0.9,
stream=True,
):
content = chunk["choices"][0].get("delta", {}).get("content")
if content:
response += content
yield response