You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just getting started here - I've created an API key via https://aistudio.google.com/app/apikey and done nothing else to configure - I have my API key from that site - and I run the code as follows (and API key is set correctly). The function calling example doesn't work, but the toy demo they provide does workj
client = Gemini.new(
credentials: {
service: 'generative-language-api',
api_key: ENV['GOOGLE_API_KEY']
},
options: { model: 'gemini-pro', server_sent_events: true }
)
input = {
tools: {
function_declarations: [
{
name: 'date_and_time',
description: 'Returns the current date and time in the ISO 8601 format for a given timezone.',
parameters: {
type: 'object',
properties: {
timezone: {
type: 'string',
description: 'A string represents the timezone to be used for providing a datetime, following the IANA (Internet Assigned Numbers Authority) Time Zone Database. Examples include "Asia/Tokyo" and "Europe/Paris". If not provided, the default timezone is the user\'s current timezone.'
}
}
}
}
]
},
contents: [
{ role: 'user', parts: { text: 'What time is it?' } }
]
}
irb(main):068:0> result = client.stream_generate_content(input)
ETHON: performed EASY effective_url=https://generativelanguage.googleapis.com/v1/models/gemini-1.0-pro:streamGenerateContent?alt=sse&key=XXX response_code=400 return_code=ok total_time=0.038375
/usr/local/lib/ruby/gems/3.1.0/gems/faraday-2.12.0/lib/faraday/response/raise_error.rb:30:in `on_complete': the server responded with status 400 (Faraday::BadRequestError)
The basic toy demo works fine:
irb(main):077:0> input = {"contents":[{"parts":[{"text":"Explain how AI works"}]}]}
=> {:contents=>[{:parts=>[{:text=>"Explain how AI works"}]}]}
irb(main):078:0> result = client.stream_generate_content(input)
ETHON: performed EASY effective_url=https://generativelanguage.googleapis.com/v1/models/vertex-ai-api:streamGenerateContent?key=XXX response_code=404 return_code=ok total_time=0.093008
/usr/local/lib/ruby/gems/3.1.0/gems/faraday-2.12.0/lib/faraday/response/raise_error.rb:30:in `on_complete': the server responded with status 404 (Faraday::ResourceNotFound)
irb(main):079:0> result
=>
[{"candidates"=>
[{"content"=>{"parts"=>[{"text"=>"**Artificial Intelligence (AI)** is the simulation of human intelligence processes by machines,"}], "role"=>"model"},
"finishReason"=>"STOP",
"index"=>0,
"safetyRatings"=>
I'm guessing I'm missing some configuration for my account - any leads on what the likely error is here?
The text was updated successfully, but these errors were encountered:
Hello!
Just getting started here - I've created an API key via https://aistudio.google.com/app/apikey and done nothing else to configure - I have my API key from that site - and I run the code as follows (and API key is set correctly). The function calling example doesn't work, but the toy demo they provide does workj
The basic toy demo works fine:
I'm guessing I'm missing some configuration for my account - any leads on what the likely error is here?
The text was updated successfully, but these errors were encountered: