Spaces:
Runtime error
Runtime error
File size: 694 Bytes
7dfa187 0fdaf32 7dfa187 7bfabdf 0fdaf32 |
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 31 32 33 34 |
from openai import OpenAI
base_url = "http://localhost:22222"
api_key = "sk-xxxxx"
client = OpenAI(base_url=base_url, api_key=api_key)
extra_body = {
"invocation_id": 1,
}
response = client.chat.completions.create(
model="precise",
messages=[
{
"role": "user",
"content": "search california's weather for me",
}
],
stream=True,
extra_body=extra_body,
)
# print(response)
for chunk in response:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="", flush=True)
elif chunk.choices[0].finish_reason == "stop":
print()
else:
# print(chunk)
pass
|