-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Support for Google's Vertex AI
- Loading branch information
Showing
12 changed files
with
719 additions
and
676 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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 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 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,42 @@ | ||
import { ProviderAPIConfig } from '../types'; | ||
|
||
// Good reference for using REST: https://cloud.google.com/vertex-ai/generative-ai/docs/start/quickstarts/quickstart-multimodal#gemini-beginner-samples-drest | ||
// Difference versus Studio AI: https://cloud.google.com/vertex-ai/docs/start/ai-platform-users | ||
export const GoogleApiConfig: ProviderAPIConfig = { | ||
getBaseURL: ({ providerOptions }) => { | ||
const { vertexProjectId, vertexRegion } = providerOptions; | ||
|
||
return `https://${vertexRegion}-aiplatform.googleapis.com/v1/projects/${vertexProjectId}/locations/${vertexRegion}/publishers/google`; | ||
}, | ||
headers: ({ providerOptions }) => { | ||
const { apiKey } = providerOptions; | ||
|
||
return { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${apiKey}`, | ||
}; | ||
}, | ||
getEndpoint: ({ fn, gatewayRequestBody }) => { | ||
let mappedFn = fn; | ||
const { model, stream } = gatewayRequestBody; | ||
if (stream) { | ||
mappedFn = `stream-${fn}`; | ||
} | ||
switch (mappedFn) { | ||
case 'chatComplete': { | ||
return `/models/${model}:generateContent`; | ||
} | ||
case 'stream-chatComplete': { | ||
return `/models/${model}:streamGenerateContent?alt=sse`; | ||
} | ||
|
||
// Embed API is not yet implemented in the gateway | ||
// This may be as easy as copy-paste from Google provider, but needs to be tested | ||
|
||
default: | ||
return ''; | ||
} | ||
}, | ||
}; | ||
|
||
export default GoogleApiConfig; |
Oops, something went wrong.