MCPcopy Create free account
hub / github.com/docker/model-test / main

Function main

main.go:17–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15)
16
17func main() {
18 // Command line flags
19 var (
20 apiKey = flag.String("api-key", "DMR", "OpenAI API key (or set OPENAI_API_KEY env var)")
21 baseURL = flag.String("base-url", "http://localhost:12434/engines/v1", "OpenAI API base URL (or set OPENAI_BASE_URL env var)")
22 model = flag.String("model", "", "Model to use (or set OPENAI_MODEL env var, defaults to gpt-4o-mini)")
23 configFile = flag.String("config", "config/test_cases.json", "Path to test cases configuration file")
24 testCase = flag.String("test-case", "", "Run only the specified test case by name")
25 )
26 flag.Parse()
27
28 // Load test cases
29 testCases, err := loadTestCases(*configFile, *testCase)
30 if err != nil {
31 log.Fatalf("Failed to load test cases: %v", err)
32 }
33
34 // Generate output filenames with model name
35 sanitizedModel := sanitizeModelName(*model)
36 timestamp := time.Now().Format("20060102_150405")
37 outputFile := fmt.Sprintf("results/agent_test_results_%s_%s.json", sanitizedModel, timestamp)
38 logFile := fmt.Sprintf("logs/agent_test_logs_%s_%s.log", sanitizedModel, timestamp)
39
40 // Ensure directories exist
41 if err := os.MkdirAll("results", 0755); err != nil {
42 log.Fatalf("Failed to create results directory: %v", err)
43 }
44 if err := os.MkdirAll("logs", 0755); err != nil {
45 log.Fatalf("Failed to create logs directory: %v", err)
46 }
47
48 // Create request logger
49 logger, err := services.NewRequestLogger(logFile)
50 if err != nil {
51 log.Fatalf("Failed to create request logger: %v", err)
52 }
53 defer logger.Close()
54
55 // Create test runner with logger
56 runner := services.NewTestRunnerWithLogger(*apiKey, *baseURL, *model, logger)
57
58 // Print test configuration
59 fmt.Printf("🚀 Starting Agent Loop Tool Efficiency Test\n")
60 fmt.Printf("📊 Configuration:\n")
61 fmt.Printf(" Base URL: %s\n", *baseURL)
62 modelName := *model
63 if modelName == "" {
64 modelName = "gpt-4o-mini (default)"
65 }
66 fmt.Printf(" Model: %s\n", modelName)
67 if *testCase != "" {
68 fmt.Printf(" Single Test Case: %s\n", *testCase)
69 }
70 fmt.Printf(" Test Cases: %d\n", len(testCases))
71 fmt.Printf(" Output: %s\n", outputFile)
72 fmt.Printf(" Log File: %s\n", logFile)
73 fmt.Println()
74

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
NewRequestLoggerFunction · 0.92
NewTestRunnerWithLoggerFunction · 0.92
loadTestCasesFunction · 0.85
sanitizeModelNameFunction · 0.85
printAgentSummaryFunction · 0.85
RunAgentTestSuiteMethod · 0.80
SaveResultsMethod · 0.80

Tested by

no test coverage detected