File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
packages/firebase_ai/firebase_ai Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -322,8 +322,13 @@ LiveServerMessage _parseServerMessage(Object jsonObject) {
322322
323323 return LiveServerToolCall (functionCalls: functionCalls);
324324 } else if (json.containsKey ('toolCallCancellation' )) {
325- final toolCancelJson =
326- json['toolCallCancellation' ] as Map <String , List <String >>;
325+ final toolCancelData = json['toolCallCancellation' ] as Map ;
326+ final Map <String , List <String >> toolCancelJson = toolCancelData.map (
327+ (key, value) => MapEntry (
328+ key as String ,
329+ (value as List ).cast <String >(),
330+ ),
331+ );
327332 return LiveServerToolCallCancellation (functionIds: toolCancelJson['ids' ]);
328333 } else if (json.containsKey ('setupComplete' )) {
329334 return LiveServerSetupComplete ();
Original file line number Diff line number Diff line change 1111// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212// See the License for the specific language governing permissions and
1313// limitations under the License.
14+ import 'dart:convert' ;
1415import 'dart:typed_data' ;
1516
1617import 'package:firebase_ai/src/api.dart' ;
@@ -206,11 +207,13 @@ void main() {
206207
207208 test ('parseServerMessage parses toolCallCancellation message correctly' ,
208209 () {
209- final jsonObject = {
210- 'toolCallCancellation' : {
211- 'ids' : ['1' , '2' ]
210+ final jsonObject = jsonDecode ('''
211+ {
212+ "toolCallCancellation": {
213+ "ids": ["1", "2"]
214+ }
212215 }
213- } ;
216+ ''' ) as Map < String , dynamic > ;
214217 final response = parseServerResponse (jsonObject);
215218 expect (response.message, isA <LiveServerToolCallCancellation >());
216219 final cancellationMessage =
You can’t perform that action at this time.
0 commit comments