mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 23:24:21 +00:00
fix(agent): block non-pdf assets in read_pdf_pages and remove mediaType fallback in AgentChatPromptBuilder
This commit is contained in:
@@ -49,6 +49,7 @@ describe('readPdfPagesTool', () => {
|
||||
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
||||
id: 'asset-1',
|
||||
projectId: 'project-1',
|
||||
media: { proxyType: 'pdf' },
|
||||
} as unknown as Asset)
|
||||
|
||||
vi.mocked(prisma.assetComment.findUnique).mockResolvedValue({
|
||||
@@ -167,4 +168,36 @@ describe('readPdfPagesTool', () => {
|
||||
text: 'Asset with ID asset-1 not found.',
|
||||
})
|
||||
})
|
||||
|
||||
it('should return error text if proxyType is not pdf', async () => {
|
||||
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
||||
id: 'asset-1',
|
||||
projectId: 'project-1',
|
||||
media: { proxyType: 'image' },
|
||||
} as unknown as Asset)
|
||||
|
||||
const tool = createReadPdfPagesTool('asset-1')
|
||||
const result = await tool.execute('call-1', { start: 1, end: 3 })
|
||||
|
||||
expect(result.content[0]).toEqual({
|
||||
type: 'text',
|
||||
text: 'Asset asset-1 is not a PDF or document.',
|
||||
})
|
||||
})
|
||||
|
||||
it('should return error text if proxyType is null/undefined (unprocessed)', async () => {
|
||||
vi.mocked(prisma.asset.findUnique).mockResolvedValue({
|
||||
id: 'asset-1',
|
||||
projectId: 'project-1',
|
||||
media: null,
|
||||
} as unknown as Asset)
|
||||
|
||||
const tool = createReadPdfPagesTool('asset-1')
|
||||
const result = await tool.execute('call-1', { start: 1, end: 3 })
|
||||
|
||||
expect(result.content[0]).toEqual({
|
||||
type: 'text',
|
||||
text: 'Asset asset-1 is not a PDF or document.',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user