Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleLittleCloud committed May 21, 2024
1 parent 08df00d commit 82d9426
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static async Task RunAsync()
// parallel function calls
var calculateTaxes = await agent.SendAsync("calculate tax: 100, 0.1; calculate tax: 200, 0.2");
calculateTaxes.GetContent().Should().Be("tax is 10\ntax is 40"); // "tax is 10\n tax is 40
calculateTaxes.Should().BeOfType<AggregateMessage<ToolCallMessage, ToolCallResultMessage>>();
calculateTaxes.Should().BeOfType<ToolCallAggregateMessage>();
calculateTaxes.GetToolCalls().Should().HaveCount(2);
calculateTaxes.GetToolCalls().First().FunctionName.Should().Be(nameof(CalculateTax));

Expand Down
6 changes: 5 additions & 1 deletion dotnet/src/AutoGen.Core/Message/ToolCallResultMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ public ToolCallResultMessage(string result, string functionName, string function

public string? GetContent()
{
return this.ToolCalls.Count == 1 ? this.ToolCalls.First().Result : null;
var results = this.ToolCalls
.Where(x => x.Result != null)
.Select(x => x.Result);

return string.Join("\n", results);
}

public override string ToString()
Expand Down
4 changes: 2 additions & 2 deletions dotnet/test/AutoGen.OpenAI.Tests/OpenAIMessageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public async Task ItProcessToolCallMessageAsync()
chatRequestMessage.ToolCalls.First().Should().BeOfType<ChatCompletionsFunctionToolCall>();
var functionToolCall = (ChatCompletionsFunctionToolCall)chatRequestMessage.ToolCalls.First();
functionToolCall.Name.Should().Be("test");
functionToolCall.Id.Should().Be("test_0");
functionToolCall.Id.Should().Be("test");
functionToolCall.Arguments.Should().Be("test");
return await innerAgent.GenerateReplyAsync(msgs);
})
Expand Down Expand Up @@ -353,7 +353,7 @@ public async Task ItProcessToolCallResultMessageAsync()
innerMessage!.Should().BeOfType<MessageEnvelope<ChatRequestMessage>>();
var chatRequestMessage = (ChatRequestToolMessage)((MessageEnvelope<ChatRequestMessage>)innerMessage!).Content;
chatRequestMessage.Content.Should().Be("result");
chatRequestMessage.ToolCallId.Should().Be("test_0");
chatRequestMessage.ToolCallId.Should().Be("test");
return await innerAgent.GenerateReplyAsync(msgs);
})
.RegisterMiddleware(middleware);
Expand Down

0 comments on commit 82d9426

Please sign in to comment.