@peopl-health/nexus 2.2.2 → 2.2.3
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/config/llmConfig.js
CHANGED
|
@@ -4,7 +4,7 @@ const { createProvider } = require('../providers/createProvider');
|
|
|
4
4
|
let anthropicClient = null;
|
|
5
5
|
let openaiClient = null;
|
|
6
6
|
let providerInstance = null;
|
|
7
|
-
let providerVariant = 'assistants';
|
|
7
|
+
let providerVariant = process.env.VARIANT || 'assistants';
|
|
8
8
|
|
|
9
9
|
const setOpenAIClient = (client) => {
|
|
10
10
|
openaiClient = client || null;
|
|
@@ -12,7 +12,6 @@ const setOpenAIClient = (client) => {
|
|
|
12
12
|
if (!client) {
|
|
13
13
|
providerInstance = null;
|
|
14
14
|
module.exports.providerInstance = null;
|
|
15
|
-
providerVariant = 'assistants';
|
|
16
15
|
module.exports.providerVariant = providerVariant;
|
|
17
16
|
}
|
|
18
17
|
};
|
|
@@ -20,8 +19,7 @@ const setOpenAIClient = (client) => {
|
|
|
20
19
|
const setOpenAIProvider = (provider) => {
|
|
21
20
|
providerInstance = provider || null;
|
|
22
21
|
module.exports.providerInstance = providerInstance;
|
|
23
|
-
providerVariant = provider?.variant || providerVariant
|
|
24
|
-
module.exports.providerVariant = providerVariant;
|
|
22
|
+
module.exports.providerVariant = provider?.variant || providerVariant;
|
|
25
23
|
|
|
26
24
|
if (!provider) {
|
|
27
25
|
setOpenAIClient(null);
|
|
@@ -37,11 +35,11 @@ const setOpenAIProvider = (provider) => {
|
|
|
37
35
|
}
|
|
38
36
|
};
|
|
39
37
|
|
|
40
|
-
const getOpenAIProvider = ({ instantiate = true } = {}) => {
|
|
38
|
+
const getOpenAIProvider = ({ instantiate = true, variant = providerVariant } = {}) => {
|
|
41
39
|
if (providerInstance) return providerInstance;
|
|
42
40
|
if (!instantiate) return null;
|
|
43
41
|
if (!openaiClient) return null;
|
|
44
|
-
const provider = createProvider({ client: openaiClient, variant
|
|
42
|
+
const provider = createProvider({ client: openaiClient, variant });
|
|
45
43
|
setOpenAIProvider(provider);
|
|
46
44
|
return provider;
|
|
47
45
|
};
|
|
@@ -615,7 +615,7 @@ const getOpenAIThreadMessagesController = async (req, res) => {
|
|
|
615
615
|
const conversationId = thread.getConversationId();
|
|
616
616
|
console.log('Thread found - Conversation ID:', conversationId);
|
|
617
617
|
|
|
618
|
-
const provider = llmConfig.getOpenAIProvider({ instantiate: true });
|
|
618
|
+
const provider = llmConfig.getOpenAIProvider({ instantiate: true, variant });
|
|
619
619
|
if (!provider) {
|
|
620
620
|
throw new Error('OpenAI provider not initialized');
|
|
621
621
|
}
|
|
@@ -10,6 +10,7 @@ const PROVIDER_VARIANTS = {
|
|
|
10
10
|
* Returns the appropriate OpenAI provider implementation for the requested variant.
|
|
11
11
|
*/
|
|
12
12
|
function createProvider(config = {}) {
|
|
13
|
+
console.log('Creating OpenAI provider with config:', config);
|
|
13
14
|
const variant = (config.variant || config.providerVariant || config.llmVariant || 'assistants')
|
|
14
15
|
.toString()
|
|
15
16
|
.toLowerCase();
|