autogen/dotnet/website/articles/AutoGen.Gemini/Function-call-with-gemini.md
2024-10-02 12:57:50 -04:00

1.7 KiB

This example shows how to use @AutoGen.Gemini.GeminiChatAgent to make function call. This example is modified from gemini-api function call example

To run this example, you need to have a project on Google Cloud with access to Vertex AI API. For more information please refer to Google Vertex AI.

Note

You can find the complete sample code here

Step 1: Install AutoGen.Gemini and AutoGen.SourceGenerator

First, install the AutoGen.Gemini package using the following command:

dotnet add package AutoGen.Gemini
dotnet add package AutoGen.SourceGenerator

The AutoGen.SourceGenerator package is required to generate the @AutoGen.Core.FunctionContract. For more information, please refer to Create-type-safe-function-call

Step 2: Add using statement

[!code-csharp]

Step 3: Create MovieFunction

[!code-csharp]

Step 4: Create a Gemini agent

[!code-csharp]

Step 5: Single turn function call

[!code-csharp]

Step 6: Multi-turn function call

[!code-csharp]