Browse Source

modify listing order

Yuki Takei 1 year ago
parent
commit
22b81f0483
1 changed files with 5 additions and 2 deletions
  1. 5 2
      apps/app/src/server/routes/apiv3/openai/chat.ts

+ 5 - 2
apps/app/src/server/routes/apiv3/openai/chat.ts

@@ -53,10 +53,13 @@ export const chatHandlersFactory: ChatHandlersFactory = (crowi) => {
           })
           })
           : await openaiClient.beta.threads.retrieve(threadId);
           : await openaiClient.beta.threads.retrieve(threadId);
 
 
-        const run = await openaiClient.beta.threads.runs.createAndPoll(thread.id, { assistant_id: assistantId });
+        const run = await openaiClient.beta.threads.runs.createAndPoll(thread.id, { assistant_id: assistant.id });
 
 
         if (run.status === 'completed') {
         if (run.status === 'completed') {
-          const messages = await openaiClient.beta.threads.messages.list(run.thread_id);
+          const messages = await openaiClient.beta.threads.messages.list(run.thread_id, {
+            limit: 1,
+            order: 'desc',
+          });
           return res.apiv3({ messages });
           return res.apiv3({ messages });
         }
         }