mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 18:00:15 +01:00
feat: backend content aggregation for agents/bedrock
This commit is contained in:
parent
16ba3ed243
commit
757f544a9b
4 changed files with 32 additions and 17 deletions
|
|
@ -8,11 +8,7 @@
|
|||
// mapModelToAzureConfig,
|
||||
// } = require('librechat-data-provider');
|
||||
const { Callback } = require('@librechat/agents');
|
||||
const {
|
||||
EModelEndpoint,
|
||||
providerEndpointMap,
|
||||
removeNullishValues,
|
||||
} = require('librechat-data-provider');
|
||||
const { providerEndpointMap, removeNullishValues } = require('librechat-data-provider');
|
||||
const {
|
||||
extractBaseURL,
|
||||
// constructAzureURL,
|
||||
|
|
@ -29,6 +25,8 @@ const BaseClient = require('~/app/clients/BaseClient');
|
|||
const { createRun } = require('./run');
|
||||
const { logger } = require('~/config');
|
||||
|
||||
/** @typedef {import('@librechat/agents').MessageContentComplex} MessageContentComplex */
|
||||
|
||||
class AgentClient extends BaseClient {
|
||||
constructor(options = {}) {
|
||||
super(options);
|
||||
|
|
@ -43,7 +41,9 @@ class AgentClient extends BaseClient {
|
|||
|
||||
this.modelOptions = modelOptions;
|
||||
this.maxContextTokens = maxContextTokens;
|
||||
this.options = Object.assign({ endpoint: EModelEndpoint.agents }, clientOptions);
|
||||
/** @type {MessageContentComplex[]} */
|
||||
this.contentParts = options.contentParts;
|
||||
this.options = Object.assign({ endpoint: options.endpoint }, clientOptions);
|
||||
}
|
||||
|
||||
setOptions(options) {
|
||||
|
|
@ -270,11 +270,12 @@ class AgentClient extends BaseClient {
|
|||
/** @type {sendCompletion} */
|
||||
async sendCompletion(payload, opts = {}) {
|
||||
this.modelOptions.user = this.user;
|
||||
return await this.chatCompletion({
|
||||
await this.chatCompletion({
|
||||
payload,
|
||||
onProgress: opts.onProgress,
|
||||
abortController: opts.abortController,
|
||||
});
|
||||
return this.contentParts;
|
||||
}
|
||||
|
||||
// async recordTokenUsage({ promptTokens, completionTokens, context = 'message' }) {
|
||||
|
|
@ -415,6 +416,7 @@ class AgentClient extends BaseClient {
|
|||
thread_id: this.conversationId,
|
||||
},
|
||||
run_id: this.responseMessageId,
|
||||
signal: abortController.signal,
|
||||
streamMode: 'values',
|
||||
version: 'v2',
|
||||
};
|
||||
|
|
@ -424,7 +426,7 @@ class AgentClient extends BaseClient {
|
|||
}
|
||||
|
||||
const messages = formatAgentMessages(payload);
|
||||
const runMessages = await run.processStream({ messages }, config, {
|
||||
await run.processStream({ messages }, config, {
|
||||
[Callback.TOOL_ERROR]: (graph, error, toolId) => {
|
||||
logger.error(
|
||||
'[api/server/controllers/agents/client.js #chatCompletion] Tool Error',
|
||||
|
|
@ -433,8 +435,7 @@ class AgentClient extends BaseClient {
|
|||
);
|
||||
},
|
||||
});
|
||||
// console.dir(runMessages, { depth: null });
|
||||
return runMessages;
|
||||
logger.info(this.contentParts, { depth: null });
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
'[api/server/controllers/agents/client.js #chatCompletion] Unhandled error type',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue