-1
I have the following problem at creation of an openai chatbot model:
The assistant replies are not displayed in the gradio chatbox. Only the user input is displayed. There are no errors or warnings in the UI nor in the console. The response object includes very good assistant’s messages, but they are lost on the way to the gradio display.
I am using recently updated version of gradio, python 3.x and the gpt-3.5-turbo-0125 model
Here is the script function passed to gradio:
def predict(message, history):
response = get_completion(messages)
for choice in response.choices:
if choice.finish_reason == "stop":
break
if choice.finish_reason == "tool_calls":
fn_name = choice.message["function_call"].name
arguments = choice.message["function_call"].arguments
function = locals()[fn_name]
result = function(**arguments)
messages.append(
{
"role": "assistant",
"content": None,
"function_call": {
"name": fn_name,
"arguments": arguments,
},
}
)
messages.append(
{
"role": "function",
"name": fn_name,
"content": f'{{"result": {str(result)} }}'
}
)
else:
messages.append(choice.message["content"])
response = get_completion(messages)
Here is the response object (includes message I want to see in the UI):
ChatCompletion(id='chatcmpl-8shL0R1lKV3xgLxqUs6bsUkpydwCm', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='To calculate the price for Simple Reservations, I need the following information from you:\n\n1. Number of users who will be using the software.\n2. Number of rooms that you want to manage.\n3. Are you a first-time client, or have you used Simple Reservations before?\n\nCan you please provide me with these details?', role='assistant', function_call=None, tool_calls=None))]
, created=1708046994, model='gpt-3.5-turbo-0125', object='chat.completion', system_fingerprint='fp_9fdfea22a2', usage=CompletionUsage(completion_tokens=68, prompt_tokens=156, total_tokens=224))