Skip to content

Commit

Permalink
[.Net] Remove Azure.AI.OpenAI from AutoGen.DotnetInteractive package (m…
Browse files Browse the repository at this point in the history
…icrosoft#3274)

* remove Azure.AI.OpenAI dependencies

* fix build error

* revert change
  • Loading branch information
LittleLittleCloud authored Aug 2, 2024
1 parent 3186bb7 commit a375d7a
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@
<EmbeddedResource Include="RestoreInteractive.config" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="$(AzureOpenAIVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AutoGen.Core\AutoGen.Core.csproj" />
<ProjectReference Include="..\AutoGen.SourceGenerator\AutoGen.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

</Project>
105 changes: 3 additions & 102 deletions dotnet/src/AutoGen.DotnetInteractive/DotnetInteractiveFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -71,6 +69,7 @@ public DotnetInteractiveFunction(InteractiveService interactiveService, string?
/// Run existing dotnet code from message. Don't modify the code, run it as is.
/// </summary>
/// <param name="code">code.</param>
[Function]
public async Task<string> RunCode(string code)
{
if (this._interactiveService == null)
Expand Down Expand Up @@ -117,6 +116,7 @@ public async Task<string> RunCode(string code)
/// Install nuget packages.
/// </summary>
/// <param name="nugetPackages">nuget package to install.</param>
[Function]
public async Task<string> InstallNugetPackages(string[] nugetPackages)
{
if (this._interactiveService == null)
Expand Down Expand Up @@ -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<string> RunCodeWrapper(string arguments)
{
var schema = JsonSerializer.Deserialize<RunCodeSchema>(
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<string>();
}

public Task<string> InstallNugetPackagesWrapper(string arguments)
{
var schema = JsonSerializer.Deserialize<InstallNugetPackagesSchema>(
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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#>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit a375d7a

Please sign in to comment.