Summarize how the changes in this PR work
- User
Summarize how the changes in this PR work
- Assistant
This PR introduces in-context document support for Anthropic and Google endpoints, allowing users to upload and use documents (such as PDFs) and other file types in the chat context. Below is a summary of how the changes in the PR work:
New Features
-
Anthropic Endpoint:
- Adds support for PDF files.
- Restricts PDF support to the Claude 3.5 Sonnet family of models.
- Estimates token count for PDFs (set to ~2000 tokens per page due to lack of page count parsing).
-
Google Endpoint:
- Adds support for PDF files, text documents, audio files, and images.
- Defines supported MIME types for these files (e.g.,
application/pdf,audio/mp3, etc.).
Key Changes
1. File Handling Updates
-
encodeAndFormatfunction:- Generalized to handle files instead of just images.
- Handles different file types (e.g., PDFs, audio files) by encoding them into Base64 or preparing appropriate payloads.
- Introduces a new
file_urlsfield (replacingimage_urls) to store file-related metadata and content.
-
New MIME type handling:
- Added MIME type support for PDFs, audio files, and text files for Google.
- PDF-specific handling for Anthropic and Google endpoints.
-
Updated strategies:
- Adjusted file processing strategies (
prepareFilePayload) to support new file types and endpoints.
- Adjusted file processing strategies (
2. Endpoint-Specific Logic
-
Anthropic:
- Checks if the model supports PDFs (Claude 3.5 Sonnet family).
- Restricts file uploads to PDFs and images.
- Adds token cost estimation for PDFs based on a fixed page token count (~2000 tokens).
-
Google:
- Supports a broader range of file types (PDFs, text, audio, images).
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.