Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix rename
  • Loading branch information
christothes committed May 6, 2025
commit de89187f0637b99297f3f038e96d6d084723232f
6 changes: 3 additions & 3 deletions src/Utility/ResponseTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace OpenAI.Responses;
/// Provides functionality to manage and execute OpenAI function tools for responses.
/// </summary>
//[Experimental("OPENAIMCP001")
public class CallLocalAsync
public class ResponseTools
{
private readonly Dictionary<string, MethodInfo> _methods = [];
private readonly Dictionary<string, Func<string, BinaryData, Task<BinaryData>>> _mcpMethods = [];
Expand All @@ -30,7 +30,7 @@ public class CallLocalAsync
/// Initializes a new instance of the ResponseTools class with an optional embedding client.
/// </summary>
/// <param name="client">The embedding client used for tool vectorization, or null to disable vectorization.</param>
public CallLocalAsync(EmbeddingClient client = null)
public ResponseTools(EmbeddingClient client = null)
{
_client = client;
}
Expand All @@ -39,7 +39,7 @@ public CallLocalAsync(EmbeddingClient client = null)
/// Initializes a new instance of the ResponseTools class with the specified tool types.
/// </summary>
/// <param name="tools">Additional tool types to add.</param>
public CallLocalAsync(params Type[] tools) : this((EmbeddingClient)null)
public ResponseTools(params Type[] tools) : this((EmbeddingClient)null)
{
foreach (var t in tools)
AddFunctionTool(t);
Expand Down
52 changes: 26 additions & 26 deletions tests/Utility/ResponseToolsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ public static async Task<double> MultiplyAsync(double x, double y)
await Task.Delay(1); // Simulate async work
return x * y;
}

public static async Task<bool> IsGreaterThanAsync(long value1, long value2)
{
await Task.Delay(1); // Simulate async work
return value1 > value2;
}

public static async Task<float> DivideAsync(float numerator, float denominator)
{
await Task.Delay(1); // Simulate async work
return numerator / denominator;
}

public static async Task<string> ConcatWithBoolAsync(string text, bool flag)
{
await Task.Delay(1); // Simulate async work
return $"{text}:{flag}";
}
public static async Task<bool> IsGreaterThanAsync(long value1, long value2)
{
await Task.Delay(1); // Simulate async work
return value1 > value2;
}

public static async Task<float> DivideAsync(float numerator, float denominator)
{
await Task.Delay(1); // Simulate async work
return numerator / denominator;
}

public static async Task<string> ConcatWithBoolAsync(string text, bool flag)
{
await Task.Delay(1); // Simulate async work
return $"{text}:{flag}";
}
}

private Mock<EmbeddingClient> mockEmbeddingClient;
Expand All @@ -77,7 +77,7 @@ public void Setup()
[Test]
public void CanAddLocalTools()
{
var tools = new CallLocalAsync();
var tools = new ResponseTools();
tools.AddFunctionTools(typeof(TestTools));

Assert.That(tools.Tools, Has.Count.EqualTo(6));
Expand All @@ -92,7 +92,7 @@ public void CanAddLocalTools()
[Test]
public void CanAddLocalAsyncTools()
{
var tools = new CallLocalAsync();
var tools = new ResponseTools();
tools.AddFunctionTools(typeof(TestToolsAsync));

Assert.That(tools.Tools, Has.Count.EqualTo(6));
Expand All @@ -107,7 +107,7 @@ public void CanAddLocalAsyncTools()
[Test]
public async Task CanCallToolAsync()
{
var tools = new CallLocalAsync();
var tools = new ResponseTools();
tools.AddFunctionTools(typeof(TestTools));

var toolCalls = new[]
Expand Down Expand Up @@ -151,7 +151,7 @@ public async Task CanCallToolAsync()
[Test]
public async Task CanCallAsyncToolsAsync()
{
var tools = new CallLocalAsync();
var tools = new ResponseTools();
tools.AddFunctionTools(typeof(TestToolsAsync));

var toolCalls = new[]
Expand Down Expand Up @@ -195,7 +195,7 @@ public async Task CanCallAsyncToolsAsync()
[Test]
public void CreatesResponseOptionsWithTools()
{
var tools = new CallLocalAsync();
var tools = new ResponseTools();
tools.AddFunctionTools(typeof(TestTools));

var options = tools.ToResponseCreationOptions();
Expand Down Expand Up @@ -239,7 +239,7 @@ public async Task CanFilterToolsByRelevance()
It.IsAny<CancellationToken>()))
.ReturnsAsync(ClientResult.FromValue(embeddingCollection, mockResponse));

var tools = new CallLocalAsync(mockEmbeddingClient.Object);
var tools = new ResponseTools(mockEmbeddingClient.Object);
tools.AddFunctionTools(typeof(TestTools));

var options = await tools.ToResponseCreationOptionsAsync("Need to add two numbers", 1, 0.5f);
Expand All @@ -250,7 +250,7 @@ public async Task CanFilterToolsByRelevance()
[Test]
public async Task ReturnsErrorForNonExistentTool()
{
var tools = new CallLocalAsync();
var tools = new ResponseTools();
var toolCall = new FunctionCallResponseItem("call1", "NonExistentTool", BinaryData.FromString("{}"));

var result = await tools.CallAsync(toolCall);
Expand All @@ -262,7 +262,7 @@ public async Task AddMcpToolsAsync_AddsToolsCorrectly()
{
// Arrange
var mockMcpClient = new Mock<McpClient>(new Uri("http://localhost:1234"));
var tools = new CallLocalAsync();
var tools = new ResponseTools();

var mockToolsResponse = BinaryData.FromString(@"
{
Expand Down Expand Up @@ -340,7 +340,7 @@ public async Task CreateResponseOptions_WithMaxToolsParameter_FiltersTools()
{
// Arrange
var mockMcpClient = new Mock<McpClient>(new Uri("http://localhost:1234"));
var tools = new CallLocalAsync(mockEmbeddingClient.Object);
var tools = new ResponseTools(mockEmbeddingClient.Object);

var mockToolsResponse = BinaryData.FromString(@"
{
Expand Down