feat: implement Anthropic native PDF support with document preservation

- Add comprehensive debug logging throughout PDF processing pipeline
- Refactor attachment processing to separate image and document handling
- Create distinct addImageURLs(), addDocuments(), and processAttachments() methods
- Fix critical bugs in stream handling and parameter passing
- Add streamToBuffer utility for proper stream-to-buffer conversion
- Remove api/agents submodule from repository

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andres Restrepo 2025-08-10 13:25:25 -05:00
parent 007570b5c6
commit 6605b6c800
53 changed files with 630 additions and 145 deletions

View file

@ -239,13 +239,13 @@ export function mapModelToAzureConfig({
const { deploymentName = '', version = '' } =
typeof modelDetails === 'object'
? {
deploymentName: modelDetails.deploymentName ?? groupConfig.deploymentName,
version: modelDetails.version ?? groupConfig.version,
}
deploymentName: modelDetails.deploymentName ?? groupConfig.deploymentName,
version: modelDetails.version ?? groupConfig.version,
}
: {
deploymentName: groupConfig.deploymentName,
version: groupConfig.version,
};
deploymentName: groupConfig.deploymentName,
version: groupConfig.version,
};
if (!deploymentName || !version) {
throw new Error(
@ -335,13 +335,13 @@ export function mapGroupToAzureConfig({
const { deploymentName = '', version = '' } =
typeof modelDetails === 'object'
? {
deploymentName: modelDetails.deploymentName ?? groupConfig.deploymentName,
version: modelDetails.version ?? groupConfig.version,
}
deploymentName: modelDetails.deploymentName ?? groupConfig.deploymentName,
version: modelDetails.version ?? groupConfig.version,
}
: {
deploymentName: groupConfig.deploymentName,
version: groupConfig.version,
};
deploymentName: groupConfig.deploymentName,
version: groupConfig.version,
};
if (!deploymentName || !version) {
throw new Error(

View file

@ -169,6 +169,10 @@ export const megabyte = 1024 * 1024;
export const mbToBytes = (mb: number): number => mb * megabyte;
const defaultSizeLimit = mbToBytes(512);
// Anthropic PDF limits: 32MB max, 100 pages max
export const anthropicPdfSizeLimit = mbToBytes(32);
const assistantsFileConfig = {
fileLimit: 10,
fileSizeLimit: defaultSizeLimit,
@ -182,6 +186,14 @@ export const fileConfig = {
[EModelEndpoint.assistants]: assistantsFileConfig,
[EModelEndpoint.azureAssistants]: assistantsFileConfig,
[EModelEndpoint.agents]: assistantsFileConfig,
[EModelEndpoint.anthropic]: {
fileLimit: 10,
fileSizeLimit: defaultSizeLimit,
totalSizeLimit: defaultSizeLimit,
supportedMimeTypes,
disabled: false,
pdfSizeLimit: anthropicPdfSizeLimit,
},
default: {
fileLimit: 10,
fileSizeLimit: defaultSizeLimit,