|
9 | 9 | const azureAssistants = require('~/server/services/Endpoints/azureAssistants'); |
10 | 10 | const assistants = require('~/server/services/Endpoints/assistants'); |
11 | 11 | const agents = require('~/server/services/Endpoints/agents'); |
12 | | -const { updateFilesUsage } = require('~/models'); |
13 | | -const { isSolidUser } = require('~/server/utils/isSolidUser'); |
14 | | -const { getConvoFromSolid } = require('~/server/services/SolidStorage'); |
| 12 | +const { updateFilesUsage, getConvo } = require('~/models'); |
15 | 13 |
|
16 | 14 | const buildFunction = { |
17 | 15 | [EModelEndpoint.agents]: agents.buildOptions, |
@@ -73,23 +71,18 @@ async function buildEndpointOption(req, res, next) { |
73 | 71 | } |
74 | 72 | } |
75 | 73 |
|
76 | | - // If model is missing and we have a conversationId, try to load it from Solid storage |
77 | | - if (!parsedBody.model && req.body?.conversationId && |
78 | | - req.body.conversationId !== 'new' && |
79 | | - isSolidUser(req)) { |
| 74 | + // If model is missing and we have a conversationId, load the conversation (Solid or MongoDB) to get the model |
| 75 | + if (!parsedBody.model && req.body?.conversationId && req.body.conversationId !== 'new') { |
80 | 76 | try { |
81 | | - const conversation = await getConvoFromSolid(req, req.body.conversationId); |
82 | | - |
| 77 | + const conversation = await getConvo(req.user?.id, req.body.conversationId, req); |
83 | 78 | if (conversation?.model) { |
84 | 79 | parsedBody.model = conversation.model; |
85 | 80 | } |
86 | 81 | } catch (error) { |
87 | | - // Don't fail the request if we can't load from Solid - just log a warning |
88 | | - logger.warn('[buildEndpointOption] Could not load conversation from Solid to extract model', { |
| 82 | + logger.warn('[buildEndpointOption] Could not load conversation to extract model', { |
89 | 83 | conversationId: req.body.conversationId, |
90 | 84 | error: error.message, |
91 | 85 | }); |
92 | | - // Continue without the model - it might be set elsewhere or the request might fail later |
93 | 86 | } |
94 | 87 | } |
95 | 88 |
|
|
0 commit comments