MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / testGemini

Function testGemini

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

Source from the content-addressed store, hash-verified

358}
359
360func testGemini(ctx context.Context, model, message string, tools []uctypes.ToolDefinition) {
361 apiKey := os.Getenv("GOOGLE_APIKEY")
362 if apiKey == "" {
363 fmt.Println("Error: GOOGLE_APIKEY environment variable not set")
364 os.Exit(1)
365 }
366
367 opts := &uctypes.AIOptsType{
368 APIType: uctypes.APIType_GoogleGemini,
369 APIToken: apiKey,
370 Model: model,
371 MaxTokens: 8192,
372 Capabilities: []string{uctypes.AICapabilityTools, uctypes.AICapabilityImages, uctypes.AICapabilityPdfs},
373 }
374
375 // Generate a chat ID
376 chatID := uuid.New().String()
377
378 // Convert to AIMessage format for WaveAIPostMessageWrap
379 aiMessage := &uctypes.AIMessage{
380 MessageId: uuid.New().String(),
381 Parts: []uctypes.AIMessagePart{
382 {
383 Type: uctypes.AIMessagePartTypeText,
384 Text: message,
385 },
386 },
387 }
388
389 fmt.Printf("Testing Google Gemini streaming with WaveAIPostMessageWrap, model: %s\n", model)
390 fmt.Printf("Message: %s\n", message)
391 fmt.Printf("Chat ID: %s\n", chatID)
392 fmt.Println("---")
393
394 testWriter := &TestResponseWriter{}
395 sseHandler := sse.MakeSSEHandlerCh(testWriter, ctx)
396 defer sseHandler.Close()
397
398 chatOpts := uctypes.WaveChatOpts{
399 ChatId: chatID,
400 ClientId: uuid.New().String(),
401 Config: *opts,
402 Tools: tools,
403 SystemPrompt: []string{"You are a helpful assistant. Be concise and clear in your responses."},
404 }
405 err := aiusechat.WaveAIPostMessageWrap(ctx, sseHandler, aiMessage, chatOpts)
406 if err != nil {
407 fmt.Printf("Google Gemini streaming error: %v\n", err)
408 }
409}
410
411func testT1(ctx context.Context) {
412 tool := aiusechat.GetAdderToolDefinition()

Callers 2

testT4Function · 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