0

I trained a model using AutoML Natural Language on Googles Cloud Platform. Now i need to call the AI via JavaScript to do a sentiment analysis, using my own model.

My goal is to embed the whole thing into a website. There i'll have a input form to analyze text. That's all for now actually.

I wasn't able to find anything relating that use case when i did my research. Google provides a REST API but there is literally no tutorial on how to handle it.

Sorry, I know this might not meet the stackoverflow requirements for a question. But I'm totally puzzled.

This is what the REST API looks like:

export GOOGLE_APPLICATION_CREDENTIALS=key-file-path

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
  -H "Content-Type: application/json" \
  https://automl.googleapis.com/v1beta1/projects/*myProjectID/locations/us-central1/models/*myModelID*:predict \
  -d '{
        "payload" : {
          "textSnippet": {
               "content": "YOUR TEXT HERE",
                "mime_type": "text/plain"
           },
        }
      }'
Moritz
  • 25
  • 4

1 Answers1

1

Here you go! and please check the full repo.

https://github.com/googleapis/nodejs-vision/blob/master/samples/automl/automlVisionPredict.js

Bira
  • 4,531
  • 2
  • 27
  • 42
  • Hey! yes actually I was able to kinda do what i intended to do using the code provided there. Still there are plenty of bugs. But i guess it's still a demo! – Moritz Jan 19 '19 at 21:07