question about set the HTTP_PROXY for client
hey @eliben:
Due to some reasons, I had to set up an HTTP proxy to access Google's related services.
But when run this project, I tried several methods to modify the source code to pass in the proxy, but none of them were successful.
Please provide a brief code example to overcome this problem.
Thank you!
I'll take a look at this. Traveling now so it may take a few days
There are some example folks used in https://github.com/google/generative-ai-go/issues/17, but you will have to modify the source code. It's not currently supported out of the box.
thx, maybe we can add a api for : https://github.com/google/generative-ai-go/issues/17#issuecomment-1870768732. imo, setting up a proxy is a mandatory option for the regions where it is not convenient to directly access google's services
Which proxy are you using?
Which proxy are you using?
I don't know what you meaning about "which proxy"
Which proxy are you using?
I don't know what you meaning about "which proxy"
Which proxy server - what is the value of HTTP_PROXY you're setting?
http://127.0.0.1:xyz
I've added a --proxy flag in the latest tag (0.5.0)
Please try it and let me know if it works for you
thx, it's work
if we can output more error log information for GenerateContentStream likes GenerateContent that would be even better(perhaps this requires modifying the genai).
if stream := mustGetBoolFlag(cmd, "stream"); stream {
iter := model.GenerateContentStream(ctx, promptParts...)
for {
resp, err := iter.Next()
if err == iterator.Done {
break
}
if err != nil {
log.Fatal(err) // HERE: 2024/05/07 10:48:39 googleapi: Error 400:
}
if len(resp.Candidates) < 1 {
fmt.Println("<empty response from model>")
} else {
c := resp.Candidates[0]
if c.Content != nil {
for _, part := range c.Content.Parts {
fmt.Print(part)
}
} else {
fmt.Println("<empty response from model>")
}
}
}
fmt.Println()
} else {
resp, err := model.GenerateContent(ctx, promptParts...)
if err != nil {
log.Fatal(err) // HERE: 2024/05/07 10:40:26 googleapi: Error 400: User location is not supported for the API use.
}
if len(resp.Candidates) < 1 {
fmt.Println("<empty response from model>")
} else {
c := resp.Candidates[0]
if c.Content != nil {
for _, part := range c.Content.Parts {
fmt.Println(part)
}
} else {
fmt.Println("<empty response from model>")
}
}
}