Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions examples/attachment-demo-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ When users send you attachments, analyze them carefully and provide helpful, det

For images: Describe what you see in detail.
For documents: Analyze and summarize the content, structure, or data as appropriate.
Supported document types: DOCX, XLSX, CSV, TXT, JSON, ZIP files.`,
Supported document types: PDF, DOCX, XLSX, CSV, TXT, JSON, ZIP files.`,
modelConfig: {
name: 'claude-sonnet-4',
temperature: 0.7,
Expand Down Expand Up @@ -144,6 +144,48 @@ server.start().then(() => {
]
}'\n`);

console.log('5.5. PDF document:');
console.log(`curl -X POST http://localhost:3002/chat \\
-H "Content-Type: application/json" \\
-d '{
"agentName": "attachment-analyst",
"messages": [
{
"role": "user",
"content": "Please analyze this PDF document",
"attachments": [
{
"kind": "document",
"mimeType": "application/pdf",
"name": "sample-document.pdf",
"url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
}
]
}
]
}'\n`);

console.log('5.6. PDF with base64 data:');
console.log(`curl -X POST http://localhost:3002/chat \\
-H "Content-Type: application/json" \\
-d '{
"agentName": "attachment-analyst",
"messages": [
{
"role": "user",
"content": "Extract text from this PDF document",
"attachments": [
{
"kind": "document",
"mimeType": "application/pdf",
"name": "test-document.pdf",
"data": "JVBERi0xLjQKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9LaWRzIFsgMyAwIFIgXQovQ291bnQgMQo+PgplbmRvYmoKMyAwIG9iago8PAovVHlwZSAvUGFnZQovUGFyZW50IDIgMCBSCi9NZWRpYUJveCBbIDAgMCA2MTIgNzkyIF0KL1Jlc291cmNlcyA8PAovRm9udCA8PAovRjEgNCAwIFIKPj4KPj4KL0NvbnRlbnRzIDUgMCBSCj4+CmVuZG9iago0IDAgb2JqCjw8Ci9UeXBlIC9Gb250Ci9TdWJ0eXBlIC9UeXBlMQovQmFzZUZvbnQgL0hlbHZldGljYQo+PgplbmRvYmoKNSAwIG9iago8PAovTGVuZ3RoIDQ0Cj4+CnN0cmVhbQpCVApxCjcyIDcwMCBUZAovRjEgMTIgVGYKKEhlbGxvLCBQREYgV29ybGQhKSBUagpFVApRCmVuZHN0cmVhbQplbmRvYmoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDEwIDAwMDAwIG4gCjAwMDAwMDAwNzkgMDAwMDAgbiAKMDAwMDAwMDE3MyAwMDAwMCBuIAowMDAwMDAwMzAxIDAwMDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAovU2l6ZSA2Ci9Sb290IDEgMCBSCj4+CnN0YXJ0eHJlZgo0NzQKJSVFT0Y="
}
]
}
]
}'\n`);

console.log('6. CSV data:');
console.log(`curl -X POST http://localhost:3002/chat \\
-H "Content-Type: application/json" \\
Expand Down Expand Up @@ -286,7 +328,7 @@ server.start().then(() => {
console.log('Configuration:');
console.log('- Use Ctrl+C to stop the server');
console.log('- Image attachments: Full visual analysis');
console.log('- Document attachments: Text extraction and analysis for DOCX, XLSX, CSV, TXT, JSON, ZIP');
console.log('- Document attachments: Text extraction and analysis for PDF, DOCX, XLSX, CSV, TXT, JSON, ZIP');
console.log('- LiteLLM format: Use "useLiteLLMFormat": true for efficient large file processing');
console.log(' * Large documents: No context window waste, native model processing');
console.log(' * Better layout understanding, tables, images preserved');
Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module.exports = {
],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
'^pdfjs-dist/legacy/build/pdf\\.mjs$': '<rootDir>/src/__mocks__/pdfjs-dist.ts',
'^canvas$': '<rootDir>/src/__mocks__/canvas.ts',
},
collectCoverageFrom: [
'src/**/*.ts',
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,15 @@
"@modelcontextprotocol/sdk": "^1.17.4",
"@types/yauzl": "^2.10.3",
"ai": "^5.0.35",
"canvas": "^3.2.0",
"eventsource": "^2.0.2",
"express": "^4.18.2",
"fastify": "^4.29.1",
"mammoth": "^1.10.0",
"mathjs": "^14.6.0",
"openai": "^4.0.0",
"papaparse": "^5.5.3",
"pdfjs-dist": "^5.4.149",
"tunnel": "^0.0.6",
"uuid": "^9.0.0",
"xlsx": "^0.18.5",
Expand Down
Loading