Add OpenAI-compatible custom endpoints as fourth LLM option#34
Add OpenAI-compatible custom endpoints as fourth LLM option#34SimplePotat wants to merge 7 commits into
Conversation
|
※AIによる翻訳です。不自然な箇所があるかもしれませんがご容赦ください。 ChatGPTクライアントが api.openai.com だけでなく、任意のOpenAI互換HTTPエンドポイントをターゲットにできる新しいLLMタイプ(LLM_TYPE_CUSTOM_OPENAI = 4)を追加。既存の設定におけるデフォルトの動作に変更はない。 備考:
llm:
type: 4
customEndpoint: "http://192.168.X.XXX:8080/v1/chat/completions"
# または、httpsの場合は以下のように設定:
# customEndpoint: "https://my-llm.example.com/v1/chat/completions"
# customRootCAFile: "/customRootCA.pem" # httpsエンドポイントでは必須
セキュリティに関する設計判断:
|
|
Thank you for your PR. We are currently withholding a decision on whether to merge it for the following reasons. We appreciate your consideration.
|
|
Thanks for taking the time to review the PR and thank you for your wonderful project! I'll leave the ultimate decision on whether its worth merging or keeping in a separate fork up to you.
|
|
Thank you for considering this. I understand. There seems to be a need for such an OpenAI-compatible endpoint, so I will consider merging it. |
|
Probably the easiest way to give it a try for yourself would be installing Ollama on your PC, launching it with "ollama serve gemma4:e2b" and then entering http://:11434/v1/chat/completions as the custom endpoint url in the config. I wouldn't recommend this setup as a daily driver but Ollama is the quickest backend in terms of setup and Gemma 4 E2B at Q4 isn't very smart at all but will run on any hardware and makes for a relatively small download. For HTTPS my current implementation is a little simplistic in hindsight and I feel like I should probably add support for pinning multiple root certs before merging it since some of the providers I listed require multiple certificates and thus won't work with the current code, but if you want to try it out right now you can use Google's non-realtime API at https://generativelanguage.googleapis.com/v1beta/openai/chat/completions and plug in a copy of the root cert you already use for the realtime API. If you want to set up a local model to use on the regular rather than just to test the PR I'd go with llama.cpp as the backend and my model recommendation would depend on your hardware specs. |
|
Thank you for your guidance. I've now set up an environment to run gemma4:e2b on ollama, so I'd like to try running the code you provided in the pull request. |
|
I tried it, but I had to modify the const String json_ChatString =
- "{\"model\": \"gpt-4o\","
+ "{\"model\": \"gemma4:e2b\","
"\"messages\": [{\"role\": \"system\", \"content\": \"\"}," // ユーザーが設定するロール
"{\"role\": \"system\", \"content\": \"\"}," // システム用のロール
"{\"role\": \"system\", \"content\": \"User Info: \"}]," // 長期記憶の要約
+ "\"stream\": false",
"\"functions\": [],"
"\"function_call\":\"auto\""
"}"; |
|
Oh good catch and silly mistake on my part! I had it in my head that there was an option to change the model from the config file because of another local branch I'd been testing with. I'll add a new config option for it when I get home. Shall I make it apply to the standard OpenAI plumbing as an optional override too? It'd make it a lot more flexible and future proof given 4o will inevitably be sunset sooner or later. |
|
Thank you. Indeed, it would be great if we could override the default 4o setting with an option in the configuration file. |
…if filled and sets the model to be used with the custom endpoint option, otherwise ignored. Prints error if left empty when custom endpoint is selected.
|
Sorry for the holdup, busy couple of days. I've pushed the config update and I'll start work on updating the readme and making the security certificate selection a bit more robust shortly. |
Should've caught this one before pushing, apologies for the notification.
|
Alright, got provisional multi-certificate support for HTTPS endpoints in there now too. I'll update the documentation to reflect all the commits here tomorrow (may take a little bit as I want to write it out manually rather than using AI like I did for code comments). |
…re, can be undone once support is implemented.
Adds a new LLM type (
LLM_TYPE_CUSTOM_OPENAI = 4) that lets the ChatGPT client target any OpenAI-compatible HTTP endpoint instead of justapi.openai.com, default behavior for existing configs is unchanged.Notes:
customEndpointuse the existing OpenAI flow unchanged.customRootCAFileis a path on the SD card to a PEM-formatted root CA.Security Decisions: