-
Notifications
You must be signed in to change notification settings - Fork 86
Azure + Ollama support (JUD-1713) #505
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
base: staging
Are you sure you want to change the base?
Conversation
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.
Summary of Changes
Hello @yifan1207, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
I've implemented support for Azure OpenAI and Azure Async OpenAI within our tracing system. This enhancement allows us to capture and log interactions with Azure-hosted OpenAI models, ensuring comprehensive visibility into AI-driven processes that leverage Microsoft's cloud infrastructure. While the PR description also mentioned Langchain support, the changes primarily focus on integrating Azure OpenAI capabilities.
Highlights
- Azure OpenAI Client Support: I've extended the tracing functionality to include support for both Azure OpenAI and Azure Async OpenAI clients. This means that interactions with these services will now be properly captured and logged.
- Enhanced Client Configuration: I've updated the internal client configuration logic to correctly identify and process requests originating from Azure OpenAI clients, ensuring they are handled appropriately within the tracing system.
- Output Data Formatting for Azure OpenAI: To provide clearer insights, I've modified the output data formatting. Now, responses from Azure OpenAI models will be explicitly marked with "(azure-openai)" in their model names, making it easier to differentiate them in logs and reports.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request adds support for Azure OpenAI and Azure Async OpenAI clients to the tracer. The changes correctly patch the client methods to enable tracing for Azure-based calls.
I've identified a few areas with code duplication that could be refactored to improve maintainability. Specifically, the configuration logic for synchronous and asynchronous Azure clients in _get_client_config
is identical and can be combined. Similarly, the logic to prefix the model name for Azure clients in _format_output_data
is repeated and could be consolidated.
The PR title and description also mention Langchian support, but I don't see any related changes in this diff. Could you clarify if that's part of a different PR or if I'm missing something?
Overall, the changes for Azure support look good, with a few opportunities for cleanup.
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.
can you add these clients to the e2etest in tracer test?
also i dont think ollama token tracking makes sense since its local inference.
src/judgeval/common/tracer/core.py
Outdated
model_name = response.model | ||
#added this to diff openai vs azure openai dont know if needed though | ||
if isinstance(client, (openai_AzureOpenAI, openai_AsyncAzureOpenAI)): | ||
model_name = "(azure-openai)" + response.model |
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.
the model_name is used for calculating cost for litellm? you should check if the pricing differs
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.
I think the issue is azaure does not show its pricing since its mostly enterprise contracts and the compute units based. So I think the best way might be just to use the openai cost as an estimate? or maybe just dont show it
assert ollama_Client is not None, "Ollama Client not found" | ||
assert ollama_AsyncClient is not None, "Ollama Async Client not found" | ||
if isinstance(client, (ollama_Client, ollama_AsyncClient)): | ||
model_name = "ollama/" + getattr(response, 'model', 'unknown') |
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.
same here, check if litellm supports olama cost checking and if this is how they format the names for diff models
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.
I think this is a similar issue I think to calculate ollama costs we'd need the user to return their compute usage but by defualt ollama does not return that. let me remove this. maybe we can default to N/A?
prompt_tokens = getattr(response, 'prompt_eval_count', None) or 0 | ||
completion_tokens = getattr(response, 'eval_count', None) or 0 |
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.
ollama labels their tokens like this?
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.
yes
ollama_AsyncClient = None | ||
|
||
try: | ||
from ollama import Client, AsyncClient, chat |
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.
can delete chat right? github lint failing
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.
yess. will do
Uh oh!
There was an error while loading. Please reload this page.