Skip to content

Conversation

Lin-Nikaido
Copy link

@Lin-Nikaido Lin-Nikaido commented Sep 5, 2025

Fixes #2862

This fixes

  • When with attached file request, upload file and get file_id from openAI.
  • Then perse llm requests for litellm correctry with file_id not file_data.

Add test code in tests/unittests/models/test_litellm.py and it passed.
image

Copy link

@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 @Lin-Nikaido, 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!

This pull request resolves an issue preventing attached files from being correctly sent to OpenAI via LiteLLM. The changes enable asynchronous file uploads for OpenAI and Azure, allowing files to be referenced by a file_id after upload, which is a more efficient and compatible method for these providers. The existing behavior for other LLM providers, where files are sent as base64 encoded data, is maintained.

Highlights

  • Asynchronous File Handling: Converted key internal functions (_content_to_message_param, _get_content, _get_completion_inputs) to asynchronous operations to support file uploads and improve performance.
  • OpenAI/Azure File Upload via file_id: Implemented logic to upload attached files (e.g., PDFs, text files) to OpenAI/Azure using litellm.acreate_file and then reference them by their file_id in the LLM request, rather than embedding the raw file data.
  • Provider-Specific File Handling: Introduced a mechanism to identify the specific LLM provider (OpenAI, Azure, Gemini, etc.) and apply the appropriate file handling strategy, ensuring file_id is used for OpenAI/Azure and base64 data for others.
  • Expanded Supported File Types: Extended the range of supported file types for attachment to include various text, document (MS Word, PowerPoint), and code file formats.
  • Comprehensive Unit Tests: Added new unit tests specifically for the OpenAI file_id integration and updated existing tests to accommodate the new asynchronous functions and confirm correct file handling logic across different providers.
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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

@adk-bot adk-bot added bot triaged [Bot] This issue is triaged by ADK bot models [Component] Issues related to model support labels Sep 5, 2025
Copy link

@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 correctly implements file attachment handling for OpenAI models via LiteLLM by uploading the file to get a file_id. The necessary asynchronous changes and corresponding test updates are well-executed. I've identified a potential bug in the provider detection logic and an opportunity to improve code readability. The new tests effectively validate the implemented functionality.

Lin-Nikaido and others added 6 commits September 5, 2025 18:24
fix typo

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot triaged [Bot] This issue is triaged by ADK bot models [Component] Issues related to model support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot send attach file to OpenAI throw LiteLlm
2 participants