Vertex API (gemini-pro model) undefined method `has_key?' for ...
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
Reproduce the request with the gemini-pro example and trace decoding from stream_project_location_publisher_model_generate_content in service.rb into google-apis-core's decode_response_body. Compare the returned array-shaped response with the generated model's expected structure; done means the request completes without the has_key? NoMethodError.
Written by the indexing model from the issue text.
Description
Environment details
- OS: MacOS
- Ruby version: 3.2.2
- Gem name and version: latest
Steps to reproduce
Execute Vertex AI GenerateContentRequest utilizing gemini-pro model and observe the error below
Code example
client = Google::Apis::AiplatformV1::AiplatformService.new
client.root_url = 'https://us-central1-aiplatform.googleapis.com/'
client.authorization = Google::Auth.get_application_default(scope: 'https://www.googleapis.com/auth/cloud-platform')
request = Google::Apis::AiplatformV1::GoogleCloudAiplatformV1GenerateContentRequest.new \
contents: [{
'role': 'user',
'parts': [
{
'text': 'Hello'
}
]
}],
generation_config: {
temperature: 0.7,
maxOutputTokens: 2048,
topP: 1.0
}
client.stream_project_location_publisher_model_generate_content \
"projects/#{project_id}/locations/us-central1/publishers/google/models/gemini-pro",
request
Error log
worker | Error performing Wgpt::BotJob (Job ID: e22f44bb-451c-4fe1-a6b9-4b75de1ff824) from Sidekiq(high) in 1563.54ms: NoMethodError (undefined method `has_key?' for [{"candidates"=>[{"content"=>{"role"=>"model", "parts"=>[{"text"=>"Hello! How may I assist you? "}]}, "finishReason"=>"STOP", "safetyRatings"=>[{"category"=>"HARM_CATEGORY_HARASSMENT", "probability"=>"NEGLIGIBLE"}, {"category"=>"HARM_CATEGORY_HATE_SPEECH", "probability"=>"NEGLIGIBLE"}, {"category"=>"HARM_CATEGORY_SEXUALLY_EXPLICIT", "probability"=>"NEGLIGIBLE"}, {"category"=>"HARM_CATEGORY_DANGEROUS_CONTENT", "probability"=>"NEGLIGIBLE"}]}], "usageMetadata"=>{"promptTokenCount"=>1, "candidatesTokenCount"=>9, "totalTokenCount"=>10}}]:Array):
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/hash/binding.rb:13:in `read'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/deserializer.rb:11:in `block in <module:Representable>'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/pipeline.rb:19:in `evaluate'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/pipeline.rb:10:in `block in call'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/pipeline.rb:9:in `each'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/pipeline.rb:9:in `inject'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/pipeline.rb:9:in `call'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/binding.rb:55:in `uncompile_fragment'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/binding.rb:14:in `block in call'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/binding.rb:12:in `each'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/binding.rb:12:in `call'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable.rb:68:in `representable_map!'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable.rb:48:in `update_properties_from'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/hash.rb:33:in `from_hash'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/representable-3.2.0/lib/representable/json.rb:37:in `from_json'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.0/lib/google/apis/core/api_command.rb:104:in `decode_response_body'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.0/lib/google/apis/core/http_command.rb:203:in `process_response'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.0/lib/google/apis/core/http_command.rb:321:in `execute_once'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.0/lib/google/apis/core/http_command.rb:126:in `block (2 levels) in do_retry'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:61:in `block in retriable'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `times'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `retriable'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.0/lib/google/apis/core/http_command.rb:123:in `block in do_retry'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:61:in `block in retriable'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `times'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `retriable'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.0/lib/google/apis/core/http_command.rb:113:in `do_retry'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.0/lib/google/apis/core/http_command.rb:104:in `execute'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.0/lib/google/apis/core/base_service.rb:418:in `execute_or_queue_command'
worker | /Users/mazen/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/google-apis-aiplatform_v1-0.10.0/lib/google/apis/aiplatform_v1/service.rb:13319:in `stream_project_location_publisher_model_generate_content'
- Dominant language
- Ruby
- Stars
- 2.9k
- Forks
- 888
- Avg merge
- 8m
- Merged PRs (30d)
- 242
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from googleapis/google-api-ruby-client
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
googleapis/google-api-ruby-client#28001 · 5 reactions ·
Maintainers usually reply within 1 day
-
googleapis/google-api-ruby-client#27757 · 1 assignee ·
Maintainers usually reply within 1 day
-
google-apis-core: CompositeIO does not maintain the IO read contractPossibly taken @torreypayne claimed this 4 days ago. Open
googleapis/google-api-ruby-client#27758 · 1 assignee ·
Maintainers usually reply within 1 day
-
google-apis-core: singular PagedResults ignores maxPossibly taken @torreypayne claimed this 4 days ago. Open
googleapis/google-api-ruby-client#27759 · 1 assignee ·
Maintainers usually reply within 1 day
-
api: storage type: feature request
Difficulty 3/5 1-2 days Newbie friendliness 55/100
googleapis/google-api-ruby-client#27339 ·
Maintainers usually reply within 1 day
All issues in googleapis/google-api-ruby-client
Similar issues
-
security
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
solana-foundation/pay-kit#341 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
julienXX/terminal-notifier#333 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
serhii-londar/open-source-mac-os-apps#1419 ·
Maintainers usually reply within 5 days