-
Notifications
You must be signed in to change notification settings - Fork 14
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
Support for Azure OpenAI API #212
Conversation
Thanks for the PR! I'll do a quick review -- Have you tested it? I think I see some syntax issues, so I doubt it would actually run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look at the changes if it makes sense!
Once you make the necessary changes, please test it and request a new review :)
Looks good to me -- in an ideal scenario, I'd prefer to resolve the OpenAI bug first and update this implementation, but are you in a rush to get going on your projects? I think we could merge it as is if you have immediate use cases. |
Before we merge, could you please confirm that you've tried both the chat & embedding functionality and that they work? (We no longer use Azure directly, so I cannot test it myself) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #212 +/- ##
==========================================
- Coverage 91.66% 91.54% -0.12%
==========================================
Files 46 46
Lines 4415 4425 +10
==========================================
+ Hits 4047 4051 +4
- Misses 368 374 +6 ☔ View full report in Codecov by Sentry. |
@svilupp I have applied the changes. There's something, which I would like to know your opinion about: The base url for an Azure LLM is as long as Also how about refactoring |
Interesting thought. My immediate reaction would be: 1) how would you know the resource name? and 2) isn't it harder to debug/share with Python and other services if we do things under the hood? Lastly, you say it's always that address pattern, but, actually, for corporates there can be a lot of customization in the paths if requested (esp. with proxying for measuring consumption, adding internal content filters, etc.). All in all, I'd probably stick to separating HOST vs PATH and am not sure if investing in refactoring that would yield any large benefits? Isn't it better to spend time building something with the API?
|
I have tested it and it works: julia> msg = aigenerate(PT.AzureOpenAISchema(), PT.AITemplate(:AssistantAsk); ask="What is the capital of France?", model="gpt-4o-2")
[ Info: Tokens: 54 in 0.8 seconds
AIMessage("Paris.") and julia> text_to_embed = "The concept of artificial intelligence."
julia> msg = aiembed(PT.AzureOpenAISchema(), text_to_embed; model="text-embedding-ada-002")
[ Info: Tokens: 6 @ Cost: $0.0 in 0.4 seconds
PromptingTools.DataMessage(JSON3.Array{Float64, Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}} of size (1536,)) |
I guess... Then maybe it would be better make the user include
or how exactly should
mmm I am talking about separating the different functions in several files, which is a 30-minute effort. For me having a file with so many lines made the implementation of the support for Azure OpenAI more difficult. |
I am actually in a rush to use the Azure OpenAI functionality. |
Added
AZURE_OPENAI_API_KEY
andAZURE_OPENAI_ENDPOINT
(i.e.https://<resource-name>.openai.azure.com
).