Skip to content

How Can I get functionCalls? #98

Closed
Closed
@toshiossada

Description

@toshiossada

using google_generative_ai package I can handle functionCall at gemini responses, but I didn't find how I can do this on flutter_ai_toolkit

as

  late final gemini= GenerativeModel(
      model: 'gemini-2.0-flash',
      apiKey: 'AIzaSyBL7n5X',
      tools: geminiTools.tools,
    );
  final geminiTools = GeminiTools();
  late chatSession = gemini.startChat();;
handleReponse(){
                    final response =
                        await chatSession.sendMessage(Content.text(question));

                    setState(() {
                      answer = response.text ?? '';
                      for (var function in response.functionCalls) {
                        final result = GeminiTools()
                            .handleFunctionCall(function.name, function.args);

                        if (!result.success) {
                          ScaffoldMessenger.of(context).showSnackBar(
                            SnackBar(
                              content: Text('Erro: ${result.reason}'),
                              backgroundColor: Colors.red,
                            ),
                          );
                        } else {
                          model = result;
                        }
}

I tried to listen GeminiProvider but I can't access this information

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions