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

Vertex API (gemini-pro model) undefined method `has_key?' for ... #17071

Open
mazenkhalil opened this issue Dec 28, 2023 · 0 comments
Open

Vertex API (gemini-pro model) undefined method `has_key?' for ... #17071

mazenkhalil opened this issue Dec 28, 2023 · 0 comments

Comments

@mazenkhalil
Copy link

mazenkhalil commented Dec 28, 2023

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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant