Feat: add tests

This commit is contained in:
Grail Finder
2025-09-05 14:21:18 +03:00
parent 8699b1a84e
commit 53dc5a5e8d
4 changed files with 409 additions and 12 deletions

30
main.go
View File

@@ -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,