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
Hi, I've ben trying to use Gemini/Vertex(?) through this gem and it looks like its not the right way to do it.
I've used the sample Google docs (and samples here give):
# https://cloud.google.com/vertex-ai/docs/samples/aiplatform-sdk-ideation?hl=en#aiplatform_sdk_ideation-rubyrequire"google/cloud/ai_platform/v1"classGeminiApi::TestGemdefself.runputs"RUNNING"ENV['GOOGLE_APPLICATION_CREDENTIALS']='google-pie-vertex.json'new.predict_text_prompt(project_id: 'xxxxxxxxxx',model: 'gemini-2.0-flash-001',)end### Vertex AI Predict Text Prompt## @param project_id [String] Your Google Cloud project (e.g. "my-project")# @param location_id [String] Your Processor Location (e.g. "us-central1")# @param publisher [String] The Model Publisher (e.g. "google")# @param model [String] The Model Identifier (e.g. "text-bison@001")#defpredict_text_promptproject_id:,location_id: "us-central1",publisher: "google",model:
# Create the Vertex AI client.# TODO problem might be that we can't use the PredictionService?client= ::Google::Cloud::AIPlatform::V1::PredictionService::Client.newdo |config|
config.endpoint="#{location_id}-aiplatform.googleapis.com"end# Build the resource name from the project.endpoint=client.endpoint_path(project: project_id,location: location_id,publisher: publisher,model: model)prompt="Give me ten interview questions for the role of program manager."# Initialize the request argumentsinstance=Google::Protobuf::Value.new(struct_value: Google::Protobuf::Struct.new(fields: {"prompt"=>Google::Protobuf::Value.new(string_value: prompt)}))instances=[instance]parameters=Google::Protobuf::Value.new(struct_value: Google::Protobuf::Struct.new(fields: {"temperature"=>Google::Protobuf::Value.new(number_value: 0.2),"maxOutputTokens"=>Google::Protobuf::Value.new(number_value: 256),"topP"=>Google::Protobuf::Value.new(number_value: 0.95),"topK"=>Google::Protobuf::Value.new(number_value: 40)}))# Make the prediction requestresponse=client.predictendpoint: endpoint,instances: instances,parameters: parameters# Handle the prediction responseputs"Predict Response"putsresponseendend
And I am just getting:
/root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:29:in `check_status': 9:Gemini cannot be accessed through Vertex Predict/RawPredict API. Please follow https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/quickstart-multimodal for Gemini usage.. debug_error_string:{UNKNOWN:Error received from peer ipv4:142.251.36.106:443 {grpc_message:"Gemini cannot be accessed through Vertex Predict/RawPredict API. Please follow https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/quickstart-multimodal for Gemini usage.", grpc_status:9, created_time:"2025-03-03T08:43:45.299372088+00:00"}} (GRPC::FailedPrecondition)
from /root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:189:in `attach_status_results_and_complete_call'
from /root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:383:in `request_response'
from /root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/client_stub.rb:174:in `block (2 levels) in request_response'
from /root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/interceptors.rb:170:in `intercept!'
from /root/dev/app/.bundle/ruby/3.2.0/gems/grpc-1.70.1-x86_64-linux/src/ruby/lib/grpc/generic/client_stub.rb:173:in `block in request_response'
from /root/dev/app/.bundle/ruby/3.2.0/gems/gapic-common-0.23.0/lib/gapic/grpc/service_stub/rpc_call.rb:123:in `call'
from /root/dev/app/.bundle/ruby/3.2.0/gems/gapic-common-0.23.0/lib/gapic/grpc/service_stub.rb:205:in `call_rpc'
from /root/dev/app/.bundle/ruby/3.2.0/gems/google-cloud-ai_platform-v1-0.60.0/lib/google/cloud/ai_platform/v1/prediction_service/client.rb:292:in `predict'
from /root/dev/app/app/lib/gemini_api/test_gem.rb:65:in `predict_text_prompt'
from /root/dev/app/app/lib/gemini_api/test_gem.rb:10:in `run'
REST api through curl seems to work fine, so are we supposed to use the rest API through http libraries?
If that's the case thats fine but its pretty confusing not having this mentioned anywhere.
The text was updated successfully, but these errors were encountered:
Hi, I've ben trying to use Gemini/Vertex(?) through this gem and it looks like its not the right way to do it.
I've used the sample Google docs (and samples here give):
And I am just getting:
And it looks like this gem is not supposed to be used with that API?
And there is no ruby API for the new one as Ruby is not listed on the linked page:
https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/quickstart-multimodal
So what are we supposed to use?
REST api through curl seems to work fine, so are we supposed to use the rest API through http libraries?
If that's the case thats fine but its pretty confusing not having this mentioned anywhere.
The text was updated successfully, but these errors were encountered: