Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Cognitive Account support #104

Open
brenwell opened this issue Oct 31, 2024 · 1 comment
Open

Azure Cognitive Account support #104

brenwell opened this issue Oct 31, 2024 · 1 comment

Comments

@brenwell
Copy link

brenwell commented Oct 31, 2024

Hello everyone.

I am trying to use this library with Azure's Cognitive OpenAi deployment. I am new to this stuff but after creating my openai resource and deployment it appears that the endpoint does not quite align with this libraries expectations. Is this an issue with me using the wrong type of resource or is this just something the lib doesn't support. Thanks :)

Here is my Terraform resource

resource "azurerm_resource_group" "oa-rg" {
  name     = "oa_rg"
  location = "francecentral"
}

resource "azurerm_cognitive_account" "openai" {
  name                = "openai"
  location            = azurerm_resource_group.oa-rg.location
  resource_group_name = azurerm_resource_group.oa-rg.name
  kind                = "OpenAI"
  sku_name            = "S0"
}

resource "azurerm_cognitive_deployment" "openai_gpt_4" {
  name                 = "openai-gpt-4"
  cognitive_account_id = azurerm_cognitive_account.openai.id

  model {
    format  = "OpenAI"
    name    = "gpt-4"
    version = "0613"
  }

  sku {
    name = "Standard"
  }
}

this results in the following endpoint

azure_openai_endpoint = "https://francecentral.api.cognitive.microsoft.com/"

This is my application code

package resource

import (
	"github.com/openai/openai-go"
	"github.com/openai/openai-go/azure"
)

func InitOpenai() *openai.Client {
	const azureOpenAIEndpoint = "https://francecentral.api.cognitive.microsoft.com"
	const azureOpenAIAPIVersion = "2024-08-01-preview"

	client := openai.NewClient(
		azure.WithEndpoint(azureOpenAIEndpoint, azureOpenAIAPIVersion),
		azure.WithAPIKey("<masked>"),
	)

	return client
}

This returns

"ChatCompletion error: POST \"https://francecentral.api.cognitive.microsoft.com/openai/chat/completions?api-version=2024-08-01-preview\": 404 Not Found 
{\"error\":
{\"code\":\"DeploymentNotFound\", 
\"message\":\"The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.\"}}\n",
@jacobzim-stl
Copy link
Collaborator

Hi I'm not sure if I can help debug this much, I might need a bit more information. If you're able to get a successful request manually that would be very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants