Open palladius opened 2 weeks ago
I'm happy to troubleshoot and file a PR myself, I just need help on how to enable Faraday logging (to see what API call is being made and what JSON is being returned).
This is the faraday dump. Seems like NO response body is available, just a "mute" 400. Note I'm based in Switzerland, and recently Gemini API KEYs have been made available in most of Europe. Weird it works from curl and not from this gem.
#<struct Faraday::Env
method=:post,
request_body=
"{\"contents\":[{\"role\":\"user\",\"parts\":{\"text\":\"Write a story about a magic backpack\"}}],\"generationConfig\":{\"candidateCount\":1},\"system_instruction\":{\"role\":\"user\",\"parts\":{\"text\":\"You are a helpful assistant from Google, called RAGazzo.\\nMake sure to always introduce yourself in interactions with humans.\\n\"}}}",
url=
#<URI::HTTPS https://generativelanguage.googleapis.com/v1/models/gemini-pro:streamGenerateContent?alt=sse&key=REDACTED>,
request=
#<struct Faraday::RequestOptions
params_encoder=nil,
proxy=nil,
bind=nil,
timeout=nil,
open_timeout=nil,
read_timeout=nil,
write_timeout=nil,
boundary=nil,
oauth=nil,
context=nil,
on_data=
#<Proc:0x0000000106e03358 /Users/ricc/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/gemini-ai-4.0.0/controllers/client.rb:164>>,
request_headers=
{"User-Agent"=>"Faraday v2.9.1", "Content-Type"=>"application/json"},
ssl=
#<struct Faraday::SSLOptions
verify=true,
verify_hostname=nil,
ca_file=nil,
ca_path=nil,
verify_mode=nil,
cert_store=nil,
client_cert=nil,
client_key=nil,
certificate=nil,
private_key=nil,
verify_depth=nil,
version=nil,
min_version=nil,
max_version=nil>,
parallel_manager=nil,
params=nil,
response=
#<Faraday::Response:0x0000000106df2238
@env=#<struct Faraday::Env:...>,
@on_complete_callbacks=[]>,
response_headers=
{"vary"=>"Origin, X-Origin, Referer",
"content-type"=>"text/event-stream",
"date"=>"Tue, 18 Jun 2024 06:19:46 GMT",
"server"=>"scaffolding on HTTPServer2",
"content-length"=>"457",
"x-xss-protection"=>"0",
"x-frame-options"=>"SAMEORIGIN",
"x-content-type-options"=>"nosniff",
"server-timing"=>"gfet4t7; dur=817",
"alt-svc"=>"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"},
status=400,
reason_phrase="",
response_body="">
Hi @palladius! Thank you very much for reporting the issue. I identified the root cause and I'm working on a fix in this PR:
@palladius fixed in version 3.2.0:
gem 'nano-bots', '~> 3.2'
Update:
Actually, prefer the newer version 3.4.0:
gem 'nano-bots', '~> 3.4'
You are a STAR! I've updated the dependency and now it works like a charm!
I took a look at https://github.com/icebaker/ruby-nano-bots/pull/22 . Nice job!
Hi, I'm trying to use nanobots with Gemini API key and keep failing repeatedly. after some debugging, I can see that
gemini-ai
andcurl
work great with my API key, while nb fails to work.For convenience the code is all here: https://github.com/palladius/ragazzi
I thought I might have a bad key, but then I tried this with same key and that worked:
==>
Please help