@peopl-health/nexus 4.5.23 → 4.5.26
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.
|
@@ -20,9 +20,9 @@ class AssistantProcessor {
|
|
|
20
20
|
return { thread, assistant };
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
async executeLLM(thread, assistant, runOptions = {},
|
|
23
|
+
async executeLLM(thread, assistant, runOptions = {}, message = null) {
|
|
24
24
|
const startTime = Date.now();
|
|
25
|
-
const runResult = await runAssistantWithRetries(thread, assistant, { ...runOptions, phiProcessor: this.phiProcessor },
|
|
25
|
+
const runResult = await runAssistantWithRetries(thread, assistant, { ...runOptions, phiProcessor: this.phiProcessor }, message);
|
|
26
26
|
const predictionTimeMs = Date.now() - startTime;
|
|
27
27
|
|
|
28
28
|
const output = sanitizeOutput(runResult?.output);
|
|
@@ -41,19 +41,19 @@ class AssistantProcessor {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
async process({ code, runOptions = {},
|
|
44
|
+
async process({ code, runOptions = {}, message = null }) {
|
|
45
45
|
if (!code) throw new Error('code is required for assistant processing');
|
|
46
46
|
|
|
47
47
|
return (this.mode === 'queue')
|
|
48
48
|
? await this._executeViaQueue({ code, runOptions })
|
|
49
|
-
: await this._executeLocal({ code, runOptions,
|
|
49
|
+
: await this._executeLocal({ code, runOptions, message });
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
async _executeLocal({ code, runOptions = {},
|
|
52
|
+
async _executeLocal({ code, runOptions = {}, message = null }) {
|
|
53
53
|
const resolved = await this.resolveThread(code);
|
|
54
54
|
if (!resolved) return null;
|
|
55
55
|
|
|
56
|
-
const result = await this.executeLLM(resolved.thread, resolved.assistant, runOptions,
|
|
56
|
+
const result = await this.executeLLM(resolved.thread, resolved.assistant, runOptions, message);
|
|
57
57
|
if (this.storeRunMetrics) await this.storeRunMetrics(code, resolved.thread, result);
|
|
58
58
|
return result;
|
|
59
59
|
}
|
|
@@ -507,7 +507,7 @@ class NexusMessaging {
|
|
|
507
507
|
const result = await this.assistantProcessor.executeLLM(
|
|
508
508
|
resolved.thread, resolved.assistant,
|
|
509
509
|
{ prePromptResult: preProcessResult },
|
|
510
|
-
preProcessed.messages
|
|
510
|
+
preProcessed.messages[0]
|
|
511
511
|
);
|
|
512
512
|
|
|
513
513
|
if (storeRunMetrics) await storeRunMetrics(chatId, resolved.thread, result, preProcessed.timings);
|
|
@@ -22,14 +22,17 @@ const runAssistantAndWait = async ({ thread, assistant, message = null, runConfi
|
|
|
22
22
|
throw new Error('runAssistantAndWait requires thread and assistant');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
if (Array.isArray(message)) {
|
|
26
|
+
throw new Error('runAssistantAndWait requires message to be a single element, not an array');
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
const variant = getProviderVariant();
|
|
26
30
|
const provider = createLLMProvider({ variant });
|
|
27
31
|
const { polling, tools: configTools, ...config } = runConfig;
|
|
28
32
|
const tools = assistant.getToolSchemas?.() || configTools || [];
|
|
29
|
-
const messageForRun = Array.isArray(message) && message.length > 0 ? message[0] : message;
|
|
30
33
|
|
|
31
34
|
return withThreadRecovery(
|
|
32
|
-
(currentThread = thread) => provider.executeRun({ thread: currentThread, message
|
|
35
|
+
(currentThread = thread) => provider.executeRun({ thread: currentThread, message, assistant, tools, config, polling }),
|
|
33
36
|
thread,
|
|
34
37
|
variant
|
|
35
38
|
);
|
package/lib/index.d.ts
CHANGED
|
@@ -595,7 +595,7 @@ declare module '@peopl-health/nexus' {
|
|
|
595
595
|
export interface ProcessInput {
|
|
596
596
|
code: string;
|
|
597
597
|
runOptions?: Record<string, any>;
|
|
598
|
-
|
|
598
|
+
message?: any | null;
|
|
599
599
|
}
|
|
600
600
|
|
|
601
601
|
export interface LLMResult {
|
|
@@ -614,7 +614,7 @@ declare module '@peopl-health/nexus' {
|
|
|
614
614
|
constructor(config: AssistantProcessorConfig);
|
|
615
615
|
setSendMessage(fn: AssistantProcessorConfig['sendMessage']): void;
|
|
616
616
|
resolveThread(code: string): Promise<{ thread: any; assistant: any } | null>;
|
|
617
|
-
executeLLM(thread: any, assistant: any, runOptions?: Record<string, any>,
|
|
617
|
+
executeLLM(thread: any, assistant: any, runOptions?: Record<string, any>, message?: any): Promise<LLMResult>;
|
|
618
618
|
process(input: ProcessInput): Promise<LLMResult | null>;
|
|
619
619
|
sendResponse(code: string, result: any): Promise<string | null>;
|
|
620
620
|
}
|