Skip to content

Conversation

yifan1207
Copy link
Collaborator

@yifan1207 yifan1207 commented Aug 8, 2025

  • add azure openai and azure async openi support
  • add ollama support (no cost calcualtion support though)

Copy link

linear bot commented Aug 8, 2025

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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

  1. 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.

@yifan1207 yifan1207 marked this pull request as draft August 8, 2025 05:19
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@yifan1207 yifan1207 changed the title Azure + Langchian support (JUD-1713) Azure + Ollama support (JUD-1713) Aug 9, 2025
@yifan1207 yifan1207 marked this pull request as ready for review August 10, 2025 00:17
@alanzhang25 alanzhang25 self-requested a review August 12, 2025 17:01
Copy link
Collaborator

@alanzhang25 alanzhang25 left a 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.

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
Copy link
Collaborator

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

Copy link
Collaborator Author

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')
Copy link
Collaborator

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

Copy link
Collaborator Author

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?

Comment on lines +2208 to +2209
prompt_tokens = getattr(response, 'prompt_eval_count', None) or 0
completion_tokens = getattr(response, 'eval_count', None) or 0
Copy link
Collaborator

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?

Copy link
Collaborator Author

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
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yess. will do

@alanzhang25 alanzhang25 self-assigned this Aug 12, 2025
@alanzhang25 alanzhang25 added the In Review Task is currently being reviewed label Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Review Task is currently being reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants