From 45e8728ce6398c8731f5a906e5547188348183c6 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Thu, 1 Aug 2024 14:27:07 -0700 Subject: [PATCH 1/3] remove Azure.AI.OpenAI dependencies --- .../AutoGen.Anthropic.Samples.csproj | 2 +- .../AutoGen.DotnetInteractive.csproj | 5 +- .../DotnetInteractiveFunction.cs | 105 +----------------- .../Template/FunctionCallTemplate.cs | 1 - .../Template/FunctionCallTemplate.tt | 1 - 5 files changed, 5 insertions(+), 109 deletions(-) diff --git a/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj b/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj index fe7553b937f..f5832ea2209 100644 --- a/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj +++ b/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj @@ -11,7 +11,7 @@ - + diff --git a/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj b/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj index 96b331f2df3..5778761f05d 100644 --- a/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj +++ b/dotnet/src/AutoGen.DotnetInteractive/AutoGen.DotnetInteractive.csproj @@ -27,12 +27,9 @@ - - - - + diff --git a/dotnet/src/AutoGen.DotnetInteractive/DotnetInteractiveFunction.cs b/dotnet/src/AutoGen.DotnetInteractive/DotnetInteractiveFunction.cs index bb5504cd548..c9b59203462 100644 --- a/dotnet/src/AutoGen.DotnetInteractive/DotnetInteractiveFunction.cs +++ b/dotnet/src/AutoGen.DotnetInteractive/DotnetInteractiveFunction.cs @@ -2,14 +2,12 @@ // DotnetInteractiveFunction.cs using System.Text; -using System.Text.Json; -using Azure.AI.OpenAI; using Microsoft.DotNet.Interactive.Documents; using Microsoft.DotNet.Interactive.Documents.Jupyter; namespace AutoGen.DotnetInteractive; -public class DotnetInteractiveFunction : IDisposable +public partial class DotnetInteractiveFunction : IDisposable { private readonly InteractiveService? _interactiveService = null; private string _notebookPath; @@ -71,6 +69,7 @@ public DotnetInteractiveFunction(InteractiveService interactiveService, string? /// Run existing dotnet code from message. Don't modify the code, run it as is. /// /// code. + [Function] public async Task RunCode(string code) { if (this._interactiveService == null) @@ -117,6 +116,7 @@ public async Task RunCode(string code) /// Install nuget packages. /// /// nuget package to install. + [Function] public async Task InstallNugetPackages(string[] nugetPackages) { if (this._interactiveService == null) @@ -173,105 +173,6 @@ private async Task AddCellAsync(string cellContent, string kernelName) writeStream.Dispose(); } - private class RunCodeSchema - { - public string code { get; set; } = string.Empty; - } - - public Task RunCodeWrapper(string arguments) - { - var schema = JsonSerializer.Deserialize( - arguments, - new JsonSerializerOptions - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - }); - - return RunCode(schema!.code); - } - - public FunctionDefinition RunCodeFunction - { - get => new FunctionDefinition - { - Name = @"RunCode", - Description = """ -Run existing dotnet code from message. Don't modify the code, run it as is. -""", - Parameters = BinaryData.FromObjectAsJson(new - { - Type = "object", - Properties = new - { - code = new - { - Type = @"string", - Description = @"code.", - }, - }, - Required = new[] - { - "code", - }, - }, - new JsonSerializerOptions - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - }) - }; - } - - private class InstallNugetPackagesSchema - { - public string[] nugetPackages { get; set; } = Array.Empty(); - } - - public Task InstallNugetPackagesWrapper(string arguments) - { - var schema = JsonSerializer.Deserialize( - arguments, - new JsonSerializerOptions - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - }); - - return InstallNugetPackages(schema!.nugetPackages); - } - - public FunctionDefinition InstallNugetPackagesFunction - { - get => new FunctionDefinition - { - Name = @"InstallNugetPackages", - Description = """ -Install nuget packages. -""", - Parameters = BinaryData.FromObjectAsJson(new - { - Type = "object", - Properties = new - { - nugetPackages = new - { - Type = @"array", - Items = new - { - Type = @"string", - }, - Description = @"nuget package to install.", - }, - }, - Required = new[] - { - "nugetPackages", - }, - }, - new JsonSerializerOptions - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - }) - }; - } public void Dispose() { this._interactiveService?.Dispose(); diff --git a/dotnet/src/AutoGen.SourceGenerator/Template/FunctionCallTemplate.cs b/dotnet/src/AutoGen.SourceGenerator/Template/FunctionCallTemplate.cs index 8eeb117141d..b90d78be3f1 100644 --- a/dotnet/src/AutoGen.SourceGenerator/Template/FunctionCallTemplate.cs +++ b/dotnet/src/AutoGen.SourceGenerator/Template/FunctionCallTemplate.cs @@ -36,7 +36,6 @@ public virtual string TransformText() using System.Threading.Tasks; using System; using AutoGen.Core; -using AutoGen.OpenAI.Extension; "); if (!String.IsNullOrEmpty(NameSpace)) { diff --git a/dotnet/src/AutoGen.SourceGenerator/Template/FunctionCallTemplate.tt b/dotnet/src/AutoGen.SourceGenerator/Template/FunctionCallTemplate.tt index dc41f0af9d7..e7ed476fde8 100644 --- a/dotnet/src/AutoGen.SourceGenerator/Template/FunctionCallTemplate.tt +++ b/dotnet/src/AutoGen.SourceGenerator/Template/FunctionCallTemplate.tt @@ -13,7 +13,6 @@ using System.Text.Json.Serialization; using System.Threading.Tasks; using System; using AutoGen.Core; -using AutoGen.OpenAI.Extension; <#if (!String.IsNullOrEmpty(NameSpace)) {#> namespace <#=NameSpace#> From e5c2eca4dd15143a282fa466760fbb6ef81a550d Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Thu, 1 Aug 2024 14:27:56 -0700 Subject: [PATCH 2/3] fix build error --- ...nctionCallTemplateTests.TestFunctionCallTemplate.approved.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/dotnet/test/AutoGen.SourceGenerator.Tests/ApprovalTests/FunctionCallTemplateTests.TestFunctionCallTemplate.approved.txt b/dotnet/test/AutoGen.SourceGenerator.Tests/ApprovalTests/FunctionCallTemplateTests.TestFunctionCallTemplate.approved.txt index f223d3124dd..ea5a8585cc2 100644 --- a/dotnet/test/AutoGen.SourceGenerator.Tests/ApprovalTests/FunctionCallTemplateTests.TestFunctionCallTemplate.approved.txt +++ b/dotnet/test/AutoGen.SourceGenerator.Tests/ApprovalTests/FunctionCallTemplateTests.TestFunctionCallTemplate.approved.txt @@ -8,7 +8,6 @@ using System.Text.Json.Serialization; using System.Threading.Tasks; using System; using AutoGen.Core; -using AutoGen.OpenAI.Extension; namespace AutoGen.SourceGenerator.Tests { From 7fcb73a9dfb72c467c22428f390305a8d59c140c Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Thu, 1 Aug 2024 14:29:31 -0700 Subject: [PATCH 3/3] revert change --- .../AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj b/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj index f5832ea2209..fe7553b937f 100644 --- a/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj +++ b/dotnet/sample/AutoGen.Anthropic.Samples/AutoGen.Anthropic.Samples.csproj @@ -11,7 +11,7 @@ - +