VertexAI SDK version 1.1.1 methode countTokens
Is there an existing issue for this?
- [x] I have searched the existing issues.
Which plugins are affected?
Other
Which platforms are affected?
iOS
Description
yesterday my token counting call was working fine, no code changes and today I have this error.
Error at ligne final tokenCount = await VertexClientAI.instance.countTokens([ Content.functionResponse(functionCall.name, functionResult) ]);
My snippet code
final functionCalls = response?.functionCalls.toList();
if (functionCalls != null && functionCalls.length > 0) {
await Future.forEach(functionCalls, (functionCall) async {
try {
final functionResult =
await VertexFunctionsAI.orchestration(functionCall);
if (functionResult != null) {
//
// new error here
//
final tokenCount = await VertexClientAI.instance.countTokens([
Content.functionResponse(functionCall.name, functionResult)
]);
//
//
log('Function token count: ${tokenCount.totalTokens.toString()}');
GenerateContentResponse? responseFunction =
await chatSession?.sendMessage(Content.functionResponse(
functionCall.name, functionResult));
responses.add(responseFunction);
textResponse = textResponse + (responseFunction?.text ?? "");
}
} on VertexAIException catch (e) {
log('Error VertexAI ${e.message}');
return UnimplementedError('Error VertexAI ${e.message}');
}
});
} else {
textResponse = response?.text ?? "";
}
flutter: ----------------FIREBASE CRASHLYTICS---------------- flutter: Unhandled format for CountTokensResponse: {totalBillableCharacters: 861, promptTokensDetails: [{modality: TEXT}]} This indicates a problem with the Vertex AI in Firebase SDK. Try updating to the latest version (https://pub.dev/packages/firebase_vertexai/versions), or file an issue at https://github.com/firebase/flutterfire/issuess.
flutter doctor -v [✓] Flutter (Channel stable, 3.24.3, on macOS 14.6.1 23G93 darwin-arm64, locale fr-CA) • Flutter version 3.24.3 on channel stable at /Users/robintre/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2663184aa7 (5 months ago), 2024-09-11 16:27:48 -0500 • Engine revision 36335019a8 • Dart version 3.5.3 • DevTools version 2.37.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/robintre/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 16C5032a • CocoaPods version 1.14.3
[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
[✓] VS Code (version 1.96.4) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.102.0
[✓] Connected device (4 available) • iPhone 15 Pro Max Desbois (mobile) • 00008130-00015CC43C93803A • ios • iOS 18.2.1 22C161 • iPhone 15 Pro Max (mobile) • A19787A5-1657-4F78-92F9-D1E94F334C4B • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator) • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.6.1 23G93 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 132.0.6834.111
[✓] Network resources • All expected network resources are available.
• No issues found!
Reproducing the issue
I have commented on the method in order to continue my development, this has always worked since the entire development of my AI chatbot. When writing this issue it does not give me this error in the log output
Firebase Core version
3.10.1
Flutter Version
3.24.3
Relevant Log Output
flutter: ----------------FIREBASE CRASHLYTICS----------------
flutter: Unhandled format for CountTokensResponse: {totalBillableCharacters: 861, promptTokensDetails: [{modality: TEXT}]}
This indicates a problem with the Vertex AI in Firebase SDK. Try updating to the latest version (https://pub.dev/packages/firebase_vertexai/versions), or file an issue at https://github.com/firebase/flutterfire/issuess.
flutter:
#0 parseCountTokensResponse (package:firebase_vertexai/src/api.dart:708:3)
api.dart:708
<asynchronous suspension>
#1 ChatController.askVertexAI.<anonymous closure> (package:easyconnect/chat/controllers/controllers_chat.dart:181:34)
controllers_chat.dart:181
<asynchronous suspension>
#2 Future._kTrue (dart:async/future.dart:670:3)
future.dart:670
<asynchronous suspension>
#3 _RootZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1633:12)
zone.dart:1633
<asynchronous suspension>
flutter: ----------------------------------------------------
Flutter dependencies
Expand Flutter dependencies snippet
flutter pub deps -- --style=compact
Dart SDK 3.5.3
Flutter SDK 3.24.3
easyconnect 1.0.0+1
dependencies:
- aes_ecb_pkcs5_flutter 0.1.2 [flutter]
- auto_size_text 3.0.0 [flutter]
- barcode_image 2.0.3 [args barcode image meta]
- cloud_firestore 5.6.2 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- cloud_functions 5.3.1 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter]
- connectivity_plus 6.1.2 [flutter flutter_web_plugins connectivity_plus_platform_interface web meta nm collection]
- csv 6.0.0
- cupertino_icons 1.0.8
- firebase_app_check 0.3.2+1 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter]
- firebase_auth 5.4.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 3.10.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_core_web 2.19.0 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_crashlytics 4.3.1 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- firebase_dynamic_links 6.1.1 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface]
- firebase_messaging 15.2.1 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- firebase_storage 12.4.1 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter]
- firebase_vertexai 1.1.1 [firebase_app_check firebase_auth firebase_core firebase_core_platform_interface flutter http]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_animate 4.5.2 [flutter flutter_shaders]
- flutter_chat_ui 1.6.15 [diffutil_dart equatable flutter flutter_chat_types flutter_link_previewer flutter_parsed_text intl meta photo_view scroll_to_index url_launcher visibility_detector]
- flutter_dotenv 5.2.1 [flutter]
- flutter_json_view 1.1.5 [flutter]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- font_awesome_flutter 10.8.0 [flutter]
- gal 2.3.1 [flutter]
- gap 3.0.1 [flutter]
- geojson_vi 2.2.5
- get 4.6.6 [flutter]
- google_fonts 6.2.1 [flutter http path_provider crypto]
- google_generative_ai 0.4.6 [http]
- google_maps_cluster_manager 3.1.0 [flutter google_maps_flutter_platform_interface]
- google_maps_flutter 2.10.0 [flutter google_maps_flutter_android google_maps_flutter_ios google_maps_flutter_platform_interface google_maps_flutter_web]
- googleapis 13.2.0 [_discoveryapis_commons http]
- googleapis_auth 1.6.0 [args crypto google_identity_services_web http http_parser]
- http 1.3.0 [async http_parser meta web]
- hugeicons 0.0.7 [flutter]
- iconsax 0.0.8 [flutter]
- in_app_review 2.0.10 [flutter in_app_review_platform_interface]
- intl 0.19.0 [clock meta path]
- introduction_screen 3.1.14 [flutter collection dots_indicator flutter_keyboard_visibility]
- json_serializable 6.9.0 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper]
- lib_toolkit_ui 0.0.1 [flutter barcode_widget cached_network_image cloud_firestore dotted_border file_picker flutter_animated_loadingkit font_awesome_flutter gap get image_picker intl map_launcher path_provider permission_handler pointer_interceptor qr_code_dart_scan smooth_page_indicator syncfusion_flutter_barcodes syncfusion_flutter_core syncfusion_flutter_datepicker syncfusion_flutter_gauges syncfusion_flutter_pdfviewer syncfusion_flutter_xlsio universal_html url_launcher video_player webview_flutter_web pro_image_editor http]
- location 6.0.2 [flutter location_platform_interface location_web]
- lottie 3.2.0 [archive flutter http path vector_math]
- maps_toolkit 3.0.0
- nfc_manager 3.5.0 [flutter]
- package_info_plus 8.1.4 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface web win32 clock]
- path_provider 2.1.5 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- pdf 3.11.2 [archive barcode bidi crypto image meta path_parsing vector_math xml]
- pointer_interceptor 0.10.1+2 [flutter flutter_web_plugins pointer_interceptor_ios pointer_interceptor_platform_interface pointer_interceptor_web]
- rich_text_controller 1.4.2 [flutter]
- scrollable_positioned_list 0.3.8 [flutter collection]
- shared_preferences 2.4.0 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- shimmer 3.0.0 [flutter]
- syncfusion_flutter_charts 26.2.14 [flutter intl vector_math syncfusion_flutter_core]
- syncfusion_flutter_core 26.2.14 [vector_math flutter]
- syncfusion_flutter_datagrid 26.2.14 [flutter syncfusion_flutter_core collection]
- syncfusion_flutter_datepicker 26.2.14 [flutter intl syncfusion_flutter_core]
- syncfusion_localizations 26.2.14 [flutter intl syncfusion_flutter_core]
- tuple 2.0.2
- webview_flutter 4.10.0 [flutter webview_flutter_android webview_flutter_platform_interface webview_flutter_wkwebview]
- widget_to_marker 1.0.6 [flutter google_maps_flutter]
- wiredash 2.3.0 [async clock collection device_info_plus file flutter flutter_localizations http http_parser intl material_color_utilities nanoid2 package_info_plus path_provider platform shared_preferences]
dev dependencies:
- flutter_lints 4.0.0 [lints]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]
dependency overrides:
- js 0.7.1
- syncfusion_pdfviewer_web 25.2.7 [flutter flutter_web_plugins js meta syncfusion_pdfviewer_platform_interface]
transitive dependencies:
- _discoveryapis_commons 1.0.7 [http http_parser meta]
- _fe_analyzer_shared 72.0.0 [meta]
- _flutterfire_internals 1.3.50 [collection firebase_core firebase_core_platform_interface flutter meta]
- _macros 0.3.2
- analyzer 6.7.0 [_fe_analyzer_shared collection convert crypto glob macros meta package_config path pub_semver source_span watcher yaml]
- archive 3.6.1 [crypto path]
- args 2.6.0
- async 2.11.0 [collection meta]
- barcode 2.2.9 [meta qr]
- barcode_widget 2.0.4 [barcode flutter]
- bidi 2.0.12
- boolean_selector 2.1.1 [source_span string_scanner]
- build 2.4.1 [analyzer async convert crypto glob logging meta package_config path]
- build_config 1.1.1 [checked_yaml json_annotation path pubspec_parse yaml]
- cached_network_image 3.4.1 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image]
- cached_network_image_platform_interface 4.1.1 [flutter flutter_cache_manager]
- cached_network_image_web 1.3.1 [cached_network_image_platform_interface flutter flutter_cache_manager web]
- camera 0.10.6 [camera_android camera_avfoundation camera_platform_interface camera_web flutter flutter_plugin_android_lifecycle]
- camera_android 0.10.10 [camera_platform_interface flutter flutter_plugin_android_lifecycle stream_transform]
- camera_avfoundation 0.9.18+1 [camera_platform_interface flutter stream_transform]
- camera_platform_interface 2.9.0 [cross_file flutter plugin_platform_interface stream_transform]
- camera_web 0.3.5 [camera_platform_interface flutter flutter_web_plugins stream_transform web]
- characters 1.3.0
- charcode 1.4.0
- charset 2.0.1
- checked_yaml 2.0.3 [json_annotation source_span yaml]
- clock 1.1.1
- cloud_firestore_platform_interface 6.6.2 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 4.4.2 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins]
- cloud_functions_platform_interface 5.6.1 [firebase_core flutter meta plugin_platform_interface]
- cloud_functions_web 4.10.7 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins]
- collection 1.18.0
- connectivity_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- convert 3.1.2 [typed_data]
- cross_file 0.3.4+2 [meta web]
- crypto 3.0.6 [typed_data]
- csslib 1.0.2 [source_span]
- dart_style 2.3.7 [analyzer args collection package_config path pub_semver source_span]
- dbus 0.7.11 [args ffi meta xml]
- device_info_plus 10.1.2 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta web win32 win32_registry]
- device_info_plus_platform_interface 7.0.2 [flutter meta plugin_platform_interface]
- diffutil_dart 4.0.1
- dots_indicator 2.1.2 [flutter]
- dotted_border 2.1.0 [flutter path_drawing]
- emoji_picker_flutter 3.1.0 [flutter flutter_web_plugins plugin_platform_interface shared_preferences web]
- equatable 2.0.7 [collection meta]
- fake_async 1.3.1 [clock collection]
- ffi 2.1.3
- file 7.0.1 [meta path]
- file_picker 8.1.7 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32 cross_file web]
- file_selector_linux 0.9.3+2 [cross_file file_selector_platform_interface flutter]
- file_selector_macos 0.9.4+2 [cross_file file_selector_platform_interface flutter]
- file_selector_platform_interface 2.6.2 [cross_file flutter http plugin_platform_interface]
- file_selector_windows 0.9.3+3 [cross_file file_selector_platform_interface flutter]
- firebase_app_check_platform_interface 0.1.1+1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_app_check_web 0.2.0+5 [_flutterfire_internals firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins web]
- firebase_auth_platform_interface 7.5.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 5.13.7 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser meta web]
- firebase_core_platform_interface 5.4.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_crashlytics_platform_interface 3.8.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_dynamic_links_platform_interface 0.2.7+1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_platform_interface 4.6.1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 3.10.1 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins meta web]
- firebase_storage_platform_interface 5.2.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_storage_web 3.10.8 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http meta web]
- fixnum 1.1.1
- flutter_animated_loadingkit 0.0.7 [flutter]
- flutter_cache_manager 3.4.1 [clock collection file flutter http path path_provider rxdart sqflite uuid]
- flutter_chat_types 3.6.2 [equatable json_annotation meta]
- flutter_keyboard_visibility 6.0.0 [meta flutter_keyboard_visibility_platform_interface flutter_keyboard_visibility_linux flutter_keyboard_visibility_macos flutter_keyboard_visibility_web flutter_keyboard_visibility_windows flutter]
- flutter_keyboard_visibility_linux 1.0.0 [flutter_keyboard_visibility_platform_interface flutter]
- flutter_keyboard_visibility_macos 1.0.0 [flutter_keyboard_visibility_platform_interface flutter]
- flutter_keyboard_visibility_platform_interface 2.0.0 [flutter meta plugin_platform_interface]
- flutter_keyboard_visibility_web 2.0.0 [flutter_keyboard_visibility_platform_interface flutter_web_plugins flutter]
- flutter_keyboard_visibility_windows 1.0.0 [flutter_keyboard_visibility_platform_interface flutter]
- flutter_link_previewer 3.2.2 [flutter flutter_chat_types flutter_linkify html http linkify meta url_launcher]
- flutter_linkify 6.0.0 [flutter linkify]
- flutter_parsed_text 2.2.1 [flutter]
- flutter_plugin_android_lifecycle 2.0.24 [flutter]
- flutter_shaders 0.1.3 [flutter vector_math]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- glob 2.1.3 [async collection file path string_scanner]
- google_identity_services_web 0.3.3 [meta web]
- google_maps 8.1.1 [meta web]
- google_maps_flutter_android 2.14.12 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface stream_transform]
- google_maps_flutter_ios 2.13.2 [flutter google_maps_flutter_platform_interface stream_transform]
- google_maps_flutter_platform_interface 2.9.5 [collection flutter plugin_platform_interface stream_transform]
- google_maps_flutter_web 0.5.10 [collection flutter flutter_web_plugins google_maps google_maps_flutter_platform_interface sanitize_html stream_transform web]
- html 0.15.5 [csslib source_span]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- image 4.3.0 [archive meta xml]
- image_picker 1.1.2 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_linux image_picker_macos image_picker_platform_interface image_picker_windows]
- image_picker_android 0.8.12+20 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- image_picker_for_web 3.0.6 [flutter flutter_web_plugins image_picker_platform_interface mime web]
- image_picker_ios 0.8.12+2 [flutter image_picker_platform_interface]
- image_picker_linux 0.2.1+1 [file_selector_linux file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_macos 0.2.1+2 [file_selector_macos file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_platform_interface 2.10.1 [cross_file flutter http plugin_platform_interface]
- image_picker_windows 0.2.1+1 [file_selector_platform_interface file_selector_windows flutter image_picker_platform_interface]
- in_app_review_platform_interface 2.0.5 [flutter url_launcher plugin_platform_interface platform]
- jiffy 6.3.2 [intl]
- json_annotation 4.9.0 [meta]
- leak_tracker 10.0.5 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.5 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- linkify 5.0.0
- lints 4.0.0
- location_platform_interface 4.0.0 [flutter plugin_platform_interface]
- location_web 5.0.1 [flutter flutter_web_plugins http_parser js location_platform_interface]
- logging 1.3.0
- macros 0.1.2-main.4 [_macros]
- map_launcher 3.5.0 [flutter]
- matcher 0.12.16+1 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.11.1 [collection]
- meta 1.15.0
- mime 1.0.6
- nanoid2 2.0.1
- nm 0.5.0 [dbus]
- octo_image 2.1.0 [flutter]
- package_config 2.1.1 [path]
- package_info_plus_platform_interface 3.0.2 [flutter meta plugin_platform_interface]
- path 1.9.0
- path_drawing 1.0.1 [vector_math meta path_parsing flutter]
- path_parsing 1.1.0 [meta vector_math]
- path_provider_android 2.2.15 [flutter path_provider_platform_interface]
- path_provider_foundation 2.4.1 [flutter path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface]
- path_provider_windows 2.3.0 [ffi flutter path path_provider_platform_interface]
- permission_handler 11.3.1 [flutter meta permission_handler_android permission_handler_apple permission_handler_html permission_handler_windows permission_handler_platform_interface]
- permission_handler_android 12.0.13 [flutter permission_handler_platform_interface]
- permission_handler_apple 9.4.5 [flutter permission_handler_platform_interface]
- permission_handler_html 0.1.3+5 [flutter flutter_web_plugins permission_handler_platform_interface web]
- permission_handler_platform_interface 4.2.3 [flutter meta plugin_platform_interface]
- permission_handler_windows 0.2.1 [flutter permission_handler_platform_interface]
- petitparser 6.0.2 [meta]
- photo_view 0.15.0 [flutter]
- platform 3.1.6
- plugin_platform_interface 2.1.8 [meta]
- pointer_interceptor_ios 0.10.1 [flutter plugin_platform_interface pointer_interceptor_platform_interface]
- pointer_interceptor_platform_interface 0.10.0+1 [flutter plugin_platform_interface]
- pointer_interceptor_web 0.10.2+1 [flutter flutter_web_plugins plugin_platform_interface pointer_interceptor_platform_interface web]
- pro_image_editor 5.4.2 [flutter emoji_picker_flutter http image vibration mime]
- pub_semver 2.1.5 [collection meta]
- pubspec_parse 1.4.0 [checked_yaml collection json_annotation pub_semver yaml]
- qr 3.0.2 [meta]
- qr_code_dart_scan 0.8.3 [flutter camera zxing_lib image camera_platform_interface equatable]
- rxdart 0.28.0
- sanitize_html 2.1.0 [html meta]
- scroll_to_index 3.0.1 [flutter]
- shared_preferences_android 2.4.4 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.5.4 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.4.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.4.1 [flutter plugin_platform_interface]
- shared_preferences_web 2.4.2 [flutter flutter_web_plugins shared_preferences_platform_interface web]
- shared_preferences_windows 2.4.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- sky_engine 0.0.99
- smooth_page_indicator 1.2.0+3 [flutter]
- source_gen 1.5.0 [analyzer async build dart_style glob path source_span yaml]
- source_helper 1.3.5 [analyzer collection source_gen]
- source_span 1.10.0 [collection path term_glyph]
- sprintf 7.0.0
- sqflite 2.4.1 [flutter sqflite_android sqflite_darwin sqflite_platform_interface sqflite_common path]
- sqflite_android 2.4.0 [flutter sqflite_common path sqflite_platform_interface]
- sqflite_common 2.5.4+6 [synchronized path meta]
- sqflite_darwin 2.4.1+1 [flutter sqflite_platform_interface meta sqflite_common path]
- sqflite_platform_interface 2.4.0 [flutter platform sqflite_common plugin_platform_interface meta]
- stack_trace 1.11.1 [path]
- stream_channel 2.1.2 [async]
- stream_transform 2.1.1
- string_scanner 1.2.0 [source_span]
- syncfusion_flutter_barcodes 26.2.14 [flutter syncfusion_flutter_core]
- syncfusion_flutter_gauges 26.2.14 [flutter syncfusion_flutter_core intl]
- syncfusion_flutter_pdf 26.2.14 [flutter intl xml syncfusion_flutter_core crypto convert http]
- syncfusion_flutter_pdfviewer 26.2.14 [flutter vector_math async http uuid device_info_plus intl syncfusion_pdfviewer_platform_interface syncfusion_pdfviewer_web syncfusion_pdfviewer_macos syncfusion_pdfviewer_windows syncfusion_flutter_core syncfusion_flutter_pdf syncfusion_flutter_signaturepad url_launcher]
- syncfusion_flutter_signaturepad 26.2.14 [flutter syncfusion_flutter_core]
- syncfusion_flutter_xlsio 26.2.14 [flutter xml archive image intl crypto jiffy syncfusion_officecore]
- syncfusion_officecore 26.2.14 [flutter syncfusion_flutter_core]
- syncfusion_pdfviewer_macos 26.2.14 [flutter syncfusion_pdfviewer_platform_interface]
- syncfusion_pdfviewer_platform_interface 26.2.14 [flutter plugin_platform_interface]
- syncfusion_pdfviewer_windows 26.2.14 [flutter]
- synchronized 3.3.0+3
- term_glyph 1.2.1
- test_api 0.7.2 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- typed_data 1.4.0 [collection]
- universal_html 2.2.4 [async csslib charcode collection html meta source_span typed_data universal_io]
- universal_io 2.2.2 [collection meta typed_data]
- url_launcher 6.3.1 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- url_launcher_android 6.3.14 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.3.2 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.2.1 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.2.2 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.3.2 [flutter plugin_platform_interface]
- url_launcher_web 2.3.3 [flutter flutter_web_plugins url_launcher_platform_interface web]
- url_launcher_windows 3.1.4 [flutter url_launcher_platform_interface]
- uuid 4.5.1 [crypto sprintf meta fixnum]
- vector_math 2.1.4
- vibration 2.1.0 [flutter vibration_platform_interface]
- vibration_platform_interface 0.0.3 [flutter plugin_platform_interface device_info_plus]
- video_player 2.9.2 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web]
- video_player_android 2.7.16 [flutter video_player_platform_interface]
- video_player_avfoundation 2.6.7 [flutter video_player_platform_interface]
- video_player_platform_interface 6.3.0 [flutter plugin_platform_interface]
- video_player_web 2.3.3 [flutter flutter_web_plugins video_player_platform_interface web]
- visibility_detector 0.4.0+2 [flutter]
- vm_service 14.2.5
- watcher 1.1.1 [async path]
- web 1.1.0
- webview_flutter_android 4.3.1 [flutter webview_flutter_platform_interface]
- webview_flutter_platform_interface 2.10.0 [flutter meta plugin_platform_interface]
- webview_flutter_web 0.2.3+4 [flutter flutter_web_plugins web webview_flutter_platform_interface]
- webview_flutter_wkwebview 3.18.0 [flutter path webview_flutter_platform_interface]
- win32 5.10.1 [ffi]
- win32_registry 1.1.5 [ffi win32]
- xdg_directories 1.1.0 [meta path]
- xml 6.5.0 [collection meta petitparser]
- yaml 3.1.3 [collection source_span string_scanner]
- zxing_lib 1.1.2 [intl charset]
Additional context and comments
No response
Additional information: the countTokens method works well with the count Content.multi([]) but not when using a count Content.functionResponse()
Hey there, I am unable to reproduce this issue, countTokens works fine for me in my application using the latest version, I believe the issue must lie in your implementation as your Content.functionResponse() might be missing fields or be submitting something for countTokens in the wrong format. This could explain why Content.multi([]) is working for you as it accepts multiple contents.
Just to give further context, the exception is thrown here: https://github.com/firebase/flutterfire/blob/main/packages/firebase_vertexai/firebase_vertexai/lib/src/api.dart#L697-L709
The reason why it threw an exception is because totalTokens is missing in the JSON object. That function is parsing the response made from the VertexAI server here (parse()): https://github.com/firebase/flutterfire/blob/main/packages/firebase_vertexai/firebase_vertexai/lib/src/model.dart#L176
It seems like the server isn't returning totalTokens property.
@Lerobindesbois - it does seem odd that it isn't being returned. What version of vertexAI package are you using?
@russellwheatley the version is writing in the title Issus version 1.1.1 ;-)
I've been writing this chatbot for 2 weeks and everything was working fine. The call to the method for calculating the Content.functionResponse token worked fine. And it stopped working 3 days ago.
if you look my snippet code : calling the counTokens method passes the same parameter from Content.fucntionResponse as the parameter to chatSession.sendMessage() and it works fine for sending the message to VertexAI. And this is the only way to receive the number of tokens for a function.
In the jsonObject the call to the method for a Content.functionResponse does not return the 'totalTokens' attribute in the object. Why?
Hey @Lerobindesbois are you still experiencing issues?
@MichaelVerdon I had to add Content.text with Content.fucntionResponse to each call to with the token count for the call and I no longer have this error. This is not specified in the documentation and I find it unusual for the token count of the call of a functionResponse. Is this normal?
Hello, thank you for your response 😄. As far as I know after doing some research, I have only seen documentation explicitly say we can use countTokens() with Content.multi in https://firebase.google.com/docs/vertex-ai/count-tokens?platform=flutter#multimodal-input and with simple text prompts, however I have not been able to see this being used with function calling so I do find it very strange also. It seems to follow a format of 'prompt' or 'prompt' and 'media' which could maybe explain why the work around worked? Can I please see what your work around looks like so I can further investigate what is going on?
Hey @Lerobindesbois. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Yes @MichaelVerdon
Look at the code in my first post, my 'WORK AROUND' is commented here in this snippet, you can see the difference.
` final functionCalls = response?.functionCalls.toList();
if (functionCalls != null && functionCalls.length > 0) {
await Future.forEach(functionCalls, (functionCall) async {
try {
final functionResult =
await VertexFunctionsAI.orchestration(functionCall);
if (functionResult != null) {
//
// new error here
//
final tokenCount = await VertexClientAI.instance.countTokens([
//
// WORK AROUND // Add Content.text(question),
Content.text(question),
// WORK AROUND // Add Content.text(response).
Content.functionResponse(functionCall.name, functionResult)
]);
//
//
log('Function token count: ${tokenCount.totalTokens.toString()}');
GenerateContentResponse? responseFunction =
await chatSession?.sendMessage(Content.functionResponse(
functionCall.name, functionResult));
responses.add(responseFunction);
textResponse = textResponse + (responseFunction?.text ?? "");
}
} on VertexAIException catch (e) {
log('Error VertexAI ${e.message}');
return UnimplementedError('Error VertexAI ${e.message}');
}
});
} else {
textResponse = response?.text ?? "";
}`
Hey there @Lerobindesbois VertexAI has been deprecated for Firebase_AI, can you try using that and telling me if the issue persists?
Hey there, this issue appears to be going stale, if you are experiencing this issue on the new Firebase_AI package, please open a new ticket.