Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dotnet/samples/Concepts/Agents/ComplexChat_NestedShopper.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
using Azure.AI.OpenAI;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.Agents.Chat;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using OpenAI.Chat;
using Resources;

namespace Agents;
Expand Down Expand Up @@ -98,7 +98,7 @@ public async Task NestedChatWithAggregatorAgentAsync()
{
Console.WriteLine($"! {Model}");

OpenAIPromptExecutionSettings jsonSettings = new() { ResponseFormat = ChatCompletionsResponseFormat.JsonObject };
OpenAIPromptExecutionSettings jsonSettings = new() { ResponseFormat = ChatResponseFormat.JsonObject };
OpenAIPromptExecutionSettings autoInvokeSettings = new() { ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions };

ChatCompletionAgent internalLeaderAgent = CreateAgent(InternalLeaderName, InternalLeaderInstructions);
Expand Down
3 changes: 3 additions & 0 deletions dotnet/samples/Concepts/Agents/Legacy_AgentCharts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,16 @@ async Task InvokeAgentAsync(IAgentThread thread, string imageName, string questi
}
}

#pragma warning disable CS0618 // Type or member is obsolete
private static OpenAIFileService CreateFileService()

{
return
ForceOpenAI || string.IsNullOrEmpty(TestConfiguration.AzureOpenAI.Endpoint) ?
new OpenAIFileService(TestConfiguration.OpenAI.ApiKey) :
new OpenAIFileService(new Uri(TestConfiguration.AzureOpenAI.Endpoint), apiKey: TestConfiguration.AzureOpenAI.ApiKey);
}
#pragma warning restore CS0618 // Type or member is obsolete

private static AgentBuilder CreateAgentBuilder()
{
Expand Down
6 changes: 5 additions & 1 deletion dotnet/samples/Concepts/Agents/Legacy_AgentTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ public async Task RunRetrievalToolAsync()
}

Kernel kernel = CreateFileEnabledKernel();
#pragma warning disable CS0618 // Type or member is obsolete
var fileService = kernel.GetRequiredService<OpenAIFileService>();
var result =
await fileService.UploadContentAsync(
new BinaryContent(await EmbeddedResource.ReadAllAsync("travelinfo.txt")!, "text/plain"),
new OpenAIFileUploadExecutionSettings("travelinfo.txt", OpenAIFilePurpose.Assistants));
#pragma warning restore CS0618 // Type or member is obsolete

var fileId = result.Id;
Console.WriteLine($"! {fileId}");
Expand Down Expand Up @@ -167,10 +169,12 @@ async Task InvokeAgentAsync(IAgent agent, string question)

private static Kernel CreateFileEnabledKernel()
{
#pragma warning disable CS0618 // Type or member is obsolete
return
ForceOpenAI || string.IsNullOrEmpty(TestConfiguration.AzureOpenAI.Endpoint) ?
Kernel.CreateBuilder().AddOpenAIFiles(TestConfiguration.OpenAI.ApiKey).Build() :
Kernel.CreateBuilder().AddAzureOpenAIFiles(TestConfiguration.AzureOpenAI.Endpoint, TestConfiguration.AzureOpenAI.ApiKey).Build();
throw new NotImplementedException("The file service is being deprecated and was not moved to AzureOpenAI connector.");
#pragma warning restore CS0618 // Type or member is obsolete
}

