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 {
103
103
) ;
104
104
const messages = ChromeAdapter . toLanguageModelMessages ( request . contents ) ;
105
105
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 {
106
113
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 } ]
114
119
}
115
- ]
116
- } )
120
+ }
121
+ ]
122
+ } )
117
123
} as Response ;
118
124
}
119
125
@@ -131,7 +137,10 @@ export class ChromeAdapter {
131
137
const stream = await session . promptStreaming ( messages ) ;
132
138
return ChromeAdapter . toStreamResponse ( stream ) ;
133
139
}
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
+ */
135
144
private static async toStreamResponse (
136
145
stream : ReadableStream < string >
137
146
) : Promise < Response > {
You can’t perform that action at this time.
0 commit comments