File tree Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ void main(List<String> args) async {
1717 }
1818
1919 final client = GoogleMcpClient (
20- GenerativeModel (model: 'gemini-2.5-pro-exp-03-25 ' , apiKey: apiKey),
20+ GenerativeModel (model: 'gemini-2.0-flash ' , apiKey: apiKey),
2121 Client (Implementation (name: "gemini-client" , version: "1.0.0" )),
2222 );
2323
Original file line number Diff line number Diff line change @@ -128,12 +128,29 @@ class GoogleMcpClient {
128128 "[Calling tool ${part .name } with args ${jsonEncode (part .args )}]" ,
129129 );
130130
131- final toolResponseText =
132- result.content
133- .whereType< mcp_dart.TextContent > ()
134- .map ((c) => c.text)
135- .join ();
136- finalText.add (toolResponseText);
131+ for (final c in result.content) {
132+ if (c is mcp_dart.TextContent ) {
133+ messages.add (Content .text (c.text));
134+ }
135+ if (c is mcp_dart.ImageContent ) {
136+ messages.add (Content .data (c.mimeType, base64Decode (c.data)));
137+ print (c.data);
138+ }
139+ }
140+ final finalRes = await model.generateContent (messages);
141+ finalText.add (
142+ finalRes.candidates.first.content.parts.map ((c) {
143+ if (c is TextPart ) {
144+ return c.text;
145+ } else if (c is DataPart ) {
146+ return "[Image: ${c .mimeType }]" ;
147+ } else if (c is FilePart ) {
148+ return "[File: ${c .uri }]" ;
149+ } else {
150+ return "[Unknown part type]" ;
151+ }
152+ }).join (),
153+ );
137154 }
138155 }
139156
You can’t perform that action at this time.
0 commit comments