-
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.
Merge pull request #301 from flexchar/small-qol-update
Small QoL update
- Loading branch information
Showing
6 changed files
with
96 additions
and
72 deletions.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
src/providers/google-vertex-ai/transformGenerationConfig.ts
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,28 @@ | ||
import { Params } from '../../types/requestBody'; | ||
|
||
/** | ||
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini#request_body | ||
*/ | ||
export function transformGenerationConfig(params: Params) { | ||
const generationConfig: Record<string, any> = {}; | ||
if (params['temperature']) { | ||
generationConfig['temperature'] = params['temperature']; | ||
} | ||
if (params['top_p']) { | ||
generationConfig['topP'] = params['top_p']; | ||
} | ||
if (params['top_k']) { | ||
generationConfig['topK'] = params['top_k']; | ||
} | ||
if (params['max_tokens']) { | ||
generationConfig['maxOutputTokens'] = params['max_tokens']; | ||
} | ||
if (params['stop']) { | ||
generationConfig['stopSequences'] = params['stop']; | ||
} | ||
if (params?.response_format?.type === 'json_object') { | ||
generationConfig['responseMimeType'] = 'application/json'; | ||
} | ||
|
||
return generationConfig; | ||
} |
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,44 @@ | ||
export interface GoogleErrorResponse { | ||
error: { | ||
code: number; | ||
message: string; | ||
status: string; | ||
details: Array<Record<string, any>>; | ||
}; | ||
} | ||
|
||
export interface GoogleGenerateFunctionCall { | ||
name: string; | ||
args: Record<string, any>; | ||
} | ||
|
||
export interface GoogleGenerateContentResponse { | ||
candidates: { | ||
content: { | ||
parts: { | ||
text?: string; | ||
functionCall?: GoogleGenerateFunctionCall; | ||
}[]; | ||
}; | ||
finishReason: string; | ||
index: 0; | ||
safetyRatings: { | ||
category: string; | ||
probability: string; | ||
}[]; | ||
}[]; | ||
promptFeedback: { | ||
safetyRatings: { | ||
category: string; | ||
probability: string; | ||
probabilityScore: number; | ||
severity: string; | ||
severityScore: number; | ||
}[]; | ||
}; | ||
usageMetadata: { | ||
promptTokenCount: number; | ||
candidatesTokenCount: number; | ||
totalTokenCount: number; | ||
}; | ||
} |
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