@peopl-health/nexus 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,6 @@ const { createProvider } = require('../providers/createProvider');
9
9
  */
10
10
  class BaseAssistant {
11
11
  constructor(options = {}) {
12
- console.log('options', options);
13
12
  this.assistantId = options.assistantId || null;
14
13
  this.thread = options.thread || null;
15
14
  this.status = options.status || 'idle';
@@ -155,7 +155,8 @@ class OpenAIAssistantsProvider {
155
155
  }
156
156
 
157
157
  async getRun({ threadId, runId }) {
158
- return this.client.beta.threads.runs.retrieve(this._ensureId(threadId), this._ensureId(runId));
158
+ const run = await this.client.beta.threads.runs.retrieve(this._ensureId(runId), { thread_id: this._ensureId(threadId) });
159
+ return run;
159
160
  }
160
161
 
161
162
  async listRuns({ threadId, limit, order = 'desc', activeOnly = false } = {}) {
@@ -177,16 +178,18 @@ class OpenAIAssistantsProvider {
177
178
 
178
179
  async submitToolOutputs({ threadId, runId, toolOutputs }) {
179
180
  return this.client.beta.threads.runs.submitToolOutputs(
180
- this._ensureId(threadId),
181
181
  this._ensureId(runId),
182
- { tool_outputs: toolOutputs }
182
+ {
183
+ thread_id: this._ensureId(threadId) ,
184
+ tool_outputs: toolOutputs
185
+ }
183
186
  );
184
187
  }
185
188
 
186
189
  async cancelRun({ threadId, runId }) {
187
190
  return this.client.beta.threads.runs.cancel(
188
- this._ensureId(threadId),
189
- this._ensureId(runId)
191
+ this._ensureId(runId),
192
+ { thread_id: this._ensureId(threadId) }
190
193
  );
191
194
  }
192
195
 
@@ -60,7 +60,8 @@ const runAssistantAndWait = async ({
60
60
  let completed = false;
61
61
 
62
62
  try {
63
- completed = await checkRunStatus(assistant, run.thread_id, run.id, 0, maxRetries);
63
+ console.log('RUN ID', run.id, thread.thread_id);
64
+ completed = await checkRunStatus(assistant, thread.thread_id, run.id, 0, maxRetries);
64
65
  } finally {
65
66
  if (filter) {
66
67
  await Thread.updateOne(filter, { $set: { run_id: null } });
@@ -395,7 +396,7 @@ const replyAssistant = async function (code, message_ = null, thread_ = null, ru
395
396
 
396
397
  if (!patientMsg) return null;
397
398
 
398
- const assistant = getAssistantById(thread?.prompt_id || thread?.assistant_id, thread);
399
+ const assistant = getAssistantById(process.env.VARIANT === 'responses' ? thread?.prompt_id : thread?.assistant_id, thread);
399
400
  assistant.setReplies(patientReply);
400
401
 
401
402
  const { run, output, completed } = await runAssistantAndWait({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",