mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
chore: remove attachments in system
This commit is contained in:
+3
-12
@@ -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[]
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user