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) => { }: AgentParams, fetch: AuthFetcher) => {
const model = createModel(modelConfig) const model = createModel(modelConfig)
const generateSystemPrompt = (attachmentPaths: string[] = []) => { const generateSystemPrompt = () => {
return system({ return system({
date: new Date(), date: new Date(),
language, language,
@@ -33,7 +33,6 @@ export const createAgent = ({
channels, channels,
skills: [], skills: [],
enabledSkills: [], enabledSkills: [],
attachments: attachmentPaths,
}) })
} }
@@ -44,12 +43,6 @@ export const createAgent = ({
identity, 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 generateUserPrompt = (input: AgentInput) => {
const images = input.attachments.filter(attachment => attachment.type === 'image') const images = input.attachments.filter(attachment => attachment.type === 'image')
const files = input.attachments.filter((a): a is ContainerFileAttachment => a.type === 'file') 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 ask = async (input: AgentInput) => {
const userPrompt = generateUserPrompt(input) const userPrompt = generateUserPrompt(input)
const messages = [...input.messages, userPrompt] const messages = [...input.messages, userPrompt]
const attachmentPaths = getInputAttachmentPaths(input) const systemPrompt = generateSystemPrompt()
const systemPrompt = generateSystemPrompt(attachmentPaths)
const { response, reasoning, text, usage } = await generateText({ const { response, reasoning, text, usage } = await generateText({
model, model,
messages, messages,
@@ -167,8 +159,7 @@ export const createAgent = ({
async function* stream(input: AgentInput): AsyncGenerator<AgentAction> { async function* stream(input: AgentInput): AsyncGenerator<AgentAction> {
const userPrompt = generateUserPrompt(input) const userPrompt = generateUserPrompt(input)
const messages = [...input.messages, userPrompt] const messages = [...input.messages, userPrompt]
const attachmentPaths = getInputAttachmentPaths(input) const systemPrompt = generateSystemPrompt()
const systemPrompt = generateSystemPrompt(attachmentPaths)
const attachmentsExtractor = new AttachmentsStreamExtractor() const attachmentsExtractor = new AttachmentsStreamExtractor()
const result: { const result: {
messages: ModelMessage[] messages: ModelMessage[]
-23
View File
@@ -27,7 +27,6 @@ export const system = ({
channels, channels,
skills, skills,
enabledSkills, enabledSkills,
attachments = [],
}: SystemParams) => { }: SystemParams) => {
const headers = { const headers = {
'language': language, 'language': language,
@@ -36,27 +35,6 @@ export const system = ({
'time-now': date.toISOString(), '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 ` return `
--- ---
${Bun.YAML.stringify(headers)} ${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')} ${enabledSkills.map(skill => skillPrompt(skill)).join('\n\n---\n\n')}
${attachmentsBlock}
`.trim() `.trim()
} }