WIP: agent provider schema parsing

This commit is contained in:
Danny Avila 2024-09-02 16:10:00 -04:00
parent 11eb215922
commit 16106e0969
No known key found for this signature in database
GPG key ID: 2DD9CC89B9B50364
3 changed files with 94 additions and 26 deletions

View file

@ -8,7 +8,12 @@
// mapModelToAzureConfig,
// } = require('librechat-data-provider');
const { Callback } = require('@librechat/agents');
const { providerEndpointMap, removeNullishValues } = require('librechat-data-provider');
const {
providerEndpointMap,
removeNullishValues,
EModelEndpoint,
parseCompactConvo,
} = require('librechat-data-provider');
const {
extractBaseURL,
// constructAzureURL,
@ -27,6 +32,10 @@ const { logger } = require('~/config');
/** @typedef {import('@librechat/agents').MessageContentComplex} MessageContentComplex */
const providerSchemas = {
[EModelEndpoint.bedrock]: true,
};
class AgentClient extends BaseClient {
constructor(options = {}) {
super(options);
@ -119,6 +128,26 @@ class AgentClient extends BaseClient {
}
getSaveOptions() {
const hasSchema = providerSchemas[this.options.endpoint];
let runOptions =
this.options.endpoint === EModelEndpoint.agents
? {
model: undefined,
// TODO:
// would need to be override settings; otherwise, model needs to be undefined
// model: this.override.model,
// instructions: this.override.instructions,
// additional_instructions: this.override.additional_instructions,
}
: {};
if (hasSchema) {
runOptions = parseCompactConvo({
endpoint: this.options.endpoint,
conversation: this.modelOptions,
});
}
return removeNullishValues(
Object.assign(
{
@ -129,15 +158,8 @@ class AgentClient extends BaseClient {
imageDetail: this.options.imageDetail,
spec: this.options.spec,
},
this.modelOptions,
{
model: undefined,
// TODO:
// would need to be override settings; otherwise, model needs to be undefined
// model: this.override.model,
// instructions: this.override.instructions,
// additional_instructions: this.override.additional_instructions,
},
// TODO: PARSE OPTIONS BY PROVIDER, MAY CONTAIN SENSITIVE DATA
runOptions,
),
);
}