Skip to content

Commit

Permalink
tweak assistant apis
Browse files Browse the repository at this point in the history
  • Loading branch information
Leask committed May 23, 2024
1 parent 62709b3 commit 02ddf48
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/alan.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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),
);
};

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 02ddf48

Please sign in to comment.