File tree Expand file tree Collapse file tree 1 file changed +19
-10
lines changed
packages/vertexai/src/methods Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -103,17 +103,23 @@ export class ChromeAdapter {
103103 ) ;
104104 const messages = ChromeAdapter . toLanguageModelMessages ( request . contents ) ;
105105 const text = await session . prompt ( messages ) ;
106+ return ChromeAdapter . toResponse ( text ) ;
107+ }
108+
109+ /**
110+ * Formats string returned by Chrome as a {@link Response} returned by Vertex.
111+ */
112+ private static toResponse ( text : string ) : Response {
106113 return {
107- json : ( ) =>
108- Promise . resolve ( {
109- candidates : [
110- {
111- content : {
112- parts : [ { text } ]
113- }
114+ json : async ( ) => ( {
115+ candidates : [
116+ {
117+ content : {
118+ parts : [ { text } ]
114119 }
115- ]
116- } )
120+ }
121+ ]
122+ } )
117123 } as Response ;
118124 }
119125
@@ -131,7 +137,10 @@ export class ChromeAdapter {
131137 const stream = await session . promptStreaming ( messages ) ;
132138 return ChromeAdapter . toStreamResponse ( stream ) ;
133139 }
134- // Formats string stream returned by Chrome as SSE returned by Vertex.
140+
141+ /**
142+ * Formats string stream returned by Chrome as SSE returned by Vertex.
143+ */
135144 private static async toStreamResponse (
136145 stream : ReadableStream < string >
137146 ) : Promise < Response > {
You can’t perform that action at this time.
0 commit comments