Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLS Handshake Timeout and 400 Error Using Context Caching #244

Open
AlvaroG13191704 opened this issue Feb 25, 2025 · 0 comments
Open

TLS Handshake Timeout and 400 Error Using Context Caching #244

AlvaroG13191704 opened this issue Feb 25, 2025 · 0 comments
Labels
type:bug Something isn't working

Comments

@AlvaroG13191704
Copy link

Description of the bug:

I'm encountering intermittent errors when using context caching with the gemini-1.5-pro-002 model or another in the generative-ai-go library. The errors include TLS handshake timeouts and API error 400 responses.

Here are some examples of the errors I encountered:

Image

Code to Reproduce

Here is the relevant part of my implementation:

ctx := context.Background()
argcc := &genai.CachedContent{
    Expiration: genai.ExpireTimeOrTTL{
        ExpireTime: time.Now().Add(1 * time.Hour),
    },
    Model:             "gemini-1.5-pro-002",
    SystemInstruction: genai.NewUserContent(genai.Text("Example system instruction")),
    Contents:          content,  // Multiple PDFs loaded as genai.Content
}

cc, err := g.Client.CreateCachedContent(ctx, argcc)
if err != nil {
    fmt.Printf("Error creating cached content: %v", err)
    panic(err)
}

resp, err := g.Session.SendMessage(ctx, genai.Text("Example prompt"))
if err != nil {
    fmt.Printf("Error sending message: %v", err)
    panic(err)
}

Actual vs expected behavior:

I should receive the response

Any other information you'd like to share?

I'm using the latest version of the SDK.

I've already set my json credentials and Gemini API KEY.

@AlvaroG13191704 AlvaroG13191704 added the type:bug Something isn't working label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant