Coder Social home page Coder Social logo

Add Vertex AI samples about php-docs-samples HOT 5 CLOSED

cselti avatar cselti commented on August 11, 2024
Add Vertex AI samples

from php-docs-samples.

Comments (5)

yash30201 avatar yash30201 commented on August 11, 2024 1

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

from php-docs-samples.

shivgautam avatar shivgautam commented on August 11, 2024

Does this example help? https://github.com/googleapis/google-cloud-php-ai-platform/blob/main/src/V1/Gapic/PredictionServiceGapicClient.php#L614-L623

from php-docs-samples.

cselti avatar cselti commented on August 11, 2024

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
....

from php-docs-samples.

yash30201 avatar yash30201 commented on August 11, 2024

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.'])]

from php-docs-samples.

cselti avatar cselti commented on August 11, 2024

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?

from php-docs-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.