Closed JckHoe closed 1 week ago
Updating the Content
field to use the same as response and added ToolUseContent
.
The example is the way to recreate the issue where the llm generates a incorrect response.
{
"id": "msg_01PZ5755vfhLUM1Bf6fRtN1J",
"type": "message",
"role": "assistant",
"model": "claude-3-haiku-20240307",
"content": [
{
"type": "text",
"text": "{\"type\":\"tool_use\",\"id\":\"toolu_01FjodET1i2Lo8NqkoHZYHXe\",\"name\":\"getCurrentWeather\"}"
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 611,
"output_tokens": 41
}
}
This was the incorrect request Content
field .
{
"model": "claude-3-haiku-20240307",
"messages": [
{
"role": "user",
"content": "What is the weather like in Boston?"
},
{
"role": "assistant",
"content": "{\"type\":\"tool_use\",\"id\":\"toolu_01FjodET1i2Lo8NqkoHZYHXe\",\"name\":\"getCurrentWeather\"}"
},
{
"role": "user",
"content": "{\"type\":\"tool_result\",\"tool_use_id\":\"toolu_01FjodET1i2Lo8NqkoHZYHXe\",\"content\":\"\\\"72 and sunny\\\"\"}"
},
{
"role": "assistant",
"content": "According to the weather information, the current weather in Boston is 72 degrees and sunny."
},
{
"role": "user",
"content": "How about the weather in Chicago?"
},
{
"role": "assistant",
"content": "{\"type\":\"tool_use\",\"id\":\"toolu_019gLSWVyyiZ5zGLqZJcSkrf\",\"name\":\"getCurrentWeather\"}"
},
{
"role": "user",
"content": "{\"type\":\"tool_result\",\"tool_use_id\":\"toolu_019gLSWVyyiZ5zGLqZJcSkrf\",\"content\":\"\\\"65 and windy\\\"\"}"
},
{
"role": "assistant",
"content": "The current weather in Chicago is 65 degrees and windy."
},
{
"role": "user",
"content": "How about the weather in Chicago?"
}
],
"max_tokens": 2560,
"temperature": 0,
"tools": [
{
"name": "getCurrentWeather",
"description": "Get the current weather in a given location",
"input_schema": {
"properties": {
"location": {
"description": "The city and state, e.g. San Francisco, CA",
"type": "string"
},
"unit": {
"enum": ["fahrenheit", "celsius"],
"type": "string"
}
},
"required": ["location"],
"type": "object"
}
}
]
}
an example of expected request will look like this
{
"model": "claude-3-opus-20240229",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": ["location"]
}
}
],
"messages": [
{
"role": "user",
"content": "What is the weather like in San Francisco?"
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "let me look up that for you"
},
{
"type": "tool_use",
"id": "toolu_01A09q90qw90lq917835lq9",
"name": "get_weather",
"input": { "location": "San Francisco, CA" }
}
]
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_01A09q90qw90lq917835lq9",
"content": "15 degrees"
}
]
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "The current weather in San Francisco, CA is 15 degrees Celsius which is 59 degrees Fahrenheit. San Francisco has a cool Mediterranean climate, so temperatures are mild year-round, rarely getting very hot or very cold. 15C/59F is a fairly typical temperature there."
}
]
},
{
"role": "user",
"content": "What is the weather like in Malaysia?"
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "let me look up that for you"
},
{
"type": "tool_use",
"id": "toolu_01A09q90qw90lq917835lq9",
"name": "get_weather",
"input": { "location": "San Francisco, CA" }
}
]
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_01A09q90qw90lq917835lq9",
"content": "15 degrees"
}
]
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "Malaysia is 15 degrees"
}
]
},
{
"role": "user",
"content": "What is the weather like in Boston?"
}
]
}
@tmc I will resolve the conflict no worries
@tmc Thank you for the review, resolved conflicts
PR Checklist
memory: add interfaces for X, Y
orutil: add whizzbang helpers
).Fixes #123
).golangci-lint
checks.