Skip to content

Conversation

@dimitry12
Copy link

Support optional mime_type in dspy.File.from_file_id.

The main effect of this is: LiteLLM will not attempt to download file from file_id to determine its format.

This is critical when using Google Gemini and its Files API, because prior to this change the flow for multi-modal context was:

  • use Files API to upload files;
  • use each file's .uri as file_id and instantiate dspy.File.from_file_id which is then converted/"adaptered" into LiteLLM-schema dict,
  • but LiteLLM attempts to determine format by downloading the file from URL contained in file_id. This is not possible because Google Gemini Files API is write-only, and the whole generation fails.

With this change we can pass Files API URIs as file_id and we can now provide optional mime_type explicitly:

dspy.File.from_file_id(f.uri, mime_type=f.mime_type)

preventing LiteLLM from attempting to download the file.

This change addresses:

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.

1 participant