Use OpenAI Python Lib instead of using aiohttp for OpenAI compatible API#335
Draft
evschlenz wants to merge 3 commits intoacon96:developfrom
Draft
Use OpenAI Python Lib instead of using aiohttp for OpenAI compatible API#335evschlenz wants to merge 3 commits intoacon96:developfrom
evschlenz wants to merge 3 commits intoacon96:developfrom
Conversation
Owner
|
Thank you for this. Yes I think it makes sense to continue migrating to the "official" python libraries to ensure proper compatibility after doing the Ollama one. Once this is published I will take a look at it for sure. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To properly support streaming tool calls (ggml-org/llama.cpp#12379) and to improve overall code cleanliness, I propose migrating to the official OpenAI Python library (https://pypi.org/project/openai/) instead of using
aiohttpdirectly for OpenAI-compatible endpoints.I tested my changes with llamacpp b7549, functiongemma (original and my custom finetune) and the
LlamaCppServerClient:as well as vllm v0.13.0, Qwen3 30bA3b and the
LlamaCppServerClient:podman run --device nvidia.com/gpu=all \ -v ~/.cache/huggingface:/root/.cache/huggingface \ -v ~/ai/vllm/models:/root/models \ -p 8000:8000 \ --ipc=host \ docker.io/vllm/vllm-openai:v0.13.0 \ --download-dir /root/models/ \ --model /root/models/Qwen3-30B-A3B-Instruct-2507-AWQ-4bit/ \ --enable-auto-tool-choice \ --tool-call-parser hermes \ --gpu-memory-utilization 0.95 \ --max-num-seqs 128 \ --dtype auto \ --swap-space 16 \ --trust-remote-code \ --host 0.0.0.0 \ --port 8000both with their native tool calling.
Since I do not have an OpenAI account, I cannot validate the functionality against their api.
This pull request should fix compatibility with functiongemma (on lamacpp at least) as well.
A potential follow-up would be to migrate
GenericOpenAIResponsesAPIClientto the OpenAI library as well. However, since I am not really familiar with the Responses API, I left it as is for now.