improvement: update ai21 chat to OpenAI-compatible /chat/completions - #1769
Closed
ChrisJr404 wants to merge 1 commit into
Closed
ChrisJr404 wants to merge 1 commit into
ChrisJr404 wants to merge 1 commit into
Conversation
AI21's Jamba models moved to an OpenAI-compatible chat endpoint. Point chatComplete at /studio/v1/chat/completions, swap the bespoke request params (numResults/maxTokens/topKReturn/penalty scales) for the standard OpenAI ones, and read the response back from choices/usage instead of the old outputs[] shape. Also adds streaming support since the new endpoint emits OpenAI-style SSE chunks. complete and embed still use the legacy routes and are untouched.
|
Portkey is not actively maintained. Consider submitting to https://github.com/glama-ai/lightport instead. |
Author
|
Thanks for letting me know. I'll close this since the project isn't being actively maintained. |
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.
Description: (required)
Closes #1215. AI21's Jamba models are now served over an OpenAI-compatible chat endpoint, so this points the ai21 provider's
chatCompleteat/studio/v1/chat/completionsand drops the old/{model}/chatshape.api.ts:chatCompletenow returns/chat/completions(base URL is unchanged, so requests hithttps://api.ai21.com/studio/v1/chat/completions).chatComplete.ts: request config swaps the bespoke AI21 params (numResults,maxTokens,minTokens,topKReturn, thepresencePenalty/countPenaltyscale objects, and the splitmessages/systemtransform) for the standard OpenAI ones —model,messages,max_tokens,temperature,top_p,n,stop,stream,tools,tool_choice,response_format. The system message stays in themessagesarray like every other OpenAI-style provider instead of being lifted into a separatesystemfield.choices[]/usagefrom the standard response instead of the oldoutputs[]shape, and I added a stream chunk transform (wired up asstream-chatCompleteinindex.ts) since the new endpoint emits OpenAI-style SSE.completeandembedstill call the legacy/{model}/completeand/embedroutes, so I left those and their transforms alone.AI21ErrorResponseTransformis still exported fromchatComplete.tssincecomplete.tsandembed.tsimport it.Reference: https://docs.ai21.com/reference/jamba-1-6-api-ref
Tests Run/Test cases added: (required)
src/providers/ai21/chatComplete.test.tscovering the endpoint path, the messages pass-through, the OpenAI response mapping, errordetailhandling, and the stream chunk rewrite (incl. the[DONE]sentinel).jest src/providers/ai21→ 6 passing.npm run build(rollup) succeeds andprettier --checkis clean on the touched files.Type of Change: