diff --git a/lib/alan.mjs b/lib/alan.mjs index 00cc58d..bd95383 100644 --- a/lib/alan.mjs +++ b/lib/alan.mjs @@ -309,9 +309,8 @@ const buildGptMessage = (content, options) => { type: 'image_url', image_url: { url: x.url } })); return String.isString(content) ? { - role: options?.role || user, content: attachments.length ? [ - { type: 'text', text: content }, ...attachments - ] : content, + role: options?.role || user, + content: [{ type: 'text', text: content }, ...attachments], } : content; }; @@ -461,7 +460,7 @@ const createMessage = async (threadId, content, options) => { const { clientBeta } = await getOpenAIClient(options); // https://platform.openai.com/docs/api-reference/messages/createMessage return await clientBeta.threads.messages.create( - threadId, buildGptMessage(content) + threadId, buildGptMessage(content, options), ); }; @@ -906,7 +905,7 @@ const talk = async (input, options) => { case ASSISTANT: resp = await promptAssistant(input, { assistantId: chatConfig.engines[engine].assistantId, - threadId: session.threadId, ...options, + threadId: session.threadId, ...options, attachments, }); session.threadId = resp.thread.id; break;