问题
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"
},
}
}'
回答1:
Here you go! and please check the full repo.
https://github.com/googleapis/nodejs-vision/blob/master/samples/automl/automlVisionPredict.js
来源:https://stackoverflow.com/questions/53907340/is-there-a-way-to-use-googles-automl-with-javascript