mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-01 21:44:27 +00:00
feat(agent): enable read_asset tool for autofill agent (#396)
* feat(agent): enable read_asset tool for autofill agent * fix(transcode): trigger autofill task for pdf assets * fix(transcode): allow autofill task creation on all file assets * fix(agent): require targetAssetId and teamId for autofill read_asset authorization * feat(agent): instruct autofill agent to report failure directly if read_asset fails
This commit is contained in:
@@ -112,6 +112,7 @@ export interface CreateAgentSessionParams {
|
||||
sessionId?: string
|
||||
userId?: string
|
||||
projectId?: string
|
||||
assetId?: string
|
||||
userCommentId?: string | null
|
||||
customTools?: AgentTool[]
|
||||
thinkingLevel?: string
|
||||
@@ -149,6 +150,7 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
|
||||
sessionId,
|
||||
userId,
|
||||
projectId,
|
||||
assetId,
|
||||
userCommentId: passedUserCommentId,
|
||||
customTools = [],
|
||||
thinkingLevel,
|
||||
@@ -316,17 +318,25 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
|
||||
}
|
||||
}
|
||||
|
||||
const mediaTools: AgentTool[] = []
|
||||
if (userId) {
|
||||
mediaTools.push(createReadAssetTool(userId))
|
||||
}
|
||||
|
||||
const agent = await prisma.agent.findUnique({
|
||||
where: { id: agentId },
|
||||
})
|
||||
const agentConfig = agent?.config as PrismaJson.AgentConfig | null | undefined
|
||||
const deniedTools = agentConfig?.deniedTools ?? [...DEFAULT_DENIED_TOOLS]
|
||||
|
||||
const mediaTools: AgentTool[] = []
|
||||
if (userId) {
|
||||
mediaTools.push(createReadAssetTool(userId))
|
||||
} else if (agent?.type === 'autofill' && assetId) {
|
||||
mediaTools.push(
|
||||
createReadAssetTool({
|
||||
teamId,
|
||||
agentType: 'autofill',
|
||||
targetAssetId: assetId,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
if (!deniedTools.includes('generate_image') || !deniedTools.includes('generate_video')) {
|
||||
try {
|
||||
const { imageModels, videoModels, providerKeys } =
|
||||
|
||||
Reference in New Issue
Block a user