chore: remove attachments in system

This commit is contained in:
Acbox
2026-02-06 19:02:43 +08:00
parent ddb67c95f5
commit b600e78cb7
2 changed files with 3 additions and 35 deletions
+3 -12
View File
@@ -25,7 +25,7 @@ export const createAgent = ({
}: AgentParams, fetch: AuthFetcher) => {
const model = createModel(modelConfig)
const generateSystemPrompt = (attachmentPaths: string[] = []) => {
const generateSystemPrompt = () => {
return system({
date: new Date(),
language,
@@ -33,7 +33,6 @@ export const createAgent = ({
channels,
skills: [],
enabledSkills: [],
attachments: attachmentPaths,
})
}
@@ -44,12 +43,6 @@ export const createAgent = ({
identity,
})
const getInputAttachmentPaths = (input: AgentInput): string[] => {
return input.attachments
.filter((a): a is ContainerFileAttachment => a.type === 'file')
.map(a => a.path)
}
const generateUserPrompt = (input: AgentInput) => {
const images = input.attachments.filter(attachment => attachment.type === 'image')
const files = input.attachments.filter((a): a is ContainerFileAttachment => a.type === 'file')
@@ -73,8 +66,7 @@ export const createAgent = ({
const ask = async (input: AgentInput) => {
const userPrompt = generateUserPrompt(input)
const messages = [...input.messages, userPrompt]
const attachmentPaths = getInputAttachmentPaths(input)
const systemPrompt = generateSystemPrompt(attachmentPaths)
const systemPrompt = generateSystemPrompt()
const { response, reasoning, text, usage } = await generateText({
model,
messages,
@@ -167,8 +159,7 @@ export const createAgent = ({
async function* stream(input: AgentInput): AsyncGenerator<AgentAction> {
const userPrompt = generateUserPrompt(input)
const messages = [...input.messages, userPrompt]
const attachmentPaths = getInputAttachmentPaths(input)
const systemPrompt = generateSystemPrompt(attachmentPaths)
const systemPrompt = generateSystemPrompt()
const attachmentsExtractor = new AttachmentsStreamExtractor()
const result: {
messages: ModelMessage[]
-23
View File
@@ -27,7 +27,6 @@ export const system = ({
channels,
skills,
enabledSkills,
attachments = [],
}: SystemParams) => {
const headers = {
'language': language,
@@ -36,27 +35,6 @@ export const system = ({
'time-now': date.toISOString(),
}
const attachmentPaths = attachments
.map((p) => (typeof p === 'string' ? p.trim() : ''))
.filter(Boolean)
const attachmentsBlock = attachmentPaths.length
? [
'## Current Attachments',
'',
'The following file paths are available in this request:',
'',
block(
[
'<attachments>',
...attachmentPaths.map((p) => `- ${p}`),
'</attachments>',
].join('\n')
),
'',
].join('\n')
: ''
return `
---
${Bun.YAML.stringify(headers)}
@@ -111,6 +89,5 @@ ${skills.map(skill => `- ${skill.name}: ${skill.description}`).join('\n')}
${enabledSkills.map(skill => skillPrompt(skill)).join('\n\n---\n\n')}
${attachmentsBlock}
`.trim()
}