-
Notifications
You must be signed in to change notification settings - Fork 847
feat: support new openai routes as unified endpoints #954
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
Closed
narengogi
wants to merge
8
commits into
Portkey-AI:main
from
narengogi:feat/support-new-openai-endpoints-as-unified-routes
Closed
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ea7524e
feat: support new openai routes as unified endpoints
narengogi 87c5128
support new unified routes for azure openai
narengogi 02fb9f6
support new unified routes for azure openai
narengogi a09c7e9
Merge remote-tracking branch 'upstream/main' into feat/support-new-op…
narengogi e55367c
support new unified routes for azure openai
narengogi 1cdd8ec
minor fixes from testing
narengogi 661892c
remove unused imports
narengogi 498fd13
changes per comments
narengogi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { ProviderConfig } from '../types'; | ||
|
|
||
| export const AzureOpenAIUpdateChatCompletionConfig: ProviderConfig = { | ||
| metadata: { | ||
| param: 'metadata', | ||
| required: true, | ||
| }, | ||
| }; |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { OPEN_AI } from '../../globals'; | ||
| import { ErrorResponse, DeleteChatCompletionResponse } from '../types'; | ||
| import { OpenAIErrorResponseTransform } from './utils'; | ||
|
|
||
| export const OpenAIDeleteChatCompletionResponseTransform: ( | ||
| response: DeleteChatCompletionResponse | ErrorResponse, | ||
| responseStatus: number | ||
| ) => DeleteChatCompletionResponse | ErrorResponse = ( | ||
| response, | ||
| responseStatus | ||
| ) => { | ||
| if (responseStatus !== 200 && 'error' in response) { | ||
| return OpenAIErrorResponseTransform(response, OPEN_AI); | ||
| } | ||
|
|
||
| return response; | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { OPEN_AI } from '../../globals'; | ||
| import { ErrorResponse } from '../types'; | ||
| import { OpenAIChatCompleteResponse } from './chatComplete'; | ||
| import { OpenAIErrorResponseTransform } from './utils'; | ||
|
|
||
| export const OpenAIGetChatCompletionResponseTransform: ( | ||
| response: OpenAIChatCompleteResponse | ErrorResponse, | ||
| responseStatus: number | ||
| ) => OpenAIChatCompleteResponse | ErrorResponse = ( | ||
| response, | ||
| responseStatus | ||
| ) => { | ||
| if (responseStatus !== 200 && 'error' in response) { | ||
| return OpenAIErrorResponseTransform(response, OPEN_AI); | ||
| } | ||
|
|
||
| return response; | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { OPEN_AI } from '../../globals'; | ||
| import { ErrorResponse, GetChatMessagesResponse } from '../types'; | ||
| import { OpenAIErrorResponseTransform } from './utils'; | ||
|
|
||
| export const OpenAIGetChatMessagesResponseTransform: ( | ||
| response: GetChatMessagesResponse | ErrorResponse, | ||
| responseStatus: number | ||
| ) => GetChatMessagesResponse | ErrorResponse = (response, responseStatus) => { | ||
| if (responseStatus !== 200 && 'error' in response) { | ||
| return OpenAIErrorResponseTransform(response, OPEN_AI); | ||
| } | ||
|
|
||
| return response; | ||
| }; |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { OPEN_AI } from '../../globals'; | ||
| import { ErrorResponse } from '../types'; | ||
| import { OpenAIChatCompleteResponse } from './chatComplete'; | ||
| import { OpenAIErrorResponseTransform } from './utils'; | ||
|
|
||
| export const OpenAIListChatCompletionsResponseTransform: ( | ||
| response: OpenAIChatCompleteResponse[] | ErrorResponse, | ||
| responseStatus: number | ||
| ) => OpenAIChatCompleteResponse[] | ErrorResponse = ( | ||
| response, | ||
| responseStatus | ||
| ) => { | ||
| if (responseStatus !== 200 && 'error' in response) { | ||
| return OpenAIErrorResponseTransform(response, OPEN_AI); | ||
| } | ||
|
|
||
| return response; | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { OPEN_AI } from '../../globals'; | ||
| import { ErrorResponse, ProviderConfig } from '../types'; | ||
| import { OpenAIChatCompleteResponse } from './chatComplete'; | ||
| import { OpenAIErrorResponseTransform } from './utils'; | ||
|
|
||
| export const OpenAIUpdateChatCompletionConfig: ProviderConfig = { | ||
| metadata: { | ||
| param: 'metadata', | ||
| required: true, | ||
| }, | ||
| }; | ||
narengogi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export const OpenAIUpdateChatCompletionResponseTransform: ( | ||
| response: OpenAIChatCompleteResponse | ErrorResponse, | ||
| responseStatus: number | ||
| ) => OpenAIChatCompleteResponse | ErrorResponse = ( | ||
| response, | ||
| responseStatus | ||
| ) => { | ||
| if (responseStatus !== 200 && 'error' in response) { | ||
| return OpenAIErrorResponseTransform(response, OPEN_AI); | ||
| } | ||
|
|
||
| return response; | ||
| }; | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.