Feat: add tests
This commit is contained in:
30
main.go
30
main.go
@@ -180,6 +180,22 @@ func buildRPPrompt(sysPrompt string, history []models.RPMessage, characterName s
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func processLLMResponse(respText string) (string, models.ToolCallInfo) {
|
||||
// Check if the response indicates tool usage
|
||||
var toolCall models.ToolCallInfo
|
||||
if strings.HasPrefix(respText, "[TOOL_CALL:") && strings.HasSuffix(respText, "]") {
|
||||
// Extract tool name from the marker
|
||||
toolName := strings.TrimPrefix(strings.TrimSuffix(respText, "]"), "[TOOL_CALL:")
|
||||
toolCall = models.ToolCallInfo{
|
||||
Name: toolName,
|
||||
// Arguments would need to be parsed from the actual response
|
||||
}
|
||||
// Remove the marker from the response text
|
||||
respText = fmt.Sprintf("Used tool: %s", toolName)
|
||||
}
|
||||
return respText, toolCall
|
||||
}
|
||||
|
||||
func runBench(questions []models.Question) ([]models.Answer, error) {
|
||||
answers := []models.Answer{}
|
||||
for _, q := range questions {
|
||||
@@ -195,18 +211,8 @@ func runBench(questions []models.Question) ([]models.Answer, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if the response indicates tool usage
|
||||
var toolCall models.ToolCallInfo
|
||||
if strings.HasPrefix(respText, "[TOOL_CALL:") && strings.HasSuffix(respText, "]") {
|
||||
// Extract tool name from the marker
|
||||
toolName := strings.TrimPrefix(strings.TrimSuffix(respText, "]"), "[TOOL_CALL:")
|
||||
toolCall = models.ToolCallInfo{
|
||||
Name: toolName,
|
||||
// Arguments would need to be parsed from the actual response
|
||||
}
|
||||
// Remove the marker from the response text
|
||||
respText = fmt.Sprintf("Used tool: %s", toolName)
|
||||
}
|
||||
// Process the response to detect tool usage
|
||||
respText, toolCall := processLLMResponse(respText)
|
||||
|
||||
a := models.Answer{
|
||||
Q: q,
|
||||
|
Reference in New Issue
Block a user