forked from microsoft/autogen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into groupchatresume
- Loading branch information
Showing
43 changed files
with
978 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dotnet/sample/AutoGen.BasicSamples/CodeSnippet/MiddlewareAgentCodeSnippet.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dotnet/sample/AutoGen.BasicSamples/Example02_TwoAgent_MathChat.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dotnet/sample/AutoGen.BasicSamples/Example15_GPT4V_BinaryDataImageMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
dotnet/sample/AutoGen.BasicSamples/Example16_OpenAIChatAgent_ConnectToThirdPartyBackend.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Example16_OpenAIChatAgent_ConnectToThirdPartyBackend.cs | ||
#region using_statement | ||
using AutoGen.Core; | ||
using AutoGen.OpenAI; | ||
using AutoGen.OpenAI.Extension; | ||
using Azure.AI.OpenAI; | ||
using Azure.Core.Pipeline; | ||
#endregion using_statement | ||
|
||
namespace AutoGen.BasicSample; | ||
|
||
#region CustomHttpClientHandler | ||
public sealed class CustomHttpClientHandler : HttpClientHandler | ||
{ | ||
private string _modelServiceUrl; | ||
|
||
public CustomHttpClientHandler(string modelServiceUrl) | ||
{ | ||
_modelServiceUrl = modelServiceUrl; | ||
} | ||
|
||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | ||
{ | ||
request.RequestUri = new Uri($"{_modelServiceUrl}{request.RequestUri.PathAndQuery}"); | ||
|
||
return base.SendAsync(request, cancellationToken); | ||
} | ||
} | ||
#endregion CustomHttpClientHandler | ||
|
||
public class Example16_OpenAIChatAgent_ConnectToThirdPartyBackend | ||
{ | ||
public static async Task RunAsync() | ||
{ | ||
#region create_agent | ||
using var client = new HttpClient(new CustomHttpClientHandler("http://localhost:11434")); | ||
var option = new OpenAIClientOptions(OpenAIClientOptions.ServiceVersion.V2024_04_01_Preview) | ||
{ | ||
Transport = new HttpClientTransport(client), | ||
}; | ||
|
||
// api-key is not required for local server | ||
// so you can use any string here | ||
var openAIClient = new OpenAIClient("api-key", option); | ||
var model = "llama3"; | ||
|
||
var agent = new OpenAIChatAgent( | ||
openAIClient: openAIClient, | ||
name: "assistant", | ||
modelName: model, | ||
systemMessage: "You are a helpful assistant designed to output JSON.", | ||
seed: 0) | ||
.RegisterMessageConnector() | ||
.RegisterPrintMessage(); | ||
#endregion create_agent | ||
|
||
#region send_message | ||
await agent.SendAsync("Can you write a piece of C# code to calculate 100th of fibonacci?"); | ||
#endregion send_message | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Program.cs | ||
|
||
await Example02_TwoAgent_MathChat.RunAsync(); | ||
using AutoGen.BasicSample; | ||
Console.ReadLine(); | ||
await Example16_OpenAIChatAgent_ConnectToThirdPartyBackend.RunAsync(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.