File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
1515 StructuredOutputSchema ,
1616 ModelResponseStatus ,
1717 ModelResponse ,
18+ addParsedModelResponse ,
1819} from '@deliberation-lab/utils' ;
1920
2021const GEMINI_DEFAULT_MODEL = 'gemini-2.5-flash' ;
@@ -164,6 +165,7 @@ export async function callGemini(
164165 prompt : string | Array < { role : string ; content : string ; name ?: string } > ,
165166 generationConfig : GenerationConfig ,
166167 modelName = GEMINI_DEFAULT_MODEL ,
168+ parseResponse = false , // parse if structured output
167169 safetySettings ?: SafetySetting [ ] ,
168170) : Promise < ModelResponse > {
169171 const genAI = new GoogleGenAI ( { apiKey} ) ;
@@ -253,6 +255,10 @@ export async function callGemini(
253255 imageDataList : imageDataList . length > 0 ? imageDataList : undefined ,
254256 } ;
255257
258+ if ( parseResponse ) {
259+ return addParsedModelResponse ( modelResponse ) ;
260+ }
261+
256262 return modelResponse ;
257263}
258264
@@ -318,6 +324,7 @@ export async function getGeminiAPIResponse(
318324 promptText ,
319325 geminiConfig ,
320326 modelName ,
327+ structuredOutputConfig ?. enabled ,
321328 safetySettings ,
322329 ) ;
323330 // eslint-disable-next-line @typescript-eslint/no-explicit-any
You can’t perform that action at this time.
0 commit comments