Skip to content

Support referencing file_ids previously uploaded to model providers.Β #2574

@tarruda

Description

@tarruda

Description

OpenAI supports uploading files to its files api, which can then be referenced by file_id when calling the inference endpoints that accept the messages property:

Image

Some other providers such as Google support similar APIs :https://ai.google.dev/api/files

This feature is useful because it avoids having to re-upload images or documents in multi-turn conversations.

Looking at the _map_user_prompt function, it is clear that PydanticAI doesn't currently support this feature and provides no way to use it (such as allowing custom message content to be added when calling inference endpoint).

I would like to contribute this to PydanticAI and have two questions:

  • Would this be a desirable contribution?
  • What would be the recommended strategy to support this in a cross-provider way? My first instinct is to add a new UserContent type (FileId, or FileReference) which would then be handled in _map_user_prompt for OpenAIModel.

References

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions