@@ -12,42 +12,42 @@ private struct FakeChatModel: ChatModel {
1212}
1313
1414final class ChatAgentParseOutputTests : XCTestCase {
15- func test_parsing_well_formatted_final_answer( ) throws {
15+ func test_parsing_well_formatted_final_answer( ) async throws {
1616 let finalAnswer = """
1717 Final Answer: The answer is 42.
1818 Because 42 is the answer to everything.
1919 """
2020
2121 let agent = ChatAgent ( chatModel: FakeChatModel ( ) , tools: [ ] , preferredLanguage: " " )
22- let result = agent. parseOutput ( finalAnswer)
22+ let result = await agent. parseOutput ( . init ( role : . assistant , content : finalAnswer) )
2323 XCTAssertEqual ( result, . finish( . init(
24- returnValue: """
24+ returnValue: . structured ( """
2525 The answer is 42.
2626 Because 42 is the answer to everything.
27- """ ,
27+ """ ) ,
2828 log: finalAnswer
2929 ) ) )
3030 }
3131
32- func test_parsing_final_answer_with_random_prefix( ) throws {
32+ func test_parsing_final_answer_with_random_prefix( ) async throws {
3333 let finalAnswer = """
3434 Now I have the final answer.
3535 Final Answer: The answer is 42.
3636 Because 42 is the answer to everything.
3737 """
3838
3939 let agent = ChatAgent ( chatModel: FakeChatModel ( ) , tools: [ ] , preferredLanguage: " " )
40- let result = agent. parseOutput ( finalAnswer)
40+ let result = await agent. parseOutput ( . init ( role : . assistant , content : finalAnswer) )
4141 XCTAssertEqual ( result, . finish( . init(
42- returnValue: """
42+ returnValue: . structured ( """
4343 The answer is 42.
4444 Because 42 is the answer to everything.
45- """ ,
45+ """ ) ,
4646 log: finalAnswer
4747 ) ) )
4848 }
4949
50- func test_parsing_action( ) throws {
50+ func test_parsing_action( ) async throws {
5151 let reply = """
5252 Question: How to setup langchain python?
5353 Thought: I am not familiar with langchain python, I should use the Search tool to find more information on how to set it up.
@@ -61,7 +61,7 @@ final class ChatAgentParseOutputTests: XCTestCase {
6161 """
6262
6363 let agent = ChatAgent ( chatModel: FakeChatModel ( ) , tools: [ ] , preferredLanguage: " " )
64- let result = agent. parseOutput ( reply)
64+ let result = await agent. parseOutput ( . init ( role : . assistant , content : reply) )
6565 XCTAssertEqual ( result, . actions( [
6666 . init(
6767 toolName: " Search " ,
@@ -71,7 +71,7 @@ final class ChatAgentParseOutputTests: XCTestCase {
7171 ] ) )
7272 }
7373
74- func test_parsing_broken_action_and_return_everything_ahead_of_it( ) {
74+ func test_parsing_broken_action_and_return_everything_ahead_of_it( ) async {
7575 let reply = """
7676 Question: How to setup langchain python?
7777 Thought: I am not familiar with langchain python, I should use the Search tool to find more information on how to set it up.
@@ -82,26 +82,26 @@ final class ChatAgentParseOutputTests: XCTestCase {
8282 """
8383
8484 let agent = ChatAgent ( chatModel: FakeChatModel ( ) , tools: [ ] , preferredLanguage: " " )
85- let result = agent. parseOutput ( reply)
85+ let result = await agent. parseOutput ( . init ( role : . assistant , content : reply) )
8686 XCTAssertEqual ( result, . finish( . init(
87- returnValue: """
87+ returnValue: . structured ( """
8888 Question: How to setup langchain python?
8989 Thought: I am not familiar with langchain python, I should use the Search tool to find more information on how to set it up.
90- """ ,
90+ """ ) ,
9191 log: reply
9292 ) ) )
9393 }
9494
95- func test_parsing_simple_reply_that_does_not_follow_the_format( ) {
95+ func test_parsing_simple_reply_that_does_not_follow_the_format( ) async {
9696 let reply = """
9797 The answer is 42.
9898 Because 42 is the answer to everything.
9999 """
100100
101101 let agent = ChatAgent ( chatModel: FakeChatModel ( ) , tools: [ ] , preferredLanguage: " " )
102- let result = agent. parseOutput ( reply)
102+ let result = await agent. parseOutput ( . init ( role : . assistant , content : reply) )
103103 XCTAssertEqual ( result, . finish( . init(
104- returnValue: reply,
104+ returnValue: . structured ( reply) ,
105105 log: reply
106106 ) ) )
107107 }
0 commit comments