source
stringclasses 1
value | repository
stringclasses 1
value | file
stringlengths 17
99
| label
stringclasses 1
value | content
stringlengths 11
13.3k
|
---|---|---|---|---|
GitHub | autogen | autogen/dotnet/website/articles/Create-your-own-middleware.md | autogen | ## Coming soon |
GitHub | autogen | autogen/dotnet/website/articles/Function-call-middleware.md | autogen | # Coming soon |
GitHub | autogen | autogen/dotnet/website/articles/OpenAIChatAgent-support-more-messages.md | autogen | By default, @AutoGen.OpenAI.OpenAIChatAgent only supports the @AutoGen.Core.IMessage<T> type where `T` is original request or response message from `Azure.AI.OpenAI`. To support more AutoGen built-in message types like @AutoGen.Core.TextMessage, @AutoGen.Core.ImageMessage, @AutoGen.Core.MultiModalMessage and so on, you can register the agent with @AutoGen.OpenAI.OpenAIChatRequestMessageConnector. The @AutoGen.OpenAI.OpenAIChatRequestMessageConnector will convert the message from AutoGen built-in message types to `Azure.AI.OpenAI.ChatRequestMessage` and vice versa. import the required namespaces: [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/OpenAICodeSnippet.cs?name=using_statement)] [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/OpenAICodeSnippet.cs?name=register_openai_chat_message_connector)] |
GitHub | autogen | autogen/dotnet/website/articles/OpenAIChatAgent-connect-to-third-party-api.md | autogen | The following example shows how to connect to third-party OpenAI API using @AutoGen.OpenAI.OpenAIChatAgent. [![](https://img.shields.io/badge/Open%20on%20Github-grey?logo=github)](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.OpenAI.Sample/Connect_To_Ollama.cs) |
GitHub | autogen | autogen/dotnet/website/articles/OpenAIChatAgent-connect-to-third-party-api.md | autogen | Overview A lot of LLM applications/platforms support spinning up a chat server that is compatible with OpenAI API, such as LM Studio, Ollama, Mistral etc. This means that you can connect to these servers using the @AutoGen.OpenAI.OpenAIChatAgent. > [!NOTE] > Some platforms might not support all the features of OpenAI API. For example, Ollama does not support `function call` when using it's openai API according to its [document](https://github.com/ollama/ollama/blob/main/docs/openai.md#v1chatcompletions) (as of 2024/05/07). > That means some of the features of OpenAI API might not work as expected when using these platforms with the @AutoGen.OpenAI.OpenAIChatAgent. > Please refer to the platform's documentation for more information. |
GitHub | autogen | autogen/dotnet/website/articles/OpenAIChatAgent-connect-to-third-party-api.md | autogen | Prerequisites - Install the following packages: ```bash dotnet add package AutoGen.OpenAI --version AUTOGEN_VERSION ``` - Spin up a chat server that is compatible with OpenAI API. The following example uses Ollama as the chat server, and llama3 as the llm model. ```bash ollama serve ``` |
GitHub | autogen | autogen/dotnet/website/articles/OpenAIChatAgent-connect-to-third-party-api.md | autogen | Steps - Import the required namespaces: [!code-csharp[](../../sample/AutoGen.OpenAI.Sample/Connect_To_Ollama.cs?name=using_statement)] - Create a `CustomHttpClientHandler` class. The `CustomHttpClientHandler` class is used to customize the HttpClientHandler. In this example, we override the `SendAsync` method to redirect the request to local Ollama server, which is running on `http://localhost:11434`. [!code-csharp[](../../sample/AutoGen.OpenAI.Sample/Connect_To_Ollama.cs?name=CustomHttpClientHandler)] - Create an `OpenAIChatAgent` instance and connect to the third-party API. Then create an @AutoGen.OpenAI.OpenAIChatAgent instance and connect to the OpenAI API from Ollama. You can customize the transport behavior of `OpenAIClient` by passing a customized `HttpClientTransport` instance. In the customized `HttpClientTransport` instance, we pass the `CustomHttpClientHandler` we just created which redirects all openai chat requests to the local Ollama server. [!code-csharp[](../../sample/AutoGen.OpenAI.Sample/Connect_To_Ollama.cs?name=create_agent)] - Chat with the `OpenAIChatAgent`. Finally, you can start chatting with the agent. In this example, we send a coding question to the agent and get the response. [!code-csharp[](../../sample/AutoGen.OpenAI.Sample/Connect_To_Ollama.cs?name=send_message)] |
GitHub | autogen | autogen/dotnet/website/articles/OpenAIChatAgent-connect-to-third-party-api.md | autogen | Sample Output The following is the sample output of the code snippet above: ![output](../images/articles/ConnectTo3PartyOpenAI/output.gif) |
GitHub | autogen | autogen/dotnet/website/articles/getting-start.md | autogen | ### Get start with AutoGen for dotnet [![dotnet-ci](https://github.com/microsoft/autogen/actions/workflows/dotnet-build.yml/badge.svg)](https://github.com/microsoft/autogen/actions/workflows/dotnet-build.yml) [![Discord](https://img.shields.io/discord/1153072414184452236?logo=discord&style=flat)](https://discord.gg/pAbnFJrkgZ) [![NuGet version](https://badge.fury.io/nu/AutoGen.Core.svg)](https://badge.fury.io/nu/AutoGen.Core) Firstly, add `AutoGen` package to your project. ```bash dotnet add package AutoGen ``` > [!NOTE] > For more information about installing packages, please check out the [installation guide](Installation.md). Then you can start with the following code snippet to create a conversable agent and chat with it. [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/GetStartCodeSnippet.cs?name=snippet_GetStartCodeSnippet)] [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/GetStartCodeSnippet.cs?name=code_snippet_1)] ### Tutorial Getting started with AutoGen.Net by following the [tutorial](../tutorial/Chat-with-an-agent.md) series. ### Examples You can find more examples under the [sample project](https://github.com/microsoft/autogen/tree/dotnet/dotnet/sample/AutoGen.BasicSamples). ### Report a bug or request a feature You can report a bug or request a feature by creating a new issue in the [github issue](https://github.com/microsoft/autogen/issues) and specifying label the label "donet" |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen-OpenAI-Overview.md | autogen | ## AutoGen.OpenAI Overview AutoGen.OpenAI provides the following agents over openai models: - @AutoGen.OpenAI.OpenAIChatAgent: A slim wrapper agent over `OpenAIClient`. This agent only support `IMessage<ChatRequestMessage>` message type. To support more message types like @AutoGen.Core.TextMessage, register the agent with @AutoGen.OpenAI.OpenAIChatRequestMessageConnector. - @AutoGen.OpenAI.GPTAgent: An agent that build on top of @AutoGen.OpenAI.OpenAIChatAgent with more message types support like @AutoGen.Core.TextMessage, @AutoGen.Core.ImageMessage, @AutoGen.Core.MultiModalMessage and function call support. Essentially, it is equivalent to @AutoGen.OpenAI.OpenAIChatAgent with @AutoGen.Core.FunctionCallMiddleware and @AutoGen.OpenAI.OpenAIChatRequestMessageConnector registered. ### Get start with AutoGen.OpenAI To get start with AutoGen.OpenAI, firstly, follow the [installation guide](Installation.md) to make sure you add the AutoGen feed correctly. Then add `AutoGen.OpenAI` package to your project file. ```xml <ItemGroup> <PackageReference Include="AutoGen.OpenAI" Version="AUTOGEN_VERSION" /> </ItemGroup> ``` |
GitHub | autogen | autogen/dotnet/website/articles/Create-type-safe-function-call.md | autogen | ## Type-safe function call `AutoGen` provides a source generator to easness the trouble of manually craft function definition and function call wrapper from a function. To use this feature, simply add the `AutoGen.SourceGenerator` package to your project and decorate your function with @AutoGen.Core.FunctionAttribute. ```bash dotnet add package AutoGen.SourceGenerator ``` > [!NOTE] > It's recommended to enable structural xml document support by setting `GenerateDocumentationFile` property to true in your project file. This allows source generator to leverage the documentation of the function when generating the function definition. ```xml <PropertyGroup> <!-- This enables structural xml document support --> <GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup> ``` Then, create a `public partial` class to host the methods you want to use in AutoGen agents. The method has to be a `public` instance method and its return type must be `Task<string>`. After the methods is defined, mark them with @AutoGen.FunctionAttribute attribute: > [!NOTE] > A `public partial` class is required for the source generator to generate code. > The method has to be a `public` instance method and its return type must be `Task<string>`. > Mark the method with @AutoGen.Core.FunctionAttribute attribute. Firstly, import the required namespaces: [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/TypeSafeFunctionCallCodeSnippet.cs?name=weather_report_using_statement)] Then, create a `WeatherReport` function and mark it with @AutoGen.Core.FunctionAttribute: [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/TypeSafeFunctionCallCodeSnippet.cs?name=weather_report)] The source generator will generate the @AutoGen.Core.FunctionContract and function call wrapper for `WeatherReport` in another partial class based on its signature and structural comments. The @AutoGen.Core.FunctionContract is introduced by [#1736](https://github.com/microsoft/autogen/pull/1736) and contains all the necessary metadata such as function name, parameters, and return type. It is LLM independent and can be used to generate openai function definition or semantic kernel function. The function call wrapper is a helper class that provides a type-safe way to call the function. > [!NOTE] > If you are using VSCode as your editor, you may need to restart the editor to see the generated code. The following code shows how to generate openai function definition from the @AutoGen.Core.FunctionContract and call the function using the function call wrapper. [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/TypeSafeFunctionCallCodeSnippet.cs?name=weather_report_consume)] |
GitHub | autogen | autogen/dotnet/website/articles/Create-an-agent.md | autogen | ## AssistantAgent [`AssistantAgent`](../api/AutoGen.AssistantAgent.yml) is a built-in agent in `AutoGen` that acts as an AI assistant. It uses LLM to generate response to user input. It also supports function call if the underlying LLM model supports it (e.g. `gpt-3.5-turbo-0613`). |
GitHub | autogen | autogen/dotnet/website/articles/Create-an-agent.md | autogen | Create an `AssistantAgent` using OpenAI model. [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/CreateAnAgent.cs?name=code_snippet_1)] |
GitHub | autogen | autogen/dotnet/website/articles/Create-an-agent.md | autogen | Create an `AssistantAgent` using Azure OpenAI model. [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/CreateAnAgent.cs?name=code_snippet_2)] |
GitHub | autogen | autogen/dotnet/website/articles/Print-message-middleware.md | autogen | @AutoGen.Core.PrintMessageMiddleware is a built-in @AutoGen.Core.IMiddleware that pretty print @AutoGen.Core.IMessage to console. > [!NOTE] > @AutoGen.Core.PrintMessageMiddleware support the following @AutoGen.Core.IMessage types: > - @AutoGen.Core.TextMessage > - @AutoGen.Core.MultiModalMessage > - @AutoGen.Core.ToolCallMessage > - @AutoGen.Core.ToolCallResultMessage > - @AutoGen.Core.Message > - (streaming) @AutoGen.Core.TextMessageUpdate > - (streaming) @AutoGen.Core.ToolCallMessageUpdate |
GitHub | autogen | autogen/dotnet/website/articles/Print-message-middleware.md | autogen | Use @AutoGen.Core.PrintMessageMiddleware in an agent You can use @AutoGen.Core.PrintMessageMiddlewareExtension.RegisterPrintMessage* to register the @AutoGen.Core.PrintMessageMiddleware to an agent. [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/PrintMessageMiddlewareCodeSnippet.cs?name=PrintMessageMiddleware)] @AutoGen.Core.PrintMessageMiddlewareExtension.RegisterPrintMessage* will format the message and print it to console ![image](../images/articles/PrintMessageMiddleware/printMessage.png) |
GitHub | autogen | autogen/dotnet/website/articles/Print-message-middleware.md | autogen | Streaming message support @AutoGen.Core.PrintMessageMiddleware also supports streaming message types like @AutoGen.Core.TextMessageUpdate and @AutoGen.Core.ToolCallMessageUpdate. If you register @AutoGen.Core.PrintMessageMiddleware to a @AutoGen.Core.IStreamingAgent, it will format the streaming message and print it to console if the message is of supported type. [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/PrintMessageMiddlewareCodeSnippet.cs?name=print_message_streaming)] ![image](../images/articles/PrintMessageMiddleware/streamingoutput.gif) |
GitHub | autogen | autogen/dotnet/website/articles/MistralChatAgent-count-token-usage.md | autogen | The following example shows how to create a `MistralAITokenCounterMiddleware` @AutoGen.Core.IMiddleware and count the token usage when chatting with @AutoGen.Mistral.MistralClientAgent. ### Overview To collect the token usage for the entire chat session, one easy solution is simply collect all the responses from agent and sum up the token usage for each response. To collect all the agent responses, we can create a middleware which simply saves all responses to a list and register it with the agent. To get the token usage information for each response, because in the example we are using @AutoGen.Mistral.MistralClientAgent, we can simply get the token usage from the response object. > [!NOTE] > You can find the complete example in the [Example13_OpenAIAgent_JsonMode](https://github.com/microsoft/autogen/tree/main/dotnet/sample/AutoGen.BasicSamples/Example14_MistralClientAgent_TokenCount.cs). - Step 1: Adding using statement [!code-csharp[](../../sample/AutoGen.BasicSamples/Example14_MistralClientAgent_TokenCount.cs?name=using_statements)] - Step 2: Create a `MistralAITokenCounterMiddleware` class which implements @AutoGen.Core.IMiddleware. This middleware will collect all the responses from the agent and sum up the token usage for each response. [!code-csharp[](../../sample/AutoGen.BasicSamples/Example14_MistralClientAgent_TokenCount.cs?name=token_counter_middleware)] - Step 3: Create a `MistralClientAgent` [!code-csharp[](../../sample/AutoGen.BasicSamples/Example14_MistralClientAgent_TokenCount.cs?name=create_mistral_client_agent)] - Step 4: Register the `MistralAITokenCounterMiddleware` with the `MistralClientAgent`. Note that the order of each middlewares matters. The token counter middleware needs to be registered before `mistralMessageConnector` because it collects response only when the responding message type is `IMessage<ChatCompletionResponse>` while the `mistralMessageConnector` will convert `IMessage<ChatCompletionResponse>` to one of @AutoGen.Core.TextMessage, @AutoGen.Core.ToolCallMessage or @AutoGen.Core.ToolCallResultMessage. [!code-csharp[](../../sample/AutoGen.BasicSamples/Example14_MistralClientAgent_TokenCount.cs?name=register_middleware)] - Step 5: Chat with the `MistralClientAgent` and get the token usage information from the response object. [!code-csharp[](../../sample/AutoGen.BasicSamples/Example14_MistralClientAgent_TokenCount.cs?name=chat_with_agent)] ### Output When running the example, the completion token count will be printed to the console. ```bash Completion token count: 1408 # might be different based on the response ``` |
GitHub | autogen | autogen/dotnet/website/articles/OpenAIChatAgent-simple-chat.md | autogen | The following example shows how to create an @AutoGen.OpenAI.OpenAIChatAgent and chat with it. Firsly, import the required namespaces: [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/OpenAICodeSnippet.cs?name=using_statement)] Then, create an @AutoGen.OpenAI.OpenAIChatAgent and chat with it: [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/OpenAICodeSnippet.cs?name=create_openai_chat_agent)] @AutoGen.OpenAI.OpenAIChatAgent also supports streaming chat via @AutoGen.Core.IAgent.GenerateStreamingReplyAsync*. [!code-csharp[](../../sample/AutoGen.BasicSamples/CodeSnippet/OpenAICodeSnippet.cs?name=create_openai_chat_agent_streaming)] |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.Ollama/Chat-with-llava.md | autogen | This sample shows how to use @AutoGen.Ollama.OllamaAgent to chat with LLaVA model. To run this example, you need to have an Ollama server running aside and have `llava:latest` model installed. For how to setup an Ollama server, please refer to [Ollama](https://ollama.com/). > [!NOTE] > You can find the complete sample code [here](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.Ollama.Sample/Chat_With_LLaVA.cs) ### Step 1: Install AutoGen.Ollama First, install the AutoGen.Ollama package using the following command: ```bash dotnet add package AutoGen.Ollama ``` For how to install from nightly build, please refer to [Installation](../Installation.md). ### Step 2: Add using statement [!code-csharp[](../../../sample/AutoGen.Ollama.Sample/Chat_With_LLaVA.cs?name=Using)] ### Step 3: Create @AutoGen.Ollama.OllamaAgent [!code-csharp[](../../../sample/AutoGen.Ollama.Sample/Chat_With_LLaVA.cs?name=Create_Ollama_Agent)] ### Step 4: Start MultiModal Chat LLaVA is a multimodal model that supports both text and image inputs. In this step, we create an image message along with a question about the image. [!code-csharp[](../../../sample/AutoGen.Ollama.Sample/Chat_With_LLaVA.cs?name=Send_Message)] |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.Ollama/Chat-with-llama.md | autogen | This example shows how to use @AutoGen.Ollama.OllamaAgent to connect to Ollama server and chat with LLaVA model. To run this example, you need to have an Ollama server running aside and have `llama3:latest` model installed. For how to setup an Ollama server, please refer to [Ollama](https://ollama.com/). > [!NOTE] > You can find the complete sample code [here](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.Ollama.Sample/Chat_With_LLaMA.cs) ### Step 1: Install AutoGen.Ollama First, install the AutoGen.Ollama package using the following command: ```bash dotnet add package AutoGen.Ollama ``` For how to install from nightly build, please refer to [Installation](../Installation.md). ### Step 2: Add using statement [!code-csharp[](../../../sample/AutoGen.Ollama.Sample/Chat_With_LLaMA.cs?name=Using)] ### Step 3: Create and chat @AutoGen.Ollama.OllamaAgent In this step, we create an @AutoGen.Ollama.OllamaAgent and connect it to the Ollama server. [!code-csharp[](../../../sample/AutoGen.Ollama.Sample/Chat_With_LLaMA.cs?name=Create_Ollama_Agent)] |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.SemanticKernel/Use-kernel-plugin-in-other-agents.md | autogen | In semantic kernel, a kernel plugin is a collection of kernel functions that can be invoked during LLM calls. Semantic kernel provides a list of built-in plugins, like [core plugins](https://github.com/microsoft/semantic-kernel/tree/main/dotnet/src/Plugins/Plugins.Core), [web search plugin](https://github.com/microsoft/semantic-kernel/tree/main/dotnet/src/Plugins/Plugins.Web) and many more. You can also create your own plugins and use them in semantic kernel. Kernel plugins greatly extend the capabilities of semantic kernel and can be used to perform various tasks like web search, image search, text summarization, etc. `AutoGen.SemanticKernel` provides a middleware called @AutoGen.SemanticKernel.KernelPluginMiddleware that allows you to use semantic kernel plugins in other AutoGen agents like @AutoGen.OpenAI.OpenAIChatAgent. The following example shows how to define a simple plugin with a single `GetWeather` function and use it in @AutoGen.OpenAI.OpenAIChatAgent. > [!NOTE] > You can find the complete sample code [here](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.SemanticKernel.Sample/Use_Kernel_Functions_With_Other_Agent.cs) ### Step 1: add using statement [!code-csharp[](../../../sample/AutoGen.SemanticKernel.Sample/Use_Kernel_Functions_With_Other_Agent.cs?name=Using)] ### Step 2: create plugin In this step, we create a simple plugin with a single `GetWeather` function that takes a location as input and returns the weather information for that location. [!code-csharp[](../../../sample/AutoGen.SemanticKernel.Sample/Use_Kernel_Functions_With_Other_Agent.cs?name=Create_plugin)] ### Step 3: create OpenAIChatAgent and use the plugin In this step, we firstly create a @AutoGen.SemanticKernel.KernelPluginMiddleware and register the previous plugin with it. The `KernelPluginMiddleware` will load the plugin and make the functions available for use in other agents. Followed by creating an @AutoGen.OpenAI.OpenAIChatAgent and register it with the `KernelPluginMiddleware`. [!code-csharp[](../../../sample/AutoGen.SemanticKernel.Sample/Use_Kernel_Functions_With_Other_Agent.cs?name=Use_plugin)] ### Step 4: chat with OpenAIChatAgent In this final step, we start the chat with the @AutoGen.OpenAI.OpenAIChatAgent by asking the weather in Seattle. The `OpenAIChatAgent` will use the `GetWeather` function from the plugin to get the weather information for Seattle. [!code-csharp[](../../../sample/AutoGen.SemanticKernel.Sample/Use_Kernel_Functions_With_Other_Agent.cs?name=Send_message)] |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.SemanticKernel/SemanticKernelChatAgent-simple-chat.md | autogen | `AutoGen.SemanticKernel` provides built-in support for `ChatCompletionAgent` via @AutoGen.SemanticKernel.SemanticKernelChatCompletionAgent. By default the @AutoGen.SemanticKernel.SemanticKernelChatCompletionAgent only supports the original `ChatMessageContent` type via `IMessage<ChatMessageContent>`. To support more AutoGen built-in message types like @AutoGen.Core.TextMessage, @AutoGen.Core.ImageMessage, @AutoGen.Core.MultiModalMessage, you can register the agent with @AutoGen.SemanticKernel.SemanticKernelChatMessageContentConnector. The @AutoGen.SemanticKernel.SemanticKernelChatMessageContentConnector will convert the message from AutoGen built-in message types to `ChatMessageContent` and vice versa. The following step-by-step example shows how to create an @AutoGen.SemanticKernel.SemanticKernelChatCompletionAgent and chat with it: > [!NOTE] > You can find the complete sample code [here](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.SemanticKernel.Sample/Create_Semantic_Kernel_Chat_Agent.cs). ### Step 1: add using statement [!code-csharp[](../../../sample/AutoGen.SemanticKernel.Sample/Create_Semantic_Kernel_Chat_Agent.cs?name=Using)] ### Step 2: create kernel [!code-csharp[](../../../sample/AutoGen.SemanticKernel.Sample/Create_Semantic_Kernel_Chat_Agent.cs?name=Create_Kernel)] ### Step 3: create ChatCompletionAgent [!code-csharp[](../../../sample/AutoGen.SemanticKernel.Sample/Create_Semantic_Kernel_Chat_Agent.cs?name=Create_ChatCompletionAgent)] ### Step 4: create @AutoGen.SemanticKernel.SemanticKernelChatCompletionAgent In this step, we create an @AutoGen.SemanticKernel.SemanticKernelChatCompletionAgent and register it with @AutoGen.SemanticKernel.SemanticKernelChatMessageContentConnector. The @AutoGen.SemanticKernel.SemanticKernelChatMessageContentConnector will convert the message from AutoGen built-in message types to `ChatMessageContent` and vice versa. [!code-csharp[](../../../sample/AutoGen.SemanticKernel.Sample/Create_Semantic_Kernel_Chat_Agent.cs?name=Create_SemanticKernelChatCompletionAgent)] ### Step 5: chat with @AutoGen.SemanticKernel.SemanticKernelChatCompletionAgent [!code-csharp[](../../../sample/AutoGen.SemanticKernel.Sample/Create_Semantic_Kernel_Chat_Agent.cs?name=Send_Message)] |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.SemanticKernel/SemanticKernelAgent-simple-chat.md | autogen | You can chat with @AutoGen.SemanticKernel.SemanticKernelAgent using both streaming and non-streaming methods and use native `ChatMessageContent` type via `IMessage<ChatMessageContent>`. The following example shows how to create an @AutoGen.SemanticKernel.SemanticKernelAgent and chat with it using non-streaming method: [!code-csharp[](../../../sample/AutoGen.BasicSamples/CodeSnippet/SemanticKernelCodeSnippet.cs?name=create_semantic_kernel_agent)] @AutoGen.SemanticKernel.SemanticKernelAgent also supports streaming chat via @AutoGen.Core.IStreamingAgent.GenerateStreamingReplyAsync*. [!code-csharp[](../../../sample/AutoGen.BasicSamples/CodeSnippet/SemanticKernelCodeSnippet.cs?name=create_semantic_kernel_agent_streaming)] |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.SemanticKernel/AutoGen-SemanticKernel-Overview.md | autogen | ## AutoGen.SemanticKernel Overview AutoGen.SemanticKernel is a package that provides seamless integration with Semantic Kernel. It provides the following agents: - @AutoGen.SemanticKernel.SemanticKernelAgent: A slim wrapper agent over `Kernel` that only support original `ChatMessageContent` type via `IMessage<ChatMessageContent>`. To support more AutoGen built-in message type, register the agent with @AutoGen.SemanticKernel.SemanticKernelChatMessageContentConnector. - @AutoGen.SemanticKernel.SemanticKernelChatCompletionAgent: A slim wrapper agent over `Microsoft.SemanticKernel.Agents.ChatCompletionAgent`. AutoGen.SemanticKernel also provides the following middleware: - @AutoGen.SemanticKernel.SemanticKernelChatMessageContentConnector: A connector that convert the message from AutoGen built-in message types to `ChatMessageContent` and vice versa. At the current stage, it only supports conversation between @AutoGen.Core.TextMessage, @AutoGen.Core.ImageMessage and @AutoGen.Core.MultiModalMessage. Function call message type like @AutoGen.Core.ToolCallMessage and @AutoGen.Core.ToolCallResultMessage are not supported yet. - @AutoGen.SemanticKernel.KernelPluginMiddleware: A middleware that allows you to use semantic kernel plugins in other AutoGen agents like @AutoGen.OpenAI.OpenAIChatAgent. ### Get start with AutoGen.SemanticKernel To get start with AutoGen.SemanticKernel, firstly, follow the [installation guide](../Installation.md) to make sure you add the AutoGen feed correctly. Then add `AutoGen.SemanticKernel` package to your project file. ```xml <ItemGroup> <PackageReference Include="AutoGen.SemanticKernel" Version="AUTOGEN_VERSION" /> </ItemGroup> ``` |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.SemanticKernel/SemanticKernelAgent-support-more-messages.md | autogen | @AutoGen.SemanticKernel.SemanticKernelAgent only supports the original `ChatMessageContent` type via `IMessage<ChatMessageContent>`. To support more AutoGen built-in message types like @AutoGen.Core.TextMessage, @AutoGen.Core.ImageMessage, @AutoGen.Core.MultiModalMessage, you can register the agent with @AutoGen.SemanticKernel.SemanticKernelChatMessageContentConnector. The @AutoGen.SemanticKernel.SemanticKernelChatMessageContentConnector will convert the message from AutoGen built-in message types to `ChatMessageContent` and vice versa. > [!NOTE] > At the current stage, @AutoGen.SemanticKernel.SemanticKernelChatMessageContentConnector only supports conversation for the followng built-in @AutoGen.Core.IMessage > - @AutoGen.Core.TextMessage > - @AutoGen.Core.ImageMessage > - @AutoGen.Core.MultiModalMessage > > Function call message type like @AutoGen.Core.ToolCallMessage and @AutoGen.Core.ToolCallResultMessage are not supported yet. [!code-csharp[](../../../sample/AutoGen.BasicSamples/CodeSnippet/SemanticKernelCodeSnippet.cs?name=register_semantic_kernel_chat_message_content_connector)] |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.Gemini/Overview.md | autogen | # AutoGen.Gemini Overview AutoGen.Gemini is a package that provides seamless integration with Google Gemini. It provides the following agent: - @AutoGen.Gemini.GeminiChatAgent: The agent that connects to Google Gemini or Vertex AI Gemini. It supports chat, multi-modal chat, and function call. AutoGen.Gemini also provides the following middleware: - @AutoGen.Gemini.GeminiMessageConnector: The middleware that converts the Gemini message to AutoGen built-in message type. |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.Gemini/Overview.md | autogen | Examples You can find more examples under the [gemini sample project](https://github.com/microsoft/autogen/tree/main/dotnet/sample/AutoGen.Gemini.Sample) |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.Gemini/Chat-with-google-gemini.md | autogen | This example shows how to use @AutoGen.Gemini.GeminiChatAgent to connect to Google AI Gemini and chat with Gemini model. To run this example, you need to have a Google AI Gemini API key. For how to get a Google Gemini API key, please refer to [Google Gemini](https://gemini.google.com/). > [!NOTE] > You can find the complete sample code [here](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.Gemini.Sample/Chat_With_Google_Gemini.cs) > [!NOTE] > What's the difference between Google AI Gemini and Vertex AI Gemini? > > Gemini is a series of large language models developed by Google. You can use it either from Google AI API or Vertex AI API. If you are relatively new to Gemini and wants to explore the feature and build some prototype for your chatbot app, Google AI APIs (with Google AI Studio) is a fast way to get started. While your app and idea matures and you'd like to leverage more MLOps tools that streamline the usage, deployment, and monitoring of models, you can move to Google Cloud Vertex AI which provides Gemini APIs along with many other features. Basically, to help you productionize your app. ([reference](https://stackoverflow.com/questions/78007243/utilizing-gemini-through-vertex-ai-or-through-google-generative-ai)) ### Step 1: Install AutoGen.Gemini First, install the AutoGen.Gemini package using the following command: ```bash dotnet add package AutoGen.Gemini ``` ### Step 2: Add using statement [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Chat_With_Google_Gemini.cs?name=Using)] ### Step 3: Create a Gemini agent [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Chat_With_Google_Gemini.cs?name=Create_Gemini_Agent)] ### Step 4: Chat with Gemini [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Chat_With_Google_Gemini.cs?name=Chat_With_Google_Gemini)] |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.Gemini/Image-chat-with-gemini.md | autogen | This example shows how to use @AutoGen.Gemini.GeminiChatAgent for image chat with Gemini model. 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](https://cloud.google.com/vertex-ai/docs). > [!NOTE] > You can find the complete sample code [here](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.Gemini.Sample/Image_Chat_With_Vertex_Gemini.cs) ### Step 1: Install AutoGen.Gemini First, install the AutoGen.Gemini package using the following command: ```bash dotnet add package AutoGen.Gemini ``` ### Step 2: Add using statement [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Image_Chat_With_Vertex_Gemini.cs?name=Using)] ### Step 3: Create a Gemini agent [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Image_Chat_With_Vertex_Gemini.cs?name=Create_Gemini_Agent)] ### Step 4: Send image to Gemini [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Image_Chat_With_Vertex_Gemini.cs?name=Send_Image_Request)] |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.Gemini/Function-call-with-gemini.md | autogen | This example shows how to use @AutoGen.Gemini.GeminiChatAgent to make function call. This example is modified from [gemini-api function call example](https://ai.google.dev/gemini-api/docs/function-calling) 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](https://cloud.google.com/vertex-ai/docs). > [!NOTE] > You can find the complete sample code [here](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.Gemini.Sample/Function_Call_With_Gemini.cs) ### Step 1: Install AutoGen.Gemini and AutoGen.SourceGenerator First, install the AutoGen.Gemini package using the following command: ```bash 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](../Create-type-safe-function-call.md) ### Step 2: Add using statement [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Function_call_with_gemini.cs?name=Using)] ### Step 3: Create `MovieFunction` [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Function_call_with_gemini.cs?name=MovieFunction)] ### Step 4: Create a Gemini agent [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Function_call_with_gemini.cs?name=Create_Gemini_Agent)] ### Step 5: Single turn function call [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Function_call_with_gemini.cs?name=Single_turn)] ### Step 6: Multi-turn function call [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Function_call_with_gemini.cs?name=Multi_turn)] |
GitHub | autogen | autogen/dotnet/website/articles/AutoGen.Gemini/Chat-with-vertex-gemini.md | autogen | This example shows how to use @AutoGen.Gemini.GeminiChatAgent to connect to Vertex AI Gemini API and chat with Gemini model. 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](https://cloud.google.com/vertex-ai/docs). > [!NOTE] > You can find the complete sample code [here](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.Gemini.Sample/Chat_With_Vertex_Gemini.cs) > [!NOTE] > What's the difference between Google AI Gemini and Vertex AI Gemini? > > Gemini is a series of large language models developed by Google. You can use it either from Google AI API or Vertex AI API. If you are relatively new to Gemini and wants to explore the feature and build some prototype for your chatbot app, Google AI APIs (with Google AI Studio) is a fast way to get started. While your app and idea matures and you'd like to leverage more MLOps tools that streamline the usage, deployment, and monitoring of models, you can move to Google Cloud Vertex AI which provides Gemini APIs along with many other features. Basically, to help you productionize your app. ([reference](https://stackoverflow.com/questions/78007243/utilizing-gemini-through-vertex-ai-or-through-google-generative-ai)) ### Step 1: Install AutoGen.Gemini First, install the AutoGen.Gemini package using the following command: ```bash dotnet add package AutoGen.Gemini ``` ### Step 2: Add using statement [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Chat_With_Vertex_Gemini.cs?name=Using)] ### Step 3: Create a Gemini agent [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Chat_With_Vertex_Gemini.cs?name=Create_Gemini_Agent)] ### Step 4: Chat with Gemini [!code-csharp[](../../../sample/AutoGen.Gemini.Sample/Chat_With_Vertex_Gemini.cs?name=Chat_With_Vertex_Gemini)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Use-AutoGen.Net-agent-as-model-in-AG-Studio.md | autogen | This tutorial shows how to use AutoGen.Net agent as model in AG Studio |
GitHub | autogen | autogen/dotnet/website/tutorial/Use-AutoGen.Net-agent-as-model-in-AG-Studio.md | autogen | Step 1. Create Dotnet empty web app and install AutoGen and AutoGen.WebAPI package ```bash dotnet new web dotnet add package AutoGen dotnet add package AutoGen.WebAPI ``` |
GitHub | autogen | autogen/dotnet/website/tutorial/Use-AutoGen.Net-agent-as-model-in-AG-Studio.md | autogen | Step 2. Replace the Program.cs with following code ```bash using AutoGen.Core; using AutoGen.Service; var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); var helloWorldAgent = new HelloWorldAgent(); app.UseAgentAsOpenAIChatCompletionEndpoint(helloWorldAgent); app.Run(); class HelloWorldAgent : IAgent { public string Name => "HelloWorld"; public Task<IMessage> GenerateReplyAsync(IEnumerable<IMessage> messages, GenerateReplyOptions? options = null, CancellationToken cancellationToken = default) { return Task.FromResult<IMessage>(new TextMessage(Role.Assistant, "Hello World!", from: this.Name)); } } ``` |
GitHub | autogen | autogen/dotnet/website/tutorial/Use-AutoGen.Net-agent-as-model-in-AG-Studio.md | autogen | Step 3: Start the web app Run the following command to start web api ```bash dotnet RUN ``` The web api will listen at `http://localhost:5264/v1/chat/completion ![terminal](../images/articles/UseAutoGenAsModelinAGStudio/Terminal.png) |
GitHub | autogen | autogen/dotnet/website/tutorial/Use-AutoGen.Net-agent-as-model-in-AG-Studio.md | autogen | Step 4: In another terminal, start autogen-studio ```bash autogenstudio ui ``` |
GitHub | autogen | autogen/dotnet/website/tutorial/Use-AutoGen.Net-agent-as-model-in-AG-Studio.md | autogen | Step 5: Navigate to AutoGen Studio UI and add hello world agent as openai Model ### Step 5.1: Go to model tab ![The Model Tab](../images/articles/UseAutoGenAsModelinAGStudio/TheModelTab.png) ### Step 5.2: Select "OpenAI model" card ![Open AI model Card](../images/articles/UseAutoGenAsModelinAGStudio/Step5.2OpenAIModel.png) ### Step 5.3: Fill the model name and url The model name needs to be same with agent name ![Fill the model name and url](../images/articles/UseAutoGenAsModelinAGStudio/Step5.3ModelNameAndURL.png) |
GitHub | autogen | autogen/dotnet/website/tutorial/Use-AutoGen.Net-agent-as-model-in-AG-Studio.md | autogen | Step 6: Create a hello world agent that uses the hello world model ![Create a hello world agent that uses the hello world model](../images/articles/UseAutoGenAsModelinAGStudio/Step6.png) ![Agent Configuration](../images/articles/UseAutoGenAsModelinAGStudio/Step6b.png) |
GitHub | autogen | autogen/dotnet/website/tutorial/Use-AutoGen.Net-agent-as-model-in-AG-Studio.md | autogen | Final Step: Use the hello world agent in workflow ![Use the hello world agent in workflow](../images/articles/UseAutoGenAsModelinAGStudio/FinalStepsA.png) ![Use the hello world agent in workflow](../images/articles/UseAutoGenAsModelinAGStudio/FinalStepsA.png) ![Use the hello world agent in workflow](../images/articles/UseAutoGenAsModelinAGStudio/FinalStepsB.png) ![Use the hello world agent in workflow](../images/articles/UseAutoGenAsModelinAGStudio/FinalStepsC.png) |
GitHub | autogen | autogen/dotnet/website/tutorial/Image-chat-with-agent.md | autogen | This tutorial shows how to perform image chat with an agent using the @AutoGen.OpenAI.OpenAIChatAgent as an example. > [!NOTE] > To chat image with an agent, the model behind the agent needs to support image input. Here is a partial list of models that support image input: > - gpt-4o > - gemini-1.5 > - llava > - claude-3 > - ... > > In this example, we are using the gpt-4o model as the backend model for the agent. > [!NOTE] > The complete code example can be found in [Image_Chat_With_Agent.cs](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.BasicSamples/GettingStart/Image_Chat_With_Agent.cs) |
GitHub | autogen | autogen/dotnet/website/tutorial/Image-chat-with-agent.md | autogen | Step 1: Install AutoGen First, install the AutoGen package using the following command: ```bash dotnet add package AutoGen ``` |
GitHub | autogen | autogen/dotnet/website/tutorial/Image-chat-with-agent.md | autogen | Step 2: Add Using Statements [!code-csharp[Using Statements](../../sample/AutoGen.BasicSamples/GettingStart/Image_Chat_With_Agent.cs?name=Using)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Image-chat-with-agent.md | autogen | Step 3: Create an @AutoGen.OpenAI.OpenAIChatAgent [!code-csharp[Create an OpenAIChatAgent](../../sample/AutoGen.BasicSamples/GettingStart/Image_Chat_With_Agent.cs?name=Create_Agent)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Image-chat-with-agent.md | autogen | Step 4: Prepare Image Message In AutoGen, you can create an image message using either @AutoGen.Core.ImageMessage or @AutoGen.Core.MultiModalMessage. The @AutoGen.Core.ImageMessage takes a single image as input, whereas the @AutoGen.Core.MultiModalMessage allows you to pass multiple modalities like text or image. Here is how to create an image message using @AutoGen.Core.ImageMessage: [!code-csharp[Create Image Message](../../sample/AutoGen.BasicSamples/GettingStart/Image_Chat_With_Agent.cs?name=Prepare_Image_Input)] Here is how to create a multimodal message using @AutoGen.Core.MultiModalMessage: [!code-csharp[Create MultiModal Message](../../sample/AutoGen.BasicSamples/GettingStart/Image_Chat_With_Agent.cs?name=Prepare_Multimodal_Input)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Image-chat-with-agent.md | autogen | Step 5: Generate Response To generate response, you can use one of the overloaded methods of @AutoGen.Core.AgentExtension.SendAsync* method. The following code shows how to generate response with an image message: [!code-csharp[Generate Response](../../sample/AutoGen.BasicSamples/GettingStart/Image_Chat_With_Agent.cs?name=Chat_With_Agent)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Image-chat-with-agent.md | autogen | Further Reading - [Image chat with gemini](../articles/AutoGen.Gemini/Image-chat-with-gemini.md) - [Image chat with llava](../articles/AutoGen.Ollama/Chat-with-llava.md) |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | This tutorial shows how to use tools in an agent. |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | What is tool Tools are pre-defined functions in user's project that agent can invoke. Agent can use tools to perform actions like search web, perform calculations, etc. With tools, it can greatly extend the capabilities of an agent. > [!NOTE] > To use tools with agent, the backend LLM model used by the agent needs to support tool calling. Here are some of the LLM models that support tool calling as of 06/21/2024 > - GPT-3.5-turbo with version >= 0613 > - GPT-4 series > - Gemini series > - OPEN_MISTRAL_7B > - ... > > This tutorial uses the latest `GPT-3.5-turbo` as example. > [!NOTE] > The complete code example can be found in [Use_Tools_With_Agent.cs](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.BasicSamples/GettingStart/Use_Tools_With_Agent.cs) |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | Key Concepts - @AutoGen.Core.FunctionContract: The contract of a function that agent can invoke. It contains the function name, description, parameters schema, and return type. - @AutoGen.Core.ToolCallMessage: A message type that represents a tool call request in AutoGen.Net. - @AutoGen.Core.ToolCallResultMessage: A message type that represents a tool call result in AutoGen.Net. - @AutoGen.Core.ToolCallAggregateMessage: An aggregate message type that represents a tool call request and its result in a single message in AutoGen.Net. - @AutoGen.Core.FunctionCallMiddleware: A middleware that pass the @AutoGen.Core.FunctionContract to the agent when generating response, and process the tool call response when receiving a @AutoGen.Core.ToolCallMessage. > [!Tip] > You can Use AutoGen.SourceGenerator to automatically generate type-safe @AutoGen.Core.FunctionContract instead of manually defining them. For more information, please check out [Create type-safe function](../articles/Create-type-safe-function-call.md). |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | Install AutoGen and AutoGen.SourceGenerator First, install the AutoGen and AutoGen.SourceGenerator package using the following command: ```bash dotnet add package AutoGen dotnet add package AutoGen.SourceGenerator ``` Also, you might need to enable structural xml document support by setting `GenerateDocumentationFile` property to true in your project file. This allows source generator to leverage the documentation of the function when generating the function definition. ```xml <PropertyGroup> <!-- This enables structural xml document support --> <GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup> ``` |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | Add Using Statements [!code-csharp[Using Statements](../../sample/AutoGen.BasicSamples/GettingStart/Use_Tools_With_Agent.cs?name=Using)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | Create agent Create an @AutoGen.OpenAI.OpenAIChatAgent with `GPT-3.5-turbo` as the backend LLM model. [!code-csharp[Create an agent with tools](../../sample/AutoGen.BasicSamples/GettingStart/Use_Tools_With_Agent.cs?name=Create_Agent)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | Define `Tool` class and create tools Create a `public partial` class to host the tools you want to use in AutoGen agents. The method has to be a `public` instance method and its return type must be `Task<string>`. After the methods is defined, mark them with @AutoGen.Core.FunctionAttribute attribute. In the following example, we define a `GetWeather` tool that returns the weather information of a city. [!code-csharp[Define Tool class](../../sample/AutoGen.BasicSamples/GettingStart/Use_Tools_With_Agent.cs?name=Tools)] [!code-csharp[Create tools](../../sample/AutoGen.BasicSamples/GettingStart/Use_Tools_With_Agent.cs?name=Create_tools)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | Tool call without auto-invoke In this case, when receiving a @AutoGen.Core.ToolCallMessage, the agent will not automatically invoke the tool. Instead, the agent will return the original message back to the user. The user can then decide whether to invoke the tool or not. ![single-turn tool call without auto-invoke](../images/articles/CreateAgentWithTools/single-turn-tool-call-without-auto-invoke.png) To implement this, you can create the @AutoGen.Core.FunctionCallMiddleware without passing the `functionMap` parameter to the constructor so that the middleware will not automatically invoke the tool once it receives a @AutoGen.Core.ToolCallMessage from its inner agent. [!code-csharp[Single-turn tool call without auto-invoke](../../sample/AutoGen.BasicSamples/GettingStart/Use_Tools_With_Agent.cs?name=Create_no_invoke_middleware)] After creating the function call middleware, you can register it to the agent using `RegisterMiddleware` method, which will return a new agent which can use the methods defined in the `Tool` class. [!code-csharp[Generate Response](../../sample/AutoGen.BasicSamples/GettingStart/Use_Tools_With_Agent.cs?name=Single_Turn_No_Invoke)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | Tool call with auto-invoke In this case, the agent will automatically invoke the tool when receiving a @AutoGen.Core.ToolCallMessage and return the @AutoGen.Core.ToolCallAggregateMessage which contains both the tool call request and the tool call result. ![single-turn tool call with auto-invoke](../images/articles/CreateAgentWithTools/single-turn-tool-call-with-auto-invoke.png) To implement this, you can create the @AutoGen.Core.FunctionCallMiddleware with the `functionMap` parameter so that the middleware will automatically invoke the tool once it receives a @AutoGen.Core.ToolCallMessage from its inner agent. [!code-csharp[Single-turn tool call with auto-invoke](../../sample/AutoGen.BasicSamples/GettingStart/Use_Tools_With_Agent.cs?name=Create_auto_invoke_middleware)] After creating the function call middleware, you can register it to the agent using `RegisterMiddleware` method, which will return a new agent which can use the methods defined in the `Tool` class. [!code-csharp[Generate Response](../../sample/AutoGen.BasicSamples/GettingStart/Use_Tools_With_Agent.cs?name=Single_Turn_Auto_Invoke)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | Send the tool call result back to LLM to generate further response In some cases, you may want to send the tool call result back to the LLM to generate further response. To do this, you can send the tool call response from agent back to the LLM by calling the `SendAsync` method of the agent. [!code-csharp[Generate Response](../../sample/AutoGen.BasicSamples/GettingStart/Use_Tools_With_Agent.cs?name=Multi_Turn_Tool_Call)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | Parallel tool call Some LLM models support parallel tool call, which returns multiple tool calls in one single message. Note that @AutoGen.Core.FunctionCallMiddleware has already handled the parallel tool call for you. When it receives a @AutoGen.Core.ToolCallMessage that contains multiple tool calls, it will automatically invoke all the tools in the sequantial order and return the @AutoGen.Core.ToolCallAggregateMessage which contains all the tool call requests and results. [!code-csharp[Generate Response](../../sample/AutoGen.BasicSamples/GettingStart/Use_Tools_With_Agent.cs?name=parallel_tool_call)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Create-agent-with-tools.md | autogen | Further Reading - [Function call with openai](../articles/OpenAIChatAgent-use-function-call.md) - [Function call with gemini](../articles/AutoGen.Gemini/Function-call-with-gemini.md) - [Function call with local model](../articles/Function-call-with-ollama-and-litellm.md) - [Use kernel plugin in other agents](../articles/AutoGen.SemanticKernel/Use-kernel-plugin-in-other-agents.md) - [function call in mistral](../articles/MistralChatAgent-use-function-call.md) |
GitHub | autogen | autogen/dotnet/website/tutorial/Chat-with-an-agent.md | autogen | This tutorial shows how to generate response using an @AutoGen.Core.IAgent by taking @AutoGen.OpenAI.OpenAIChatAgent as an example. > [!NOTE] > AutoGen.Net provides the following agents to connect to different LLM platforms. Generating responses using these agents is similar to the example shown below. > - @AutoGen.OpenAI.OpenAIChatAgent > - @AutoGen.SemanticKernel.SemanticKernelAgent > - @AutoGen.LMStudio.LMStudioAgent > - @AutoGen.Mistral.MistralClientAgent > - @AutoGen.Anthropic.AnthropicClientAgent > - @AutoGen.Ollama.OllamaAgent > - @AutoGen.Gemini.GeminiChatAgent > [!NOTE] > The complete code example can be found in [Chat_With_Agent.cs](https://github.com/microsoft/autogen/blob/main/dotnet/sample/AutoGen.BasicSamples/GettingStart/Chat_With_Agent.cs) |
GitHub | autogen | autogen/dotnet/website/tutorial/Chat-with-an-agent.md | autogen | Step 1: Install AutoGen First, install the AutoGen package using the following command: ```bash dotnet add package AutoGen ``` |
GitHub | autogen | autogen/dotnet/website/tutorial/Chat-with-an-agent.md | autogen | Step 2: add Using Statements [!code-csharp[Using Statements](../../sample/AutoGen.BasicSamples/GettingStart/Chat_With_Agent.cs?name=Using)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Chat-with-an-agent.md | autogen | Step 3: Create an @AutoGen.OpenAI.OpenAIChatAgent > [!NOTE] > The @AutoGen.OpenAI.Extension.OpenAIAgentExtension.RegisterMessageConnector* method registers an @AutoGen.OpenAI.OpenAIChatRequestMessageConnector middleware which converts OpenAI message types to AutoGen message types. This step is necessary when you want to use AutoGen built-in message types like @AutoGen.Core.TextMessage, @AutoGen.Core.ImageMessage, etc. > For more information, see [Built-in-messages](../articles/Built-in-messages.md) [!code-csharp[Create an OpenAIChatAgent](../../sample/AutoGen.BasicSamples/GettingStart/Chat_With_Agent.cs?name=Create_Agent)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Chat-with-an-agent.md | autogen | Step 4: Generate Response To generate response, you can use one of the overloaded method of @AutoGen.Core.AgentExtension.SendAsync* method. The following code shows how to generate response with text message: [!code-csharp[Generate Response](../../sample/AutoGen.BasicSamples/GettingStart/Chat_With_Agent.cs?name=Chat_With_Agent)] To generate response with chat history, you can pass the chat history to the @AutoGen.Core.AgentExtension.SendAsync* method: [!code-csharp[Generate Response with Chat History](../../sample/AutoGen.BasicSamples/GettingStart/Chat_With_Agent.cs?name=Chat_With_History)] To streamingly generate response, use @AutoGen.Core.IStreamingAgent.GenerateStreamingReplyAsync* [!code-csharp[Generate Streaming Response](../../sample/AutoGen.BasicSamples/GettingStart/Chat_With_Agent.cs?name=Streaming_Chat)] |
GitHub | autogen | autogen/dotnet/website/tutorial/Chat-with-an-agent.md | autogen | Further Reading - [Chat with google gemini](../articles/AutoGen.Gemini/Chat-with-google-gemini.md) - [Chat with vertex gemini](../articles/AutoGen.Gemini/Chat-with-vertex-gemini.md) - [Chat with Ollama](../articles/AutoGen.Ollama/Chat-with-llama.md) - [Chat with Semantic Kernel Agent](../articles/AutoGen.SemanticKernel/SemanticKernelAgent-simple-chat.md) |
GitHub | autogen | autogen/dotnet/website/release_note/0.0.17.md | autogen | # AutoGen.Net 0.0.17 Release Notes |
GitHub | autogen | autogen/dotnet/website/release_note/0.0.17.md | autogen | ๐ What's New 1. **.NET Core Target Framework Support** ([#3203](https://github.com/microsoft/autogen/issues/3203)) - ๐ Added support for .NET Core to ensure compatibility and enhanced performance of AutoGen packages across different platforms. 2. **Kernel Support in Interactive Service Constructor** ([#3181](https://github.com/microsoft/autogen/issues/3181)) - ๐ง Enhanced the Interactive Service to accept a kernel in its constructor, facilitating usage in notebook environments. 3. **Constructor Options for OpenAIChatAgent** ([#3126](https://github.com/microsoft/autogen/issues/3126)) - โ๏ธ Added new constructor options for `OpenAIChatAgent` to allow full control over chat completion flags/options. 4. **Step-by-Step Execution for Group Chat** ([#3075](https://github.com/microsoft/autogen/issues/3075)) - ๐ ๏ธ Introduced an `IAsyncEnumerable` extension API to run group chat step-by-step, enabling developers to observe internal processes or implement early stopping mechanisms. |
GitHub | autogen | autogen/dotnet/website/release_note/0.0.17.md | autogen | ๐ Improvements 1. **Cancellation Token Addition in Graph APIs** ([#3111](https://github.com/microsoft/autogen/issues/3111)) - ๐ Added cancellation tokens to async APIs in the `AutoGen.Core.Graph` class to follow best practices and enhance the control flow. |
GitHub | autogen | autogen/dotnet/website/release_note/0.0.17.md | autogen | โ ๏ธ API Breaking Changes 1. **FunctionDefinition Generation Stopped in Source Generator** ([#3133](https://github.com/microsoft/autogen/issues/3133)) - ๐ Stopped generating `FunctionDefinition` from `Azure.AI.OpenAI` in the source generator to eliminate unnecessary package dependencies. Migration guide: - โก๏ธ Use `ToOpenAIFunctionDefinition()` extension from `AutoGen.OpenAI` for generating `FunctionDefinition` from `AutoGen.Core.FunctionContract`. - โก๏ธ Use `FunctionContract` for metadata such as function name or parameters. 2. **Namespace Renaming for AutoGen.WebAPI** ([#3152](https://github.com/microsoft/autogen/issues/3152)) - โ๏ธ Renamed the namespace of `AutoGen.WebAPI` from `AutoGen.Service` to `AutoGen.WebAPI` to maintain consistency with the project name. 3. **Semantic Kernel Version Update** ([#3118](https://github.com/microsoft/autogen/issues/3118)) - ๐ Upgraded the Semantic Kernel version to 1.15.1 for enhanced functionality and performance improvements. This might introduce break change for those who use a lower-version semantic kernel. |
GitHub | autogen | autogen/dotnet/website/release_note/0.0.17.md | autogen | ๐ Documentation 1. **Consume AutoGen.Net Agent in AG Studio** ([#3142](https://github.com/microsoft/autogen/issues/3142)) - Added detailed documentation on using AutoGen.Net Agent as a model in AG Studio, including examples of starting an OpenAI chat backend and integrating third-party OpenAI models. 2. **Middleware Overview Documentation Errors Fixed** ([#3129](https://github.com/microsoft/autogen/issues/3129)) - Corrected logic and compile errors in the example code provided in the Middleware Overview documentation to ensure it runs without issues. --- We hope you enjoy the new features and improvements in AutoGen.Net 0.0.17! If you encounter any issues or have feedback, please open a new issue on our [GitHub repository](https://github.com/microsoft/autogen/issues). |
GitHub | autogen | autogen/dotnet/website/release_note/update.md | autogen | ##### Update on 0.0.15 (2024-06-13) Milestone: [AutoGen.Net 0.0.15](https://github.com/microsoft/autogen/milestone/3) ###### Highlights - [Issue 2851](https://github.com/microsoft/autogen/issues/2851) `AutoGen.Gemini` package for Gemini support. Examples can be found [here](https://github.com/microsoft/autogen/tree/main/dotnet/sample/AutoGen.Gemini.Sample) ##### Update on 0.0.14 (2024-05-28) ###### New features - [Issue 2319](https://github.com/microsoft/autogen/issues/2319) Add `AutoGen.Ollama` package for Ollama support. Special thanks to @iddelacruz for the effort. - [Issue 2608](https://github.com/microsoft/autogen/issues/2608) Add `AutoGen.Anthropic` package for Anthropic support. Special thanks to @DavidLuong98 for the effort. - [Issue 2647](https://github.com/microsoft/autogen/issues/2647) Add `ToolCallAggregateMessage` for function call middleware. ###### API Breaking Changes - [Issue 2648](https://github.com/microsoft/autogen/issues/2648) Deprecate `Message` type. - [Issue 2649](https://github.com/microsoft/autogen/issues/2649) Deprecate `Workflow` type. ###### Bug Fixes - [Issue 2735](https://github.com/microsoft/autogen/issues/2735) Fix tool call issue in AutoGen.Mistral package. - [Issue 2722](https://github.com/microsoft/autogen/issues/2722) Fix parallel funciton call in function call middleware. - [Issue 2633](https://github.com/microsoft/autogen/issues/2633) Set up `name` field in `OpenAIChatMessageConnector` - [Issue 2660](https://github.com/microsoft/autogen/issues/2660) Fix dotnet interactive restoring issue when system language is Chinese - [Issue 2687](https://github.com/microsoft/autogen/issues/2687) Add `global::` prefix to generated code to avoid conflict with user-defined types. ##### Update on 0.0.13 (2024-05-09) ###### New features - [Issue 2593](https://github.com/microsoft/autogen/issues/2593) Consume SK plugins in Agent. - [Issue 1893](https://github.com/microsoft/autogen/issues/1893) Support inline-data in ImageMessage - [Issue 2481](https://github.com/microsoft/autogen/issues/2481) Introduce `ChatCompletionAgent` to `AutoGen.SemanticKernel` ###### API Breaking Changes - [Issue 2470](https://github.com/microsoft/autogen/issues/2470) Update the return type of `IStreamingAgent.GenerateStreamingReplyAsync` from `Task<IAsyncEnumerable<IStreamingMessage>>` to `IAsyncEnumerable<IStreamingMessage>` - [Issue 2470](https://github.com/microsoft/autogen/issues/2470) Update the return type of `IStreamingMiddleware.InvokeAsync` from `Task<IAsyncEnumerable<IStreamingMessage>>` to `IAsyncEnumerable<IStreamingMessage>` - Mark `RegisterReply`, `RegisterPreProcess` and `RegisterPostProcess` as obsolete. You can replace them with `RegisterMiddleware` ###### Bug Fixes - Fix [Issue 2609](https://github.com/microsoft/autogen/issues/2609) Constructor of conversableAgentConfig does not accept LMStudioConfig as ConfigList ##### Update on 0.0.12 (2024-04-22) - Add AutoGen.Mistral package to support Mistral.AI models ##### Update on 0.0.11 (2024-04-10) - Add link to Discord channel in nuget's readme.md - Document improvements - In `AutoGen.OpenAI`, update `Azure.AI.OpenAI` to 1.0.0-beta.15 and add support for json mode and deterministic output in `OpenAIChatAgent` [Issue #2346](https://github.com/microsoft/autogen/issues/2346) - In `AutoGen.SemanticKernel`, update `SemanticKernel` package to 1.7.1 - [API Breaking Change] Rename `PrintMessageMiddlewareExtension.RegisterPrintFormatMessageHook' to `PrintMessageMiddlewareExtension.RegisterPrintMessage`. ##### Update on 0.0.10 (2024-03-12) - Rename `Workflow` to `Graph` - Rename `AddInitializeMessage` to `SendIntroduction` - Rename `SequentialGroupChat` to `RoundRobinGroupChat` ##### Update on 0.0.9 (2024-03-02) - Refactor over @AutoGen.Message and introducing `TextMessage`, `ImageMessage`, `MultiModalMessage` and so on. PR [#1676](https://github.com/microsoft/autogen/pull/1676) - Add `AutoGen.SemanticKernel` to support seamless integration with Semantic Kernel - Move the agent contract abstraction to `AutoGen.Core` package. The `AutoGen.Core` package provides the abstraction for message type, agent and group chat and doesn't contain dependencies over `Azure.AI.OpenAI` or `Semantic Kernel`. This is useful when you want to leverage AutoGen's abstraction only and want to avoid introducing any other dependencies. - Move `GPTAgent`, `OpenAIChatAgent` and all openai-dependencies to `AutoGen.OpenAI` ##### Update on 0.0.8 (2024-02-28) - Fix [#1804](https://github.com/microsoft/autogen/pull/1804) - Streaming support for IAgent [#1656](https://github.com/microsoft/autogen/pull/1656) - Streaming support for middleware via `MiddlewareStreamingAgent` [#1656](https://github.com/microsoft/autogen/pull/1656) - Graph chat support with conditional transition workflow [#1761](https://github.com/microsoft/autogen/pull/1761) - AutoGen.SourceGenerator: Generate `FunctionContract` from `FunctionAttribute` [#1736](https://github.com/microsoft/autogen/pull/1736) ##### Update on 0.0.7 (2024-02-11) - Add `AutoGen.LMStudio` to support comsume openai-like API from LMStudio local server ##### Update on 0.0.6 (2024-01-23) - Add `MiddlewareAgent` - Use `MiddlewareAgent` to implement existing agent hooks (RegisterPreProcess, RegisterPostProcess, RegisterReply) - Remove `AutoReplyAgent`, `PreProcessAgent`, `PostProcessAgent` because they are replaced by `MiddlewareAgent` ##### Update on 0.0.5 - Simplify `IAgent` interface by removing `ChatLLM` Property - Add `GenerateReplyOptions` to `IAgent.GenerateReplyAsync` which allows user to specify or override the options when generating reply ##### Update on 0.0.4 - Move out dependency of Semantic Kernel - Add type `IChatLLM` as connector to LLM ##### Update on 0.0.3 - In AutoGen.SourceGenerator, rename FunctionAttribution to FunctionAttribute - In AutoGen, refactor over ConversationAgent, UserProxyAgent, and AssistantAgent ##### Update on 0.0.2 - update Azure.OpenAI.AI to 1.0.0-beta.12 - update Semantic kernel to 1.0.1 |
GitHub | autogen | autogen/dotnet/website/release_note/0.0.16.md | autogen | # AutoGen.Net 0.0.16 Release Notes We are excited to announce the release of **AutoGen.Net 0.0.16**. This release includes several new features, bug fixes, improvements, and important updates. Below are the detailed release notes: **[Milestone: AutoGen.Net 0.0.16](https://github.com/microsoft/autogen/milestone/4)** |
GitHub | autogen | autogen/dotnet/website/release_note/0.0.16.md | autogen | ๐ฆ New Features 1. **Deprecate `IStreamingMessage`** ([#3045](https://github.com/microsoft/autogen/issues/3045)) - Replaced `IStreamingMessage` and `IStreamingMessage<T>` with `IMessage` and `IMessage<T>`. 2. **Add example for using ollama + LiteLLM for function call** ([#3014](https://github.com/microsoft/autogen/issues/3014)) - Added a new tutorial to the website for integrating ollama with LiteLLM for function calls. 3. **Add ReAct sample** ([#2978](https://github.com/microsoft/autogen/issues/2978)) - Added a new sample demonstrating the ReAct pattern. 4. **Support tools Anthropic Models** ([#2771](https://github.com/microsoft/autogen/issues/2771)) - Introduced support for tools like `AnthropicClient`, `AnthropicClientAgent`, and `AnthropicMessageConnector`. 5. **Propose Orchestrator for managing group chat/agentic workflow** ([#2695](https://github.com/microsoft/autogen/issues/2695)) - Introduced a customizable orchestrator interface for managing group chats and agent workflows. 6. **Run Agent as Web API** ([#2519](https://github.com/microsoft/autogen/issues/2519)) - Introduced the ability to start an OpenAI-chat-compatible web API from an arbitrary agent. |
GitHub | autogen | autogen/dotnet/website/release_note/0.0.16.md | autogen | ๐ Bug Fixes 1. **SourceGenerator doesn't work when function's arguments are empty** ([#2976](https://github.com/microsoft/autogen/issues/2976)) - Fixed an issue where the SourceGenerator failed when function arguments were empty. 2. **Add content field in ToolCallMessage** ([#2975](https://github.com/microsoft/autogen/issues/2975)) - Added a content property in `ToolCallMessage` to handle text content returned by the OpenAI model during tool calls. 3. **AutoGen.SourceGenerator doesnโt encode `"` in structural comments** ([#2872](https://github.com/microsoft/autogen/issues/2872)) - Fixed an issue where structural comments containing `"` were not properly encoded, leading to compilation errors. |
GitHub | autogen | autogen/dotnet/website/release_note/0.0.16.md | autogen | ๐ Improvements 1. **Sample update - Add getting-start samples for BasicSample project** ([#2859](https://github.com/microsoft/autogen/issues/2859)) - Re-organized the `AutoGen.BasicSample` project to include only essential getting-started examples, simplifying complex examples. 2. **Graph constructor should consider null transitions** ([#2708](https://github.com/microsoft/autogen/issues/2708)) - Updated the Graph constructor to handle cases where transitionsโ values are null. |
GitHub | autogen | autogen/dotnet/website/release_note/0.0.16.md | autogen | โ ๏ธ API-Breakchange 1. **Deprecate `IStreamingMessage`** ([#3045](https://github.com/microsoft/autogen/issues/3045)) - **Migration guide:** Deprecating `IStreamingMessage` will introduce breaking changes, particularly for `IStreamingAgent` and `IStreamingMiddleware`. Replace all `IStreamingMessage` and `IStreamingMessage<T>` with `IMessage` and `IMessage<T>`. |
GitHub | autogen | autogen/dotnet/website/release_note/0.0.16.md | autogen | ๐ Document Update 1. **Add example for using ollama + LiteLLM for function call** ([#3014](https://github.com/microsoft/autogen/issues/3014)) - Added a tutorial to the website for using ollama with LiteLLM. Thank you to all the contributors for making this release possible. We encourage everyone to upgrade to AutoGen.Net 0.0.16 to take advantage of these new features and improvements. If you encounter any issues or have any feedback, please let us know. Happy coding! ๐ |
GitHub | autogen | autogen/dotnet/src/AutoGen.SourceGenerator/README.md | autogen | ### AutoGen.SourceGenerator This package carries a source generator that adds support for type-safe function definition generation. Simply mark a method with `Function` attribute, and the source generator will generate a function definition and a function call wrapper for you. ### Get start First, add the following to your project file and set `GenerateDocumentationFile` property to true ```xml <PropertyGroup> <!-- This enables structural xml document support --> <GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup> ``` ```xml <ItemGroup> <PackageReference Include="AutoGen.SourceGenerator" /> </ItemGroup> ``` > Nightly Build feed: https://devdiv.pkgs.visualstudio.com/DevDiv/_packaging/AutoGen/nuget/v3/index.json Then, for the methods you want to generate function definition and function call wrapper, mark them with `Function` attribute: > Note: For the best of performance, try using primitive types for the parameters and return type. ```csharp // file: MyFunctions.cs using AutoGen; // a partial class is required // and the class must be public public partial class MyFunctions { /// <summary> /// Add two numbers. /// </summary> /// <param name="a">The first number.</param> /// <param name="b">The second number.</param> [Function] public Task<string> AddAsync(int a, int b) { return Task.FromResult($"{a} + {b} = {a + b}"); } } ``` The source generator will generate the following code based on the method signature and documentation. It helps you save the effort of writing function definition and keep it up to date with the actual method signature. ```csharp // file: MyFunctions.generated.cs public partial class MyFunctions { private class AddAsyncSchema { public int a {get; set;} public int b {get; set;} } public Task<string> AddAsyncWrapper(string arguments) { var schema = JsonSerializer.Deserialize<AddAsyncSchema>( arguments, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, }); return AddAsync(schema.a, schema.b); } public FunctionDefinition AddAsyncFunction { get => new FunctionDefinition { Name = @"AddAsync", Description = """ Add two numbers. """, Parameters = BinaryData.FromObjectAsJson(new { Type = "object", Properties = new { a = new { Type = @"number", Description = @"The first number.", }, b = new { Type = @"number", Description = @"The second number.", }, }, Required = new [] { "a", "b", }, }, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, }) }; } } ``` For more examples, please check out the following project - [AutoGen.BasicSamples](../sample/AutoGen.BasicSamples/) - [AutoGen.SourceGenerator.Tests](../../test/AutoGen.SourceGenerator.Tests/) |
GitHub | autogen | autogen/dotnet/src/AutoGen.LMStudio/README.md | autogen | ## AutoGen.LMStudio This package provides support for consuming openai-like API from LMStudio local server. |
GitHub | autogen | autogen/dotnet/src/AutoGen.LMStudio/README.md | autogen | Installation To use `AutoGen.LMStudio`, add the following package to your `.csproj` file: ```xml <ItemGroup> <PackageReference Include="AutoGen.LMStudio" Version="AUTOGEN_VERSION" /> </ItemGroup> ``` |
GitHub | autogen | autogen/dotnet/src/AutoGen.LMStudio/README.md | autogen | Usage ```csharp using AutoGen.LMStudio; var localServerEndpoint = "localhost"; var port = 5000; var lmStudioConfig = new LMStudioConfig(localServerEndpoint, port); var agent = new LMStudioAgent( name: "agent", systemMessage: "You are an agent that help user to do some tasks.", lmStudioConfig: lmStudioConfig) .RegisterPrintMessage(); // register a hook to print message nicely to console await agent.SendAsync("Can you write a piece of C# code to calculate 100th of fibonacci?"); ``` |
GitHub | autogen | autogen/dotnet/src/AutoGen.LMStudio/README.md | autogen | Update history ### Update on 0.0.7 (2024-02-11) - Add `LMStudioAgent` to support consuming openai-like API from LMStudio local server. |
GitHub | autogen | autogen/.devcontainer/README.md | autogen | # Dockerfiles and Devcontainer Configurations for AutoGen Welcome to the `.devcontainer` directory! Here you'll find Dockerfiles and devcontainer configurations that are essential for setting up your AutoGen development environment. Each Dockerfile is tailored for different use cases and requirements. Below is a brief overview of each and how you can utilize them effectively. These configurations can be used with Codespaces and locally. |
GitHub | autogen | autogen/.devcontainer/README.md | autogen | Dockerfile Descriptions ### base - **Purpose**: This Dockerfile, i.e., `./Dockerfile`, is designed for basic setups. It includes common Python libraries and essential dependencies required for general usage of AutoGen. - **Usage**: Ideal for those just starting with AutoGen or for general-purpose applications. - **Building the Image**: Run `docker build -f ./Dockerfile -t autogen_base_img .` in this directory. - **Using with Codespaces**: `Code > Codespaces > Click on +` By default + creates a Codespace on the current branch. ### full - **Purpose**: This Dockerfile, i.e., `./full/Dockerfile` is for advanced features. It includes additional dependencies and is configured for more complex or feature-rich AutoGen applications. - **Usage**: Suited for advanced users who need the full range of AutoGen's capabilities. - **Building the Image**: Execute `docker build -f full/Dockerfile -t autogen_full_img .`. - **Using with Codespaces**: `Code > Codespaces > Click on ...> New with options > Choose "full" as devcontainer configuration`. This image may require a Codespace with at least 64GB of disk space. ### dev - **Purpose**: Tailored for AutoGen project developers, this Dockerfile, i.e., `./dev/Dockerfile` includes tools and configurations aiding in development and contribution. - **Usage**: Recommended for developers who are contributing to the AutoGen project. - **Building the Image**: Run `docker build -f dev/Dockerfile -t autogen_dev_img .`. - **Using with Codespaces**: `Code > Codespaces > Click on ...> New with options > Choose "dev" as devcontainer configuration`. This image may require a Codespace with at least 64GB of disk space. - **Before using**: We highly encourage all potential contributors to read the [AutoGen Contributing](https://microsoft.github.io/autogen/docs/Contribute) page prior to submitting any pull requests. ### studio - **Purpose**: Tailored for AutoGen project developers, this Dockerfile, i.e., `./studio/Dockerfile`, includes tools and configurations aiding in development and contribution. - **Usage**: Recommended for developers who are contributing to the AutoGen project. - **Building the Image**: Run `docker build -f studio/Dockerfile -t autogen_studio_img .`. - **Using with Codespaces**: `Code > Codespaces > Click on ...> New with options > Choose "studio" as devcontainer configuration`. - **Before using**: We highly encourage all potential contributors to read the [AutoGen Contributing](https://microsoft.github.io/autogen/docs/Contribute) page prior to submitting any pull requests. |
GitHub | autogen | autogen/.devcontainer/README.md | autogen | Customizing Dockerfiles Feel free to modify these Dockerfiles for your specific project needs. Here are some common customizations: - **Adding New Dependencies**: If your project requires additional Python packages, you can add them using the `RUN pip install` command. - **Changing the Base Image**: You may change the base image (e.g., from a Python image to an Ubuntu image) to suit your project's requirements. - **Changing the Python version**: do you need a different version of python other than 3.11. Just update the first line of each of the Dockerfiles like so: `FROM python:3.11-slim-bookworm` to `FROM python:3.10-slim-bookworm` - **Setting Environment Variables**: Add environment variables using the `ENV` command for any application-specific configurations. We have prestaged the line needed to inject your OpenAI_key into the docker environment as a environmental variable. Others can be staged in the same way. Just uncomment the line. `# ENV OPENAI_API_KEY="{OpenAI-API-Key}"` to `ENV OPENAI_API_KEY="{OpenAI-API-Key}"` - **Need a less "Advanced" Autogen build**: If the `./full/Dockerfile` is to much but you need more than advanced then update this line in the Dockerfile file. `RUN pip install pyautogen[teachable,lmm,retrievechat,mathchat,blendsearch] autogenra` to install just what you need. `RUN pip install pyautogen[retrievechat,blendsearch] autogenra` - **Can't Dev without your favorite CLI tool**: if you need particular OS tools to be installed in your Docker container you can add those packages here right after the sudo for the `./base/Dockerfile` and `./full/Dockerfile` files. In the example below we are installing net-tools and vim to the environment. ```code RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ software-properties-common sudo net-tools vim\ && apt-get clean \ && rm -rf /var/lib/apt/lists/* ``` ### Managing Your Docker Environment After customizing your Dockerfile, build the Docker image using the `docker build` command as shown above. To run a container based on your new image, use: ```bash docker run -it -v $(pwd)/your_app:/app your_image_name ``` Replace `your_app` with your application directory and `your_image_name` with the name of the image you built. #### Closing for the Day - **Exit the container**: Type `exit`. - **Stop the container**: Use `docker stop {application_project_name}`. #### Resuming Work - **Restart the container**: Use `docker start {application_project_name}`. - **Access the container**: Execute `sudo docker exec -it {application_project_name} bash`. - **Reactivate the environment**: Run `source /usr/src/app/autogen_env/bin/activate`. ### Useful Docker Commands - **View running containers**: `docker ps -a`. - **View Docker images**: `docker images`. - **Restart container setup**: Stop (`docker stop my_container`), remove the container (`docker rm my_container`), and remove the image (`docker rmi my_image:latest`). #### Troubleshooting Common Issues - Check Docker daemon, port conflicts, and permissions issues. #### Additional Resources For more information on Docker usage and best practices, refer to the [official Docker documentation](https://docs.docker.com). |