-
Notifications
You must be signed in to change notification settings - Fork 411
fix: convert functionResponse parts to Spring AI ToolResponseMessage #1424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ | |
| import org.springframework.ai.chat.messages.AssistantMessage; | ||
| import org.springframework.ai.chat.messages.Message; | ||
| import org.springframework.ai.chat.messages.SystemMessage; | ||
| import org.springframework.ai.chat.messages.ToolResponseMessage; | ||
| import org.springframework.ai.chat.messages.UserMessage; | ||
| import org.springframework.ai.chat.metadata.ChatResponseMetadata; | ||
| import org.springframework.ai.chat.metadata.DefaultUsage; | ||
|
|
@@ -184,19 +185,18 @@ void testToLlmPromptWithFunctionResponse() { | |
| Prompt prompt = messageConverter.toLlmPrompt(request); | ||
|
|
||
| // Currently only UserMessage is created (function response is skipped) | ||
| assertThat(prompt.getInstructions()).hasSize(1); | ||
| assertThat(prompt.getInstructions()).hasSize(2); | ||
|
|
||
| Message userMessage = prompt.getInstructions().get(0); | ||
| assertThat(userMessage).isInstanceOf(UserMessage.class); | ||
| assertThat(((UserMessage) userMessage).getText()).isEqualTo("What's the weather?"); | ||
|
|
||
| // When Spring AI provides public API for ToolResponseMessage, uncomment: | ||
| // Message toolResponseMessage = prompt.getInstructions().get(1); | ||
| // assertThat(toolResponseMessage).isInstanceOf(ToolResponseMessage.class); | ||
| // ToolResponseMessage toolResponse = (ToolResponseMessage) toolResponseMessage; | ||
| // assertThat(toolResponse.getResponses()).hasSize(1); | ||
| // ToolResponseMessage.ToolResponse response = toolResponse.getResponses().get(0); | ||
| // assertThat(response.name()).isEqualTo("get_weather"); | ||
| Message toolResponseMessage = prompt.getInstructions().get(1); | ||
| assertThat(toolResponseMessage).isInstanceOf(ToolResponseMessage.class); | ||
| ToolResponseMessage toolResponse = (ToolResponseMessage) toolResponseMessage; | ||
| assertThat(toolResponse.getResponses()).hasSize(1); | ||
| ToolResponseMessage.ToolResponse response = toolResponse.getResponses().get(0); | ||
| assertThat(response.name()).isEqualTo("get_weather"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we also assert the tool call id? That's the actual subject of #1423, and testToLlmPromptWithFunctionCall already does it for the other direction at line 152. It looks like it needs a fixture change — |
||
| } | ||
|
|
||
| @Test | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still correct? Maybe it should be removed?