mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
.Net: Update Code Interpreter Sample as a Step. (#148)
* Updating code interpreter samples * Small adjustments to ensure it works as expected * Update dotnet/samples/GettingStarted/Steps/Step03_ChatClientAgent_UsingCodeInterpreterTools.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Address xmldoc * Addressing PR coment, external implementaions + ChatClients update, removing RawRepresentationFactory requirement * Address warnings * Update Fix warnings * Proposed changes for the OpenAIAssistantChatClient * Address PR comments --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Mark Wallace <127216156+markwallace-microsoft@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
01fd74a80c
commit
fef4fd2c18
@@ -251,6 +251,7 @@ public sealed partial class PersistentAgentsChatClient : IChatClient
|
||||
if (options.Tools is { Count: > 0 } tools)
|
||||
{
|
||||
List<ToolDefinition> toolDefinitions = [];
|
||||
ToolResources? toolResources = null;
|
||||
|
||||
// If the caller has provided any tool overrides, we'll assume they don't want to use the agent's tools.
|
||||
// But if they haven't, the only way we can provide our tools is via an override, whereas we'd really like to
|
||||
@@ -287,6 +288,15 @@ public sealed partial class PersistentAgentsChatClient : IChatClient
|
||||
|
||||
case HostedCodeInterpreterTool:
|
||||
toolDefinitions.Add(new CodeInterpreterToolDefinition());
|
||||
|
||||
// Once available, HostedCodeInterpreterTool.FileIds property will be used instead of the AdditionalProperties.
|
||||
if (tool.AdditionalProperties.TryGetValue("fileIds", out object? fileIdsObject) && fileIdsObject is IEnumerable<string> fileIds)
|
||||
{
|
||||
foreach (var fileId in fileIds)
|
||||
{
|
||||
(toolResources ??= new() { CodeInterpreter = new() }).CodeInterpreter.FileIds.Add(fileId);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case HostedWebSearchTool webSearch when webSearch.AdditionalProperties?.TryGetValue("connectionId", out object? connectionId) is true:
|
||||
@@ -299,6 +309,11 @@ public sealed partial class PersistentAgentsChatClient : IChatClient
|
||||
{
|
||||
runOptions.OverrideTools = toolDefinitions;
|
||||
}
|
||||
|
||||
if (toolResources is not null)
|
||||
{
|
||||
runOptions.ToolResources = toolResources;
|
||||
}
|
||||
}
|
||||
|
||||
// Store the tool mode, if relevant.
|
||||
|
||||
Reference in New Issue
Block a user