private static AgentBuilder CreateAgentBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ public class OpenAIAssistant_FileManipulation(ITestOutputHelper output) : BaseTe
[Fact]
public async Task AnalyzeCSVFileUsingOpenAIAssistantAgentAsync()
{
#pragma warning disable CS0618 // Type or member is obsolete
OpenAIFileService fileService = new(TestConfiguration.OpenAI.ApiKey);

OpenAIFileReference uploadFile =
await fileService.UploadContentAsync(
new BinaryContent(await EmbeddedResource.ReadAllAsync("sales.csv"), mimeType: "text/plain"),
new OpenAIFileUploadExecutionSettings("sales.csv", OpenAIFilePurpose.Assistants));

#pragma warning restore CS0618 // Type or member is obsolete

Console.WriteLine(this.ApiKey);

// Define the agent
Expand Down
3 changes: 3 additions & 0 deletions dotnet/samples/Concepts/Agents/OpenAIAssistant_FileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class OpenAIAssistant_FileService(ITestOutputHelper output) : BaseTest(ou
[Fact]
public async Task UploadAndRetrieveFilesAsync()
{
#pragma warning disable CS0618 // Type or member is obsolete
OpenAIFileService fileService = new(TestConfiguration.OpenAI.ApiKey);

BinaryContent[] files = [
Expand Down Expand Up @@ -62,5 +63,7 @@ public async Task UploadAndRetrieveFilesAsync()
// Delete the test file remotely
await fileService.DeleteFileAsync(fileReference.Id);
}

#pragma warning restore CS0618 // Type or member is obsolete
}
}
3 changes: 2 additions & 1 deletion dotnet/samples/Concepts/Agents/OpenAIAssistant_Retrieval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ public class OpenAIAssistant_Retrieval(ITestOutputHelper output) : BaseTest(outp
[Fact]
public async Task UseRetrievalToolWithOpenAIAssistantAgentAsync()
{
#pragma warning disable CS0618 // Type or member is obsolete
OpenAIFileService fileService = new(TestConfiguration.OpenAI.ApiKey);

OpenAIFileReference uploadFile =
await fileService.UploadContentAsync(new BinaryContent(await EmbeddedResource.ReadAllAsync("travelinfo.txt")!, "text/plain"),
new OpenAIFileUploadExecutionSettings("travelinfo.txt", OpenAIFilePurpose.Assistants));

#pragma warning restore CS0618 // Type or member is obsolete
// Define the agent
OpenAIAssistantAgent agent =
await OpenAIAssistantAgent.CreateAsync(
Expand Down
40 changes: 2 additions & 38 deletions dotnet/samples/Concepts/Concepts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<ProjectReference Include="..\..\src\Connectors\Connectors.MistralAI\Connectors.MistralAI.csproj" />
<ProjectReference Include="..\..\src\Agents\Abstractions\Agents.Abstractions.csproj" />
<ProjectReference Include="..\..\src\Agents\Core\Agents.Core.csproj" />
<!--ProjectReference Include="..\..\src\Agents\OpenAI\Agents.OpenAI.csproj" /-->
<ProjectReference Include="..\..\src\Agents\OpenAI\Agents.OpenAI.csproj" />
<ProjectReference Include="..\..\src\Connectors\Connectors.Google\Connectors.Google.csproj" />
<ProjectReference Include="..\..\src\Connectors\Connectors.HuggingFace\Connectors.HuggingFace.csproj" />
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.AzureAISearch\Connectors.Memory.AzureAISearch.csproj" />
Expand All @@ -64,7 +64,7 @@
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.Sqlite\Connectors.Memory.Sqlite.csproj" />
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.Weaviate\Connectors.Memory.Weaviate.csproj" />
<ProjectReference Include="..\..\src\Connectors\Connectors.OpenAIV2\Connectors.OpenAIV2.csproj" />
<!--ProjectReference Include="..\..\src\Experimental\Agents\Experimental.Agents.csproj" /-->
<ProjectReference Include="..\..\src\Experimental\Agents\Experimental.Agents.csproj" />
<ProjectReference Include="..\..\src\Experimental\Orchestration.Flow\Experimental.Orchestration.Flow.csproj" />
<ProjectReference Include="..\..\src\Extensions\PromptTemplates.Handlebars\PromptTemplates.Handlebars.csproj" />
<ProjectReference Include="..\..\src\Extensions\PromptTemplates.Liquid\PromptTemplates.Liquid.csproj" />
Expand Down Expand Up @@ -109,40 +109,4 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Compile Remove="Agents\ChatCompletion_FunctionTermination.cs" />
<Compile Remove="Agents\ChatCompletion_Streaming.cs" />
<Compile Remove="Agents\ComplexChat_NestedShopper.cs" />
<Compile Remove="Agents\Legacy_AgentAuthoring.cs" />
<Compile Remove="Agents\Legacy_AgentCharts.cs" />
<Compile Remove="Agents\Legacy_AgentCollaboration.cs" />
<Compile Remove="Agents\Legacy_AgentDelegation.cs" />
<Compile Remove="Agents\Legacy_Agents.cs" />
<Compile Remove="Agents\Legacy_AgentTools.cs" />
<Compile Remove="Agents\Legacy_ChatCompletionAgent.cs" />
<Compile Remove="Agents\MixedChat_Agents.cs" />
<Compile Remove="Agents\OpenAIAssistant_ChartMaker.cs" />
<Compile Remove="Agents\OpenAIAssistant_CodeInterpreter.cs" />
<Compile Remove="Agents\OpenAIAssistant_FileManipulation.cs" />
<Compile Remove="Agents\OpenAIAssistant_FileService.cs" />
<Compile Remove="Agents\OpenAIAssistant_Retrieval.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Agents\ChatCompletion_FunctionTermination.cs" />
<None Include="Agents\ChatCompletion_Streaming.cs" />
<None Include="Agents\ComplexChat_NestedShopper.cs" />
<None Include="Agents\Legacy_AgentAuthoring.cs" />
<None Include="Agents\Legacy_AgentCharts.cs" />
<None Include="Agents\Legacy_AgentCollaboration.cs" />
<None Include="Agents\Legacy_AgentDelegation.cs" />
<None Include="Agents\Legacy_Agents.cs" />
<None Include="Agents\Legacy_AgentTools.cs" />
<None Include="Agents\Legacy_ChatCompletionAgent.cs" />
<None Include="Agents\MixedChat_Agents.cs" />
<None Include="Agents\OpenAIAssistant_ChartMaker.cs" />
<None Include="Agents\OpenAIAssistant_CodeInterpreter.cs" />
<None Include="Agents\OpenAIAssistant_FileManipulation.cs" />
<None Include="Agents\OpenAIAssistant_FileService.cs" />
<None Include="Agents\OpenAIAssistant_Retrieval.cs" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion dotnet/src/Experimental/Agents/Experimental.Agents.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="System.Linq.Async" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Connectors\Connectors.OpenAI\Connectors.OpenAI.csproj" />
<ProjectReference Include="..\..\Connectors\Connectors.AzureOpenAI\Connectors.AzureOpenAI.csproj" />
<ProjectReference Include="..\..\Extensions\PromptTemplates.Handlebars\PromptTemplates.Handlebars.csproj" />
<ProjectReference Include="..\..\Functions\Functions.Yaml\Functions.Yaml.csproj" />
<ProjectReference Include="..\..\SemanticKernel.Core\SemanticKernel.Core.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private static void AddHeaders(this HttpRequestMessage request, OpenAIRestContex
{
request.Headers.Add(HeaderNameOpenAIAssistant, HeaderOpenAIValueAssistant);
request.Headers.Add(HeaderNameUserAgent, HttpHeaderConstant.Values.UserAgent);
request.Headers.Add(HttpHeaderConstant.Names.SemanticKernelVersion, HttpHeaderConstant.Values.GetAssemblyVersion(typeof(OpenAIFileService)));
request.Headers.Add(HttpHeaderConstant.Names.SemanticKernelVersion, HttpHeaderConstant.Values.GetAssemblyVersion(typeof(OpenAIChatCompletionService)));

if (context.HasVersion)
{
Expand Down