language_model: Add tool results to message content (#17363)

This PR updates the message content for an LLM request to allow it
contain tool results.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-09-04 13:29:01 -04:00 committed by GitHub
parent 74907cb3e6
commit 30b2133336
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 73 additions and 38 deletions

View file

@ -261,12 +261,15 @@ pub fn count_anthropic_tokens(
for content in message.content {
match content {
MessageContent::Text(string) => {
string_contents.push_str(&string);
MessageContent::Text(text) => {
string_contents.push_str(&text);
}
MessageContent::Image(image) => {
tokens_from_images += image.estimate_tokens();
}
MessageContent::ToolResult(tool_result) => {
string_contents.push_str(&tool_result.content);
}
}
}