gptscript-ai / gptscript

Build AI assistants that interact with your systems
https://gptscript.ai
Apache License 2.0
2.99k stars 261 forks source link

Cannot connect to Azure OpenAI deployment #59

Closed sirredbeard closed 7 months ago

sirredbeard commented 7 months ago

I am unable to connect gptscript to Azure's implementation of OpenAI.

I have a gpt 3.5 turbo deployment on Azure OpenAI named, coincidentally enough, gpt-35-turbo.

It is reachable with:

curl https://<endpoint>.openai.azure.com/openai/deployments/gpt-35-turbo/completions?api-version=2023-05-15 -H "Content-Type: application/json"   -H "api-key: <key>"   -d "{
  \"prompt\": \"Once upon a time\",
  \"max_tokens\": 5
}"

and returns, for example:

{"id":"cmpl-8uobBPlV6d0UDqVFPwQdKEkZJaGgl","object":"text_completion","created":1708551561,"model":"gpt-35-turbo","choices":[{"text":" on a small island,","index":0,"finish_reason":"length","logprobs":null}],"usage":{"prompt_tokens":4,"completion_tokens":5,"total_tokens":9}}

With gptscript, I am running:

.\main.exe "https://get.gptscript.ai/echo.gpt" --input 'Hello, World!' --openai-api-key '<key>' --openai-api-type 'AZURE' --openai-base-url 'https://<endpoint>.openai.azure.com/openai/deployments/gpt-35-turbo/completions' --openai-api-version '2023-05-15'

and getting:

16:45:22 started  [main] [input=--input Hello, World! --openai-api-key <key> --openai-api-type AZURE --openai-base-url https://<endpoint>.openai.azure.com/openai/deployments/gpt-35-turbo/completions --openai-api-version 2023-05-15]
16:45:22 sent     [main]
         content  [1] content | Waiting for model response...2024/02/21 16:45:22 error, status code: 404, message: Resource not found

I can reproduce the same on Linux:

export OPENAI_API_KEY="<key>"
export OPENAI_API_TYPE="AZURE"
export OPENAI_BASE_URL="https://<endpoint>.openai.azure.com/openai/deployments/gpt-35-turbo/completions"
export OPENAI_API_VERSION="2023-05-15"
gptscript "https://get.gptscript.ai/echo.gpt" --input 'Hello, World!' --debug

Gets:

16:51:33 started  [main] [input=--input Hello, World! --debug]
16:51:33 sent     [main]
         content  [1] content | Waiting for model response...2024/02/21 16:51:33 error, status code: 404, message: Resource not found
sirredbeard commented 7 months ago

Closing this in favor of #43, Azure support is WIP