Gemini returns empty connent

I was testing gpt-4o and gemini. However, with the same input message, gemini returns empty content. Here is related code:

openai_client = openai.OpenAI(api_key=secrets[“openai_key”])
gemini_client = openai.OpenAI(api_key=secrets[“gemini_key”], base_url=“https://generativelanguage.googleapis.com/v1beta/openai/”)

response = client.chat.completions.create(
model=model,
messages=messages,
tools=tools
)

Here is the output from gpt-4o:

gpt-4o-2024-11-20: ChatCompletion(id=‘chatcmpl-B66Tw9logz254LsrUx6lxPRoSaQxv’, choices=[Choice(finish_reason=‘stop’, index=0, logprobs=None, message=ChatCompletionMessage(content=‘{\n “tags”: [\n {\n “tag”: “sys_human_follow_up”,\n “reason”: “Assistant mentioned escalating the issue to a special team for further assistance and stated they will assist the user shortly.”\n }\n ]\n}’, refusal=None, role=‘assistant’, audio=None, function_call=None, tool_calls=None))], created=1740794584, model=‘gpt-4o-2024-11-20’, object=‘chat.completion’, service_tier=‘default’, system_fingerprint=‘fp_1d7c5f52ce’, usage=CompletionUsage(completion_tokens=51, prompt_tokens=619, total_tokens=670, completion_tokens_details=CompletionTokensDetails(audio_tokens=0, reasoning_tokens=0, accepted_prediction_tokens=0, rejected_prediction_tokens=0), prompt_tokens_details=PromptTokensDetails(audio_tokens=0, cached_tokens=0)))

Here is the output from gemini:
gemini-2.0-flash: ChatCompletion(id=None, choices=[Choice(finish_reason=‘stop’, index=0, logprobs=None, message=ChatCompletionMessage(content=None, refusal=None, role=‘assistant’, audio=None, function_call=None, tool_calls=None))], created=1740794586, model=‘gemini-2.0-flash’, object=‘chat.completion’, service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=0, prompt_tokens=634, total_tokens=634, completion_tokens_details=None, prompt_tokens_details=None))

Hi @Lifan_Xu , Welcome to the forum.

Could you provide the sample messages and tools??

I did not use tools, here is an example message:
messages = [
{
“role”: “system”,
“content”: "You are a smart tagger whose only job is to create tags, output in JSON format. \n "
},
{
“role”: “user”,
“content”: [
{
“type”: “text”,
“text”: “It doesn’t work unfortunately”
}
]
},
{
“role”: “assistant”,
“content”: [
{
“type”: “text”,
“text”: “Thank you for trying the steps so far! Let\u2019s try another approach to resolve this issue.\n\nSometimes, manually selecting a network operator can help. Here\u2019s how to do it on your iPhone 14: \n1. Go to Settings > Cellular/Mobile Data > Network Selection. \n2. Turn off Automatic and wait for the list of available networks to load. \n3. Select one of the recommended networks for Dominica (e.g., Digicel or Flow). \n\nOnce you’ve done this, try using your internet again and let me know if it works! \ud83d\ude0a”
}
]
},
{
“role”: “user”,
“content”: [
{
“type”: “text”,
“text”: “It doesn’t work unfortunately”
}
]
},
{
“role”: “assistant”,
“content”: [
{
“type”: “text”,
“text”: “Thank you for trying the steps so far! Since the issue persists, I\u2019ll need to escalate this to our special team for a more personalized resolution. \n\nI will notify them immediately, and they will assist you shortly. Thank you for your understanding and patience! \ud83d\ude0a”
}
]
},
{
“role”: “system”,
“content”: “please escalate this to a special team”
}
]

1 Like