为什么我访问 googleapis.com/v1/projects chat-bison@001:predict 时会得到 404 错误?

huangapple go评论54阅读模式
英文:

Why do I get a 404 for googleapis.com/v1/projects chat-bison@001:predict?

问题

I'm using the example curl I get from:

https://console.cloud.google.com/vertex-ai/generative/language/my-prompts/create/text?authuser=2&project=my-app

为什么我访问 googleapis.com/v1/projects chat-bison@001:predict 时会得到 404 错误?

https://us-central1-aiplatform.googleapis.com/v1/projects/my-app/locations/us-central1/publishers/google/chat-bison@001:predict

但是每次都返回404错误。我有正确的Bearer授权令牌。似乎一切都正确,但为什么会出现404错误?

英文:

I'm using the example curl I get from:

https://console.cloud.google.com/vertex-ai/generative/language/my-prompts/create/text?authuser=2&project=my-app

为什么我访问 googleapis.com/v1/projects chat-bison@001:predict 时会得到 404 错误?

https://us-central1-aiplatform.googleapis.com/v1/projects/my-app/locations/us-central1/publishers/google/chat-bison@001:predict

but I get a 404 everytime. I have the right Bearer auth token. Everything seems to be correct but 404!

答案1

得分: 3

以下是已翻译的内容:

构建的URL显然不正确。

  1. 模型应该是 text-bison(不带 @001
  2. URL "template" 应该是 https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:predict(缺少了 /models

总之:

API_ENDPOINT="us-central1-aiplatform.googleapis.com"
PROJECT_ID="<projectID>"
MODEL_ID="text-bison"

curl \
-X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:predict" -d \
'{
  "instances": [
    {
      "content": "Write a short poem:"
    }
  ],
  "parameters": {
    "temperature": 0.2,
    "maxOutputTokens": 256,
    "topP": 0.8,
    "topK": 40
  }
}'

来源:https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/api-quickstart

英文:

The built URL apparently is incorrect.

  1. The model is supposed to be text-bison (without the @001)
  2. The URL "template" is supposed to be https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:predict (/models was missing)

All in all:

API_ENDPOINT=&quot;us-central1-aiplatform.googleapis.com&quot;
PROJECT_ID=&quot;&lt;projectID&gt;&quot;
MODEL_ID=&quot;text-bison&quot;

curl \
-X POST \
-H &quot;Authorization: Bearer $(gcloud auth print-access-token)&quot; \
-H &quot;Content-Type: application/json&quot; \
&quot;https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:predict&quot; -d \
$&#39;{
  &quot;instances&quot;: [
    {
      &quot;content&quot;: &quot;Write a short poem:&quot;
    }
  ],
  &quot;parameters&quot;: {
    &quot;temperature&quot;: 0.2,
    &quot;maxOutputTokens&quot;: 256,
    &quot;topP&quot;: 0.8,
    &quot;topK&quot;: 40
  }
}&#39;

Source: https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/api-quickstart

huangapple
  • 本文由 发表于 2023年5月15日 02:01:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76248975.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定