Skip to content
Closed
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/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageVersion Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.301" />
<PackageVersion Include="Azure.AI.ContentSafety" Version="1.0.0" />
<PackageVersion Include="Azure.AI.Inference" Version="1.0.0-beta.2" />
<PackageVersion Include="Azure.AI.OpenAI" Version="[2.1.0-beta.2]" />
<PackageVersion Include="Azure.AI.OpenAI" Version="[2.2.0-beta.1]" />
<PackageVersion Include="Azure.AI.Projects" Version="[1.0.0-beta.3]" />
<PackageVersion Include="Azure.Identity" Version="1.13.2" />
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.3.0" />
Expand Down Expand Up @@ -49,7 +49,7 @@
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Npgsql" Version="8.0.6" />
<PackageVersion Include="OllamaSharp" Version="4.0.17" />
<PackageVersion Include="OpenAI" Version="[2.1.0-beta.2]" />
<PackageVersion Include="OpenAI" Version="[2.2.0-beta.1]" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
<PackageVersion Include="PdfPig" Version="0.1.9" />
<PackageVersion Include="Pinecone.NET" Version="2.1.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ public async Task UseSingleAssistantWithFunctionToolsAsync()
new()
{
Name = HostName,
Instructions = HostInstructions,
Metadata = AssistantSampleMetadata,
Instructions = HostInstructions
};

foreach (var keyValuePair in AssistantSampleMetadata)
{
creationOptions.Metadata.Add(keyValuePair);
}

// In this sample the function tools are added to the assistant this is
// important if you want to retrieve the assistant later and then dynamically check
// what function tools it requires.
Expand Down
20 changes: 10 additions & 10 deletions dotnet/src/Agents/OpenAI/Internal/AssistantThreadActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,23 +256,23 @@ await functionProcessor.InvokeFunctionCallsAsync(
int messageCount = 0;
foreach (RunStep completedStep in completedStepsToProcess)
{
if (completedStep.Type == RunStepType.ToolCalls)
if (completedStep.Kind == RunStepKind.ToolCall)
{
foreach (RunStepToolCall toolCall in completedStep.Details.ToolCalls)
{
bool isVisible = false;
ChatMessageContent? content = null;

// Process code-interpreter content
if (toolCall.ToolKind == RunStepToolCallKind.CodeInterpreter)
if (toolCall.Kind == RunStepToolCallKind.CodeInterpreter)
{
content = GenerateCodeInterpreterContent(agent.GetName(), toolCall.CodeInterpreterInput, completedStep);
isVisible = true;
}
// Process function result content
else if (toolCall.ToolKind == RunStepToolCallKind.Function)
else if (toolCall.Kind == RunStepToolCallKind.Function)
{
FunctionResultContent functionStep = functionSteps[toolCall.ToolCallId]; // Function step always captured on invocation
FunctionResultContent functionStep = functionSteps[toolCall.Id]; // Function step always captured on invocation
content = GenerateFunctionResultContent(agent.GetName(), [functionStep], completedStep);
}

Expand All @@ -284,7 +284,7 @@ await functionProcessor.InvokeFunctionCallsAsync(
}
}
}
else if (completedStep.Type == RunStepType.MessageCreation)
else if (completedStep.Kind == RunStepKind.CreatedMessage)
{
// Retrieve the message
ThreadMessage? message = await RetrieveMessageAsync(client, threadId, completedStep.Details.CreatedMessageId, agent.PollingOptions.MessageSynchronizationDelay, cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -506,7 +506,7 @@ await client.GetRunStepsAsync(run.ThreadId, run.Id, cancellationToken: cancellat
{
foreach (RunStepToolCall stepDetails in step.Details.ToolCalls)
{
toolMap[stepDetails.ToolCallId] = step.Id;
toolMap[stepDetails.Id] = step.Id;
}
}

Expand Down Expand Up @@ -564,14 +564,14 @@ await RetrieveMessageAsync(
{
foreach (RunStepToolCall toolCall in step.Details.ToolCalls)
{
if (toolCall.ToolKind == RunStepToolCallKind.Function)
if (toolCall.Kind == RunStepToolCallKind.Function)
{
messages?.Add(GenerateFunctionResultContent(agent.GetName(), stepFunctionResults[step.Id], step));
stepFunctionResults.Remove(step.Id);
break;
}

if (toolCall.ToolKind == RunStepToolCallKind.CodeInterpreter)
if (toolCall.Kind == RunStepToolCallKind.CodeInterpreter)
{
messages?.Add(GenerateCodeInterpreterContent(agent.GetName(), toolCall.CodeInterpreterInput, step));
}
Expand Down Expand Up @@ -761,13 +761,13 @@ private static ChatMessageContent GenerateCodeInterpreterContent(string agentNam

private static IEnumerable<FunctionCallContent> ParseFunctionStep(OpenAIAssistantAgent agent, RunStep step)
{
if (step.Status == RunStepStatus.InProgress && step.Type == RunStepType.ToolCalls)
if (step.Status == RunStepStatus.InProgress && step.Kind == RunStepKind.ToolCall)
{
foreach (RunStepToolCall toolCall in step.Details.ToolCalls)
{
(FunctionName nameParts, KernelArguments functionArguments) = ParseFunctionCall(toolCall.FunctionName, toolCall.FunctionArguments);

FunctionCallContent content = new(nameParts.Name, nameParts.PluginName, toolCall.ToolCallId, functionArguments);
FunctionCallContent content = new(nameParts.Name, nameParts.PluginName, toolCall.Id, functionArguments);

yield return content;
}
Expand Down