[GH-ISSUE #5545] OpenAI v1/completion throws an error when passing list of strings to stop parameter. #65502

Closed
opened 2026-05-03 21:29:39 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @chigkim on GitHub (Jul 8, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/5545

Originally assigned to: @royjhan on GitHub.

What is the issue?

The new OpenAI v1/completion, (not chat.completion) throws an error if you pass list of strings to stop parameter.

from openai import OpenAI
client = OpenAI(base_url=base_url, api_key=api_key)
prompt = """User: Hello,
Assistant: Hi, how can I help you?
User: How's it going?
Assistant:"""
model="llama3:text"
stop = ["User:", "Assistant:"] # Triggers an error
stop = "User:" # No error
response = client.completions.create(prompt=prompt, model=model, max_tokens=128, stop=stop)

error Error code: 400 - {'error': {'message': "invalid type for 'stop' field: []interface {}", 'type': 'invalid_request_error', 'param': None, 'code': None}}

OS

macOS

GPU

Apple

CPU

Apple

Ollama version

0.1.49

Originally created by @chigkim on GitHub (Jul 8, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/5545 Originally assigned to: @royjhan on GitHub. ### What is the issue? The new OpenAI v1/completion, (not chat.completion) throws an error if you pass list of strings to stop parameter. ```python from openai import OpenAI client = OpenAI(base_url=base_url, api_key=api_key) prompt = """User: Hello, Assistant: Hi, how can I help you? User: How's it going? Assistant:""" model="llama3:text" stop = ["User:", "Assistant:"] # Triggers an error stop = "User:" # No error response = client.completions.create(prompt=prompt, model=model, max_tokens=128, stop=stop) ``` error Error code: 400 - {'error': {'message': "invalid type for 'stop' field: []interface {}", 'type': 'invalid_request_error', 'param': None, 'code': None}} ### OS macOS ### GPU Apple ### CPU Apple ### Ollama version 0.1.49
GiteaMirror added the bug label 2026-05-03 21:29:39 -05:00
Author
Owner

@royjhan commented on GitHub (Jul 8, 2024):

Thanks for the issue

<!-- gh-comment-id:2215410697 --> @royjhan commented on GitHub (Jul 8, 2024): Thanks for the issue
Author
Owner

@ceykmc commented on GitHub (Jul 10, 2024):

I encountered the same problem. How to solve this problem ?

<!-- gh-comment-id:2219259328 --> @ceykmc commented on GitHub (Jul 10, 2024): I encountered the same problem. How to solve this problem ?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#65502