error in think key and error in message role in ollama gpt-oss #289

Closed
opened 2026-02-15 16:29:38 -05:00 by yindo · 1 comment
Owner

Originally created by @Arthurns16 on GitHub (Aug 12, 2025).

I’m running into two errors when executing this code: first, the think option isn’t recognized as valid; second, I’m getting an error about a message with an invalid role and empty content. I’m running gpt-oss with Llama on a Slurm-based cluster. I was able to run Mistral without issues, but the code fails with gpt-oss.

for i in range(start_index, len(df)):
composition = str(df.loc[i, "composition"]).strip()
phase = str(df.loc[i, "phase"]).strip()
input_str = f"{composition} {phase}"

print(f"Processing {i + 1}/{len(df)}: {input_str}")
print (instructions)

try:

    response = ollama.chat(
        model='gpt-oss:120b',
        messages=[
            {'role': 'system', 'content': instructions},
            {'role': 'user', 'content': input_str}
        ],
        format='json',
        stream=False,
       think = 'high',
        options={
            "temperature": 0.0,
            "seed": 42,
            "num_predict" : -1,
            "num_ctx": 8192,
        }
    )

    json_output = response["message"]["content"].strip()

except Exception as e:
    print(f"Erro no índice {i}: {e}")
    json_output = f"ERROR: {str(e)}"

results.append({"gpt_fractions": json_output})
Originally created by @Arthurns16 on GitHub (Aug 12, 2025). I’m running into two errors when executing this code: first, the think option isn’t recognized as valid; second, I’m getting an error about a message with an invalid role and empty content. I’m running gpt-oss with Llama on a Slurm-based cluster. I was able to run Mistral without issues, but the code fails with gpt-oss. for i in range(start_index, len(df)): composition = str(df.loc[i, "composition"]).strip() phase = str(df.loc[i, "phase"]).strip() input_str = f"{composition} {phase}" print(f"Processing {i + 1}/{len(df)}: {input_str}") print (instructions) try: response = ollama.chat( model='gpt-oss:120b', messages=[ {'role': 'system', 'content': instructions}, {'role': 'user', 'content': input_str} ], format='json', stream=False, think = 'high', options={ "temperature": 0.0, "seed": 42, "num_predict" : -1, "num_ctx": 8192, } ) json_output = response["message"]["content"].strip() except Exception as e: print(f"Erro no índice {i}: {e}") json_output = f"ERROR: {str(e)}" results.append({"gpt_fractions": json_output})
yindo closed this issue 2026-02-15 16:29:38 -05:00
Author
Owner

@Arthurns16 commented on GitHub (Aug 12, 2025):

even after updating ollama and python, I recieve null messages error. It only works when I remove json parameter.

@Arthurns16 commented on GitHub (Aug 12, 2025): even after updating ollama and python, I recieve null messages error. It only works when I remove json parameter.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#289