-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Modular backends & support for openAI & AWS endpoints #541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com>
Tested this locally with openAI, the llama.cpp local server with openAI adapter and also plain TGI and everything works great. I think this is good to go imo! |
cc @coyotte508 if you want to take a quick peek, especially in endpoints.ts and models.ts |
Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu>
I've been testing this branch and from what I've seen, it seems to break the LLM Summarization for the conversation title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using mostly Azure Open AI so I tested this branch with an Azure Endpoint. With some minor tweaks it works well so thanks for this PR!
I also tested the websearch but I had some issues with the GenerateQuery that didn't understand the preprompt (system prompt) correctly.
Appart from that, it's working well for me.
src/lib/server/endpoints/openai/openAIChatToTextGenerationStream.ts
Outdated
Show resolved
Hide resolved
src/lib/server/endpoints/openai/openAICompletionToTextGenerationStream.ts
Outdated
Show resolved
Hide resolved
Looking forward for this PR 👀 |
I was on holiday last week, I'll be back Tuesday and implement the feedback/merge this then! |
Co-authored-by: Eliott C. <coyotte508@gmail.com>
I also just added support directly for the llama.cpp API server directly since the protocol is a bit different! |
* Fix the response Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Should use /completions Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Use async generator Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Use openai npm Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix generateFromDefaultEndpoint Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix last char become undefined Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Better support for system prompt Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Updates Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Revert Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Update README Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Default system prompt Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * remove sk- Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fixing types Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix lockfile Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Move .optional Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Add try...catch and controller.error(error) Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * baseURL Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Format Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix types Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix again Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Better error message Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Update README Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Refactor backend to add support for modular backends * readme fix * readme update * add support for lambda on aws endpoint * upsate doc for lambda support * fix typecheck * make imports really optional * readme fixes * make endpoint creator async * Update README.md Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * Update README.md Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * Update src/lib/server/endpoints/openai/endpointOai.ts Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * trailing comma * Update README.md Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu> * change readme example name * Update src/lib/server/models.ts Co-authored-by: Eliott C. <coyotte508@gmail.com> * fixed preprompt to use conversation.preprompt * Make openAI endpoint compatible with Azure OpenAI * surface errors in generation * Added support for llamacpp endpoint * fix llamacpp endpoint so it properly stops * Add llamacpp example to readme * Add support for legacy configs --------- Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> Co-authored-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu> Co-authored-by: Eliott C. <coyotte508@gmail.com>
* Fix the response Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Should use /completions Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Use async generator Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Use openai npm Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix generateFromDefaultEndpoint Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix last char become undefined Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Better support for system prompt Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Updates Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Revert Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Update README Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Default system prompt Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * remove sk- Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fixing types Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix lockfile Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Move .optional Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Add try...catch and controller.error(error) Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * baseURL Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Format Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix types Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix again Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Better error message Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Update README Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Refactor backend to add support for modular backends * readme fix * readme update * add support for lambda on aws endpoint * upsate doc for lambda support * fix typecheck * make imports really optional * readme fixes * make endpoint creator async * Update README.md Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * Update README.md Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * Update src/lib/server/endpoints/openai/endpointOai.ts Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * trailing comma * Update README.md Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu> * change readme example name * Update src/lib/server/models.ts Co-authored-by: Eliott C. <coyotte508@gmail.com> * fixed preprompt to use conversation.preprompt * Make openAI endpoint compatible with Azure OpenAI * surface errors in generation * Added support for llamacpp endpoint * fix llamacpp endpoint so it properly stops * Add llamacpp example to readme * Add support for legacy configs --------- Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> Co-authored-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu> Co-authored-by: Eliott C. <coyotte508@gmail.com>
* Fix the response Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Should use /completions Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Use async generator Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Use openai npm Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix generateFromDefaultEndpoint Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix last char become undefined Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Better support for system prompt Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Updates Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Revert Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Update README Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Default system prompt Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * remove sk- Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fixing types Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix lockfile Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Move .optional Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Add try...catch and controller.error(error) Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * baseURL Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Format Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix types Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix again Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Better error message Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Update README Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Refactor backend to add support for modular backends * readme fix * readme update * add support for lambda on aws endpoint * upsate doc for lambda support * fix typecheck * make imports really optional * readme fixes * make endpoint creator async * Update README.md Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * Update README.md Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * Update src/lib/server/endpoints/openai/endpointOai.ts Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * trailing comma * Update README.md Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu> * change readme example name * Update src/lib/server/models.ts Co-authored-by: Eliott C. <coyotte508@gmail.com> * fixed preprompt to use conversation.preprompt * Make openAI endpoint compatible with Azure OpenAI * surface errors in generation * Added support for llamacpp endpoint * fix llamacpp endpoint so it properly stops * Add llamacpp example to readme * Add support for legacy configs --------- Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> Co-authored-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu> Co-authored-by: Eliott C. <coyotte508@gmail.com>
* Fix the response Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Should use /completions Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Use async generator Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Use openai npm Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix generateFromDefaultEndpoint Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix last char become undefined Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Better support for system prompt Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Updates Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Revert Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Update README Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Default system prompt Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * remove sk- Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fixing types Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix lockfile Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Move .optional Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Add try...catch and controller.error(error) Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * baseURL Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Format Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix types Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix again Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Better error message Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Update README Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Refactor backend to add support for modular backends * readme fix * readme update * add support for lambda on aws endpoint * upsate doc for lambda support * fix typecheck * make imports really optional * readme fixes * make endpoint creator async * Update README.md Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * Update README.md Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * Update src/lib/server/endpoints/openai/endpointOai.ts Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * trailing comma * Update README.md Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu> * change readme example name * Update src/lib/server/models.ts Co-authored-by: Eliott C. <coyotte508@gmail.com> * fixed preprompt to use conversation.preprompt * Make openAI endpoint compatible with Azure OpenAI * surface errors in generation * Added support for llamacpp endpoint * fix llamacpp endpoint so it properly stops * Add llamacpp example to readme * Add support for legacy configs --------- Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> Co-authored-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu> Co-authored-by: Eliott C. <coyotte508@gmail.com>
* Fix the response Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Should use /completions Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Use async generator Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Use openai npm Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix generateFromDefaultEndpoint Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix last char become undefined Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Better support for system prompt Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Updates Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Revert Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Update README Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Default system prompt Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * remove sk- Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fixing types Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix lockfile Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Move .optional Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Add try...catch and controller.error(error) Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * baseURL Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Format Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix types Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Fix again Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Better error message Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Update README Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Refactor backend to add support for modular backends * readme fix * readme update * add support for lambda on aws endpoint * upsate doc for lambda support * fix typecheck * make imports really optional * readme fixes * make endpoint creator async * Update README.md Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * Update README.md Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * Update src/lib/server/endpoints/openai/endpointOai.ts Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> * trailing comma * Update README.md Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu> * change readme example name * Update src/lib/server/models.ts Co-authored-by: Eliott C. <coyotte508@gmail.com> * fixed preprompt to use conversation.preprompt * Make openAI endpoint compatible with Azure OpenAI * surface errors in generation * Added support for llamacpp endpoint * fix llamacpp endpoint so it properly stops * Add llamacpp example to readme * Add support for legacy configs --------- Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> Co-authored-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com> Co-authored-by: Mishig <mishig.davaadorj@coloradocollege.edu> Co-authored-by: Eliott C. <coyotte508@gmail.com>
This PR adds support for openAI endpoint with a refactor that make it easier to handle adding independent backends with library dependencies in the future. For example if you want to add
gpt-3.5-turbo
:Add to your
MODELS
:and add
OPENAI_API_KEY
to your .env.localCloses #452
Closes #428