@peopl-health/nexus 5.57.0-dev.8751 → 5.57.0-dev.8772
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.
- package/lib/eval/EvalProvider.js +33 -10
- package/package.json +1 -1
package/lib/eval/EvalProvider.js
CHANGED
|
@@ -36,7 +36,7 @@ class EvalProvider {
|
|
|
36
36
|
this.memoryManager = config.memoryManager || (
|
|
37
37
|
config.memoryStrategy === 'enhanced' ? new EnhancedMemoryManager() : new DefaultMemoryManager()
|
|
38
38
|
);
|
|
39
|
-
const variant = (config.variant || '
|
|
39
|
+
const variant = (config.variant || 'gateway').toString().toLowerCase();
|
|
40
40
|
this.provider = createLLMProvider({
|
|
41
41
|
variant,
|
|
42
42
|
defaultModels: { responseModel: this.model },
|
|
@@ -47,6 +47,11 @@ class EvalProvider {
|
|
|
47
47
|
encode: config.phi?.encode || false,
|
|
48
48
|
ner: config.phi?.ner || null,
|
|
49
49
|
});
|
|
50
|
+
this.configModelConfig = {
|
|
51
|
+
...(config.model ? { model: config.model } : {}),
|
|
52
|
+
...(config.temperature != null ? { temperature: config.temperature } : {}),
|
|
53
|
+
...(config.maxOutputTokens != null ? { max_output_tokens: config.maxOutputTokens } : {}),
|
|
54
|
+
};
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
id() {
|
|
@@ -69,12 +74,15 @@ class EvalProvider {
|
|
|
69
74
|
|
|
70
75
|
const { messages, promptVariables, lastUserMessage, contextSource } = await this._buildContext(numero, beforeCheckpoint);
|
|
71
76
|
|
|
72
|
-
const {
|
|
77
|
+
const {
|
|
78
|
+
devContent, assistant, toolSchemas, resolvedPromptId, presetModelConfig, resolvedPresetId,
|
|
79
|
+
} = await this._resolvePrompt(prompt, assistantId, thread, promptVariables);
|
|
73
80
|
|
|
74
81
|
const request = this._buildRequest({
|
|
75
82
|
devContent, messages, promptVariables, toolSchemas, assistant,
|
|
76
83
|
assistantId: resolvedPromptId || assistantId,
|
|
77
|
-
presetId:
|
|
84
|
+
presetId: resolvedPresetId,
|
|
85
|
+
presetModelConfig,
|
|
78
86
|
});
|
|
79
87
|
|
|
80
88
|
const startTime = Date.now();
|
|
@@ -126,11 +134,15 @@ class EvalProvider {
|
|
|
126
134
|
let devContent;
|
|
127
135
|
let resolvedPromptId = assistantId;
|
|
128
136
|
let presetToolIds = null;
|
|
137
|
+
let presetModelConfig = null;
|
|
138
|
+
let resolvedPresetId = this.presetId || thread?.preset_id || null;
|
|
129
139
|
|
|
130
|
-
const presetId =
|
|
140
|
+
const presetId = resolvedPresetId;
|
|
131
141
|
|
|
132
142
|
if (this.promptSource === 'airtable' && (presetId || assistantId)) {
|
|
133
|
-
const {
|
|
143
|
+
const {
|
|
144
|
+
resolvedPrompt, promptId, presetToolIds: toolIds, modelConfig, presetId: composedPresetId,
|
|
145
|
+
} = await composePrompt({
|
|
134
146
|
presetId,
|
|
135
147
|
promptId: assistantId,
|
|
136
148
|
variables: promptVariables,
|
|
@@ -138,6 +150,8 @@ class EvalProvider {
|
|
|
138
150
|
devContent = resolvedPrompt;
|
|
139
151
|
resolvedPromptId = promptId || assistantId;
|
|
140
152
|
presetToolIds = toolIds;
|
|
153
|
+
presetModelConfig = modelConfig || null;
|
|
154
|
+
resolvedPresetId = composedPresetId || resolvedPresetId;
|
|
141
155
|
} else {
|
|
142
156
|
devContent = fallbackPrompt;
|
|
143
157
|
devContent = devContent.replace(/\{\{(\w+)\}\}/g, (_, key) => promptVariables[key] ?? '');
|
|
@@ -176,10 +190,21 @@ class EvalProvider {
|
|
|
176
190
|
}
|
|
177
191
|
}
|
|
178
192
|
|
|
179
|
-
return { devContent, assistant, toolSchemas, resolvedPromptId };
|
|
193
|
+
return { devContent, assistant, toolSchemas, resolvedPromptId, presetModelConfig, resolvedPresetId };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
_modelConfig(presetModelConfig) {
|
|
197
|
+
const base = presetModelConfig
|
|
198
|
+
|| { temperature: this.temperature, max_output_tokens: this.maxOutputTokens };
|
|
199
|
+
const merged = { model: this.model, ...base, ...this.configModelConfig };
|
|
200
|
+
if (typeof merged.model !== 'string' || !merged.model.trim()) merged.model = this.model;
|
|
201
|
+
return merged;
|
|
180
202
|
}
|
|
181
203
|
|
|
182
|
-
_buildRequest({
|
|
204
|
+
_buildRequest({
|
|
205
|
+
devContent, messages, promptVariables, toolSchemas, assistant, assistantId, presetId,
|
|
206
|
+
presetModelConfig = null,
|
|
207
|
+
}) {
|
|
183
208
|
const convertedMessages = this.provider._convertItemsToApiFormat(messages);
|
|
184
209
|
|
|
185
210
|
const memoryParts = [];
|
|
@@ -199,9 +224,7 @@ class EvalProvider {
|
|
|
199
224
|
input,
|
|
200
225
|
toolSchemas: isContextOnly ? [] : toolSchemas,
|
|
201
226
|
toolChoice: isContextOnly ? 'none' : this.toolChoice,
|
|
202
|
-
modelConfig: shouldUsePromptRegistry
|
|
203
|
-
? {}
|
|
204
|
-
: { model: this.model, temperature: this.temperature, max_output_tokens: this.maxOutputTokens },
|
|
227
|
+
modelConfig: shouldUsePromptRegistry ? {} : this._modelConfig(presetModelConfig),
|
|
205
228
|
assistant: isContextOnly ? null : assistant,
|
|
206
229
|
phiProcessor: this.phiProcessor,
|
|
207
230
|
promptVariables,
|