Skip to content

Handle None as param value in api_like_OAI.py - #2746

Merged
ggerganov merged 2 commits into
ggml-org:masterfrom
ryderwishart:ryderwishart-patch-1
Oct 8, 2023
Merged

Handle None as param value in api_like_OAI.py#2746
ggerganov merged 2 commits into
ggml-org:masterfrom
ryderwishart:ryderwishart-patch-1

Conversation

@ryderwishart

Copy link
Copy Markdown
Contributor

Context

Microsoft Guidance automatically sends a stop param in the body, and the value is not "", but None. This causes the current code to throw an error (TypeError: 'NoneType' object is not iterable, e.g., on line 77 in the make_postData function) when trying to request a completion. I suspect other implementations besides Guidance may send None as a param value in the body.

Proposed Solution

This PR checks for None in addition to empty string check in all request params in the api_like_OAI.py script.

I have confirmed that this solution fixes the use case with Guidance, and I can't see any reason in the code that this would break any existing implementations, since it's simply another falsey check.

Check for None in addition to empty string check in all request params
@ryderwishart ryderwishart changed the title Make api_like_OAI.py work with Microsoft Guidance Handle None as param value in api_like_OAI.py Aug 23, 2023
@ggerganov

Copy link
Copy Markdown
Member

I just merged #2796 which I now see is probably incorrect given this behaviour

@ggerganov
ggerganov merged commit 8e6716a into ggml-org:master Oct 8, 2023
@ryderwishart
ryderwishart deleted the ryderwishart-patch-1 branch October 9, 2023 04:18
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
Check for None in addition to empty string check in all request params

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
phuongncn pushed a commit to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4 that referenced this pull request Apr 28, 2026
Check for None in addition to empty string check in all request params

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
Check for None in addition to empty string check in all request params

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
Check for None in addition to empty string check in all request params

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
Check for None in addition to empty string check in all request params

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants