@peopl-health/nexus 4.5.29 → 4.5.30
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 +11 -7
- package/package.json +1 -1
package/lib/eval/EvalProvider.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
const { OpenAI } = require('openai');
|
|
2
|
-
|
|
3
1
|
const { getCurrentMexicoDateTime } = require('../utils/dateUtils');
|
|
4
2
|
const { retryWithBackoff } = require('../utils/retryUtils');
|
|
5
3
|
const { logger } = require('../utils/logger');
|
|
6
4
|
const { Thread } = require('../models/threadModel');
|
|
7
5
|
const { DefaultMemoryManager } = require('../memory/DefaultMemoryManager');
|
|
8
6
|
const { EnhancedMemoryManager } = require('../memory/EnhancedMemoryManager');
|
|
9
|
-
const {
|
|
7
|
+
const { PROVIDER_VARIANTS } = require('../providers/createLLMProvider');
|
|
10
8
|
const { handleFunctionCalls } = require('../providers/OpenAIResponsesProviderTools');
|
|
11
9
|
const { composePrompt, resolveTools } = require('../services/promptComposerService');
|
|
12
10
|
const { getToolSchemas: getRegistrySchemas } = require('../services/toolRegistryService');
|
|
@@ -40,14 +38,20 @@ class EvalProvider {
|
|
|
40
38
|
this.presetId = config.presetId || null;
|
|
41
39
|
this.label = options.label || config.label || `nexus:${this.model}`;
|
|
42
40
|
|
|
43
|
-
this.client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
44
41
|
this.memoryManager = config.memoryManager || (
|
|
45
42
|
config.memoryStrategy === 'enhanced' ? new EnhancedMemoryManager() : new DefaultMemoryManager()
|
|
46
43
|
);
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
const variant = (config.variant || process.env.VARIANT || 'responses').toString().toLowerCase();
|
|
45
|
+
const ProviderClass = PROVIDER_VARIANTS[variant];
|
|
46
|
+
if (!ProviderClass) {
|
|
47
|
+
throw new Error(`Invalid LLM provider variant for eval: '${variant}'. Available: ${Object.keys(PROVIDER_VARIANTS).join(', ')}`);
|
|
48
|
+
}
|
|
49
|
+
this.provider = new ProviderClass({
|
|
49
50
|
defaultModels: { responseModel: this.model },
|
|
51
|
+
conversationManager: this.memoryManager,
|
|
50
52
|
});
|
|
53
|
+
this.client = this.provider.getClient();
|
|
54
|
+
this.model = this.provider._mapModelConfig({ model: this.model }).model;
|
|
51
55
|
this.phiProcessor = new PhiProcessor({
|
|
52
56
|
encode: config.phi?.encode || false,
|
|
53
57
|
ner: config.phi?.ner || null,
|
|
@@ -184,7 +188,7 @@ class EvalProvider {
|
|
|
184
188
|
const input = [{ role: 'developer', content: devContent }, ...memoryMessage, ...convertedMessages];
|
|
185
189
|
const apiConfig = { input, instructions: devContent || '' };
|
|
186
190
|
|
|
187
|
-
if (assistantId) {
|
|
191
|
+
if (assistantId && this.provider.supportsPromptRegistry) {
|
|
188
192
|
apiConfig.prompt = { id: assistantId, variables: promptVariables };
|
|
189
193
|
const version = this.promptVersions[assistantId];
|
|
190
194
|
if (version) apiConfig.prompt.version = String(version);
|