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

Jsburckhardt/287 azure openai list models #290

Conversation

jsburckhardt
Copy link
Contributor

what

  • feat(models): include flow for listing models with azure openai endpoint

why

how to test

  • go test
    image

  • or run test TestAzureListModels
    image

@codecov
Copy link

codecov bot commented Apr 30, 2023

Codecov Report

Merging #290 (c446225) into master (af9ff51) will increase coverage by 0.49%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #290      +/-   ##
==========================================
+ Coverage   92.43%   92.93%   +0.49%     
==========================================
  Files          22       22              
  Lines         661      665       +4     
==========================================
+ Hits          611      618       +7     
+ Misses         36       35       -1     
+ Partials       14       12       -2     
Impacted Files Coverage Δ
client.go 91.34% <100.00%> (+3.34%) ⬆️

... and 1 file with indirect coverage changes

@sashabaranov
Copy link
Owner

sashabaranov commented May 1, 2023

@jsburckhardt thank you for the PR! I wonder if this is covered by the logic in the fullURL? If not, maybe we should improve the fullURL

go-openai/client.go

Lines 102 to 108 in af9ff51

// /openai/deployments/{engine}/chat/completions?api-version={api_version}
if c.config.APIType == APITypeAzure || c.config.APIType == APITypeAzureAD {
baseURL := c.config.BaseURL
baseURL = strings.TrimRight(baseURL, "/")
return fmt.Sprintf("%s/%s/%s/%s%s?api-version=%s",
baseURL, azureAPIPrefix, azureDeploymentsPrefix, c.config.Engine, suffix, c.config.APIVersion)
}

@jsburckhardt
Copy link
Contributor Author

I'll give it a shot updating fullURL, the thing is the URL/API changes between /models and /completions and fullURL isn't aware of the service that is getting called. Leave it with me I'll check what I can do.
completions-> {endpoint}/openai/deployments/{engine}/chat/completions?api-version={api_version}
models -> {endpoint}/openai/models?api-version=2022-12-01

@sashabaranov
Copy link
Owner

@jsburckhardt got it! ThefullURL knows about what endpoint is passed to it, so we can make a special case there

@jsburckhardt
Copy link
Contributor Author

@sashabaranov updated by adding some logic into the fullURL, should be ok now. Let me know ;)

client.go Outdated Show resolved Hide resolved
Copy link
Owner

@sashabaranov sashabaranov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@sashabaranov sashabaranov merged commit 104c0c0 into sashabaranov:master May 3, 2023
@jsburckhardt jsburckhardt deleted the jsburckhardt/287-azure-openai-list-models branch July 17, 2023 01:06
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

Successfully merging this pull request may close these issues.

2 participants