mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🤖 fix: Address Minor Agent Issues (#4483)
* fix(Agents): remove test code in openAI/llm.js * refactor: add use of enums in encodeAndFormat * fix: image attachment payload formatting for agents * chore: imports
This commit is contained in:
parent
a6fbe7591a
commit
ec922986a9
5 changed files with 20 additions and 6 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
const { Callback, createMetadataAggregator } = require('@librechat/agents');
|
const { Callback, createMetadataAggregator } = require('@librechat/agents');
|
||||||
const {
|
const {
|
||||||
Constants,
|
Constants,
|
||||||
|
VisionModes,
|
||||||
openAISchema,
|
openAISchema,
|
||||||
EModelEndpoint,
|
EModelEndpoint,
|
||||||
anthropicSchema,
|
anthropicSchema,
|
||||||
|
|
@ -196,6 +197,7 @@ class AgentClient extends BaseClient {
|
||||||
this.options.req,
|
this.options.req,
|
||||||
attachments,
|
attachments,
|
||||||
this.options.agent.provider,
|
this.options.agent.provider,
|
||||||
|
VisionModes.agents,
|
||||||
);
|
);
|
||||||
message.image_urls = image_urls.length ? image_urls : undefined;
|
message.image_urls = image_urls.length ? image_urls : undefined;
|
||||||
return files;
|
return files;
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ const initializeClient = async ({
|
||||||
if (optionsOnly) {
|
if (optionsOnly) {
|
||||||
const requestOptions = Object.assign(
|
const requestOptions = Object.assign(
|
||||||
{
|
{
|
||||||
modelOptions: endpointOption.modelOptions,
|
modelOptions: endpointOption.model_parameters,
|
||||||
},
|
},
|
||||||
clientOptions,
|
clientOptions,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ function getLLMConfig(apiKey, options = {}) {
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
let llmConfig = {
|
let llmConfig = {
|
||||||
model: 'gpt-4o-mini',
|
|
||||||
streaming,
|
streaming,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const { EModelEndpoint, FileSources, VisionModes } = require('librechat-data-provider');
|
const {
|
||||||
const { getStrategyFunctions } = require('../strategies');
|
FileSources,
|
||||||
|
VisionModes,
|
||||||
|
ImageDetail,
|
||||||
|
ContentTypes,
|
||||||
|
EModelEndpoint,
|
||||||
|
} = require('librechat-data-provider');
|
||||||
|
const { getStrategyFunctions } = require('~/server/services/Files/strategies');
|
||||||
const { logger } = require('~/config');
|
const { logger } = require('~/config');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -79,7 +85,7 @@ async function encodeAndFormat(req, files, endpoint, mode) {
|
||||||
promises.push(preparePayload(req, file));
|
promises.push(preparePayload(req, file));
|
||||||
}
|
}
|
||||||
|
|
||||||
const detail = req.body.imageDetail ?? 'auto';
|
const detail = req.body.imageDetail ?? ImageDetail.auto;
|
||||||
|
|
||||||
/** @type {Array<[MongoFile, string]>} */
|
/** @type {Array<[MongoFile, string]>} */
|
||||||
const formattedImages = await Promise.all(promises);
|
const formattedImages = await Promise.all(promises);
|
||||||
|
|
@ -104,7 +110,7 @@ async function encodeAndFormat(req, files, endpoint, mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const imagePart = {
|
const imagePart = {
|
||||||
type: 'image_url',
|
type: ContentTypes.IMAGE_URL,
|
||||||
image_url: {
|
image_url: {
|
||||||
url: imageContent.startsWith('http')
|
url: imageContent.startsWith('http')
|
||||||
? imageContent
|
? imageContent
|
||||||
|
|
@ -113,6 +119,12 @@ async function encodeAndFormat(req, files, endpoint, mode) {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (mode === VisionModes.agents) {
|
||||||
|
result.image_urls.push(imagePart);
|
||||||
|
result.files.push(fileMetadata);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (endpoint && endpoint === EModelEndpoint.google && mode === VisionModes.generative) {
|
if (endpoint && endpoint === EModelEndpoint.google && mode === VisionModes.generative) {
|
||||||
delete imagePart.image_url;
|
delete imagePart.image_url;
|
||||||
imagePart.inlineData = {
|
imagePart.inlineData = {
|
||||||
|
|
|
||||||
|
|
@ -752,6 +752,7 @@ export const visionModels = [
|
||||||
];
|
];
|
||||||
export enum VisionModes {
|
export enum VisionModes {
|
||||||
generative = 'generative',
|
generative = 'generative',
|
||||||
|
agents = 'agents',
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validateVisionModel({
|
export function validateVisionModel({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue