You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! If you create a chat using acreate, provide functions, up-to-date model, the arguments field is always empty regardless, reproduces every single time. Altho, if you are using simple synchronous create on the same setup, it works perfectly.
To Reproduce
ChatCompletion.acreate
gen = await openai.ChatCompletion.acreate(
model='gpt-3.5-turbo-0613',
messages=[{"role": "user", "content": "What's the weather like in Boston?"}],
stream=True,
functions=[
{
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
}
],
function_call='auto'
)
resp = gen.__anext__()
delta = resp.choices[0].delta
print(f'DELTA:\n{delta}')
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo-0613",
messages=[{"role": "user", "content": "What's the weather like in Boston?"}],
functions=[
{
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
}
],
function_call="auto",
)
message = response["choices"][0]["message"]
print(message)
Hey @valaises, just chiming in since I also bumped into this a few days ago. When using stream=True you need to wait for all the chunks to be sent and combine all the deltas. This works for me:
gen=awaitopenai.ChatCompletion.acreate(
model='gpt-3.5-turbo-0613',
messages=[{"role": "user", "content": "What's the weather like in Boston?"}],
stream=True,
functions=[
{
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
}
],
function_call='auto'
)
function_name=''arguments=''asyncforitemingen:
delta=item.choices[0].deltaifdelta.get('function_call'):
function_name+=delta.function_call.get('name', '')
arguments+=str(delta.function_call.get('arguments', ''))
print(f'function_name: {function_name}\narguments: {json.loads(arguments)}')
Describe the bug
Hi! If you create a chat using acreate, provide functions, up-to-date model, the arguments field is always empty regardless, reproduces every single time. Altho, if you are using simple synchronous create on the same setup, it works perfectly.
To Reproduce
ChatCompletion.acreate
OUTPUT (ARGUMENTS ARE ABSENT)
ChatCompletion.create
OUTPUT (ARGUMENTS ARE PRESENT)
Code snippets
No response
OS
Ubuntu 20.04.5 LTS
Python version
Python 3.9.15
Library version
openai-python v0.27.8
The text was updated successfully, but these errors were encountered: