mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
👓 fix: Assistants Vision Prompt Error Handling (legacy) (#4529)
* fix: vision prompt error handling * fix: Update model reference in chatV1 controller * remove model reference
This commit is contained in:
parent
4da35b9cf5
commit
655f63714b
2 changed files with 12 additions and 7 deletions
|
|
@ -314,7 +314,9 @@ const chatV1 = async (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof endpointOption.artifactsPrompt === 'string' && endpointOption.artifactsPrompt) {
|
if (typeof endpointOption.artifactsPrompt === 'string' && endpointOption.artifactsPrompt) {
|
||||||
body.additional_instructions = `${body.additional_instructions ?? ''}\n${endpointOption.artifactsPrompt}`.trim();
|
body.additional_instructions = `${body.additional_instructions ?? ''}\n${
|
||||||
|
endpointOption.artifactsPrompt
|
||||||
|
}`.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instructions) {
|
if (instructions) {
|
||||||
|
|
@ -371,11 +373,14 @@ const chatV1 = async (req, res) => {
|
||||||
visionMessage.content = createVisionPrompt(plural);
|
visionMessage.content = createVisionPrompt(plural);
|
||||||
visionMessage = formatMessage({ message: visionMessage, endpoint: EModelEndpoint.openAI });
|
visionMessage = formatMessage({ message: visionMessage, endpoint: EModelEndpoint.openAI });
|
||||||
|
|
||||||
visionPromise = openai.chat.completions.create({
|
visionPromise = openai.chat.completions
|
||||||
model: 'gpt-4-vision-preview',
|
.create({
|
||||||
messages: [visionMessage],
|
messages: [visionMessage],
|
||||||
max_tokens: 4000,
|
max_tokens: 4000,
|
||||||
});
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
logger.error('[/assistants/chat/] Error creating vision prompt', error);
|
||||||
|
});
|
||||||
|
|
||||||
const pluralized = plural ? 's' : '';
|
const pluralized = plural ? 's' : '';
|
||||||
body.additional_instructions = `${
|
body.additional_instructions = `${
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ const processVisionRequest = async (client, currentAction) => {
|
||||||
|
|
||||||
/** @type {ChatCompletion | undefined} */
|
/** @type {ChatCompletion | undefined} */
|
||||||
const completion = await client.visionPromise;
|
const completion = await client.visionPromise;
|
||||||
if (completion.usage) {
|
if (completion && completion.usage) {
|
||||||
recordUsage({
|
recordUsage({
|
||||||
user: client.req.user.id,
|
user: client.req.user.id,
|
||||||
model: client.req.body.model,
|
model: client.req.body.model,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue