Closed cselti closed 9 months ago
Sadly, no, I have already checked everything in the client library's source code.
The problem is that the acceptable instance
structure has not been specified.
I have tried with the same structure as in the REST API or Node.js library (and those work, of course):
$instances = new Value(['prompt' => 'Give me ten interview questions for the role of program manager.']);
// or
$instances = new Value(['content' => 'Give me ten interview questions for the role of program manager.']);
// or
$instances = new Value(['text' => 'Give me ten interview questions for the role of program manager.']);
// or
$instances = new StringValue(['input' => 'Give me ten interview questions for the role of program manager.']);
// or
$instances = new Value(['input_text' => new StringValue('Give me ten interview questions for the role of program manager.')]);
// .....
I have got always like these:
Fatal error: Uncaught UnexpectedValueException: Invalid message property: content Fatal error: Uncaught UnexpectedValueException: Invalid message property: prompt Fatal error: Uncaught UnexpectedValueException: Invalid message property: text Fatal error: Uncaught UnexpectedValueException: Invalid message property: input ....
Hi @cselti ,
I see that the Value
is imported as Google\Protobuf\Value
(ref). Also observing that Ai Platform has defined it's own Value.php with possible options as string_value
, int_value
and double_value
.
Can you check if the following works for you?
$instances = [new Value(['string_value' => 'Give me ten interview questions for the role of program manager.'])]
Hi @yash30201 , Sadly not:
Call failed with message: {
"message": "Invalid instance: string_value: \t \"Give me ten interview questions for the role of program manager.\"\n",
"code": 3,
"status": "INVALID_ARGUMENT",
"details": []
}
It was worked for you?
Hi @cselti , sorry for the delay.
So I tried to deploy a model and the send predict
requests. Following the way a model was queried in ruby, I replicated the syntax for PHP and it worked. Following is the crude way of creating a prediction request. You can extract the logic so that request making becomes easy.
$serializer = new Serializer();
$struct = $serializer->decodeMessage(new Struct(), ['fields' => ['prompt' => ['string_value' => 'Hi Model']]]);
$request = (new PredictRequest())
->setEndpoint($client->endpointName($projectId, $locationId, $endpointId))
->setInstances([
new Value(['struct_value' => $struct])
If you face connection timeout / deadline exceed error, you can just simply increase the timeout for predict
rpc according to your model's average end to end request times in the vendor/google/cloud-ai-platform/src/V1/resources/prediction_service_client_config.json
Please add some examples for the Vertex AI PHP client library.
Actually, I need a working example for the
predict
call in thePredictionServiceClient
.My problem is that it doesn't accept the
instances
input and I get the following error messages:I have tried with a following
instances
input with several combinations similar to this:I used
content
,prompt
,text
,input
,input_text
,input_string
,message
values, using aValue
with multiple level, usingStringValue
orStructValue
- nothing worked.I have checked the "samples" in the client library, but it uses only empty
[new Value()]
that it throws anEmpty instancis
INVALID_ARGUMENT
error response.I have checked the NodeJS client library (which is quite similar to the PHP client library) and it's worked correctly. I searched on the internet, of course, but I found only 2 examples and none of them worked.
I know that I can use the REST API too, but I prefer the client library because of the built-in authentication, error handling, etc.
Thanks in advance.