MCPcopy
hub / github.com/wavetermdev/waveterm / testAnthropic

Function testAnthropic

cmd/testai/main-testai.go:310–358  ·  view source on GitHub ↗
(ctx context.Context, model, message string, tools []uctypes.ToolDefinition)

Source from the content-addressed store, hash-verified

308}
309
310func testAnthropic(ctx context.Context, model, message string, tools []uctypes.ToolDefinition) {
311 apiKey := os.Getenv("ANTHROPIC_APIKEY")
312 if apiKey == "" {
313 fmt.Println("Error: ANTHROPIC_APIKEY environment variable not set")
314 os.Exit(1)
315 }
316
317 opts := &uctypes.AIOptsType{
318 APIType: uctypes.APIType_AnthropicMessages,
319 APIToken: apiKey,
320 Model: model,
321 MaxTokens: 4096,
322 ThinkingLevel: uctypes.ThinkingLevelMedium,
323 }
324
325 // Generate a chat ID
326 chatID := uuid.New().String()
327
328 // Convert to AIMessage format for WaveAIPostMessageWrap
329 aiMessage := &uctypes.AIMessage{
330 MessageId: uuid.New().String(),
331 Parts: []uctypes.AIMessagePart{
332 {
333 Type: uctypes.AIMessagePartTypeText,
334 Text: message,
335 },
336 },
337 }
338
339 fmt.Printf("Testing Anthropic streaming with WaveAIPostMessageWrap, model: %s\n", model)
340 fmt.Printf("Message: %s\n", message)
341 fmt.Printf("Chat ID: %s\n", chatID)
342 fmt.Println("---")
343
344 testWriter := &TestResponseWriter{}
345 sseHandler := sse.MakeSSEHandlerCh(testWriter, ctx)
346 defer sseHandler.Close()
347
348 chatOpts := uctypes.WaveChatOpts{
349 ChatId: chatID,
350 ClientId: uuid.New().String(),
351 Config: *opts,
352 Tools: tools,
353 }
354 err := aiusechat.WaveAIPostMessageWrap(ctx, sseHandler, aiMessage, chatOpts)
355 if err != nil {
356 fmt.Printf("Anthropic streaming error: %v\n", err)
357 }
358}
359
360func testGemini(ctx context.Context, model, message string, tools []uctypes.ToolDefinition) {
361 apiKey := os.Getenv("GOOGLE_APIKEY")

Callers 2

testT1Function · 0.85
mainFunction · 0.85

Calls 4

MakeSSEHandlerChFunction · 0.92
WaveAIPostMessageWrapFunction · 0.92
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected