mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-01 16:18:51 +01:00
🪨 feat: AWS Bedrock support (#3935)
* feat: Add BedrockIcon component to SVG library * feat: EModelEndpoint.bedrock * feat: first pass, bedrock chat. note: AgentClient is returning `agents` as conversation.endpoint * fix: declare endpoint in initialization step * chore: Update @librechat/agents dependency to version 1.4.5 * feat: backend content aggregation for agents/bedrock * feat: abort agent requests * feat: AWS Bedrock icons * WIP: agent provider schema parsing * chore: Update EditIcon props type * refactor(useGenerationsByLatest): make agents and bedrock editable * refactor: non-assistant message content, parts * fix: Bedrock response `sender` * fix: use endpointOption.model_parameters not endpointOption.modelOptions * fix: types for step handler * refactor: Update Agents.ToolCallDelta type * refactor: Remove unnecessary assignment of parentMessageId in AskController * refactor: remove unnecessary assignment of parentMessageId (agent request handler) * fix(bedrock/agents): message regeneration * refactor: dynamic form elements using react-hook-form Controllers * fix: agent icons/labels for messages * fix: agent actions * fix: use of new dynamic tags causing application crash * refactor: dynamic settings touch-ups * refactor: update Slider component to allow custom track class name * refactor: update DynamicSlider component styles * refactor: use Constants value for GLOBAL_PROJECT_NAME (enum) * feat: agent share global methods/controllers * fix: agents query * fix: `getResponseModel` * fix: share prompt a11y issue * refactor: update SharePrompt dialog theme styles * refactor: explicit typing for SharePrompt * feat: add agent roles/permissions * chore: update @librechat/agents dependency to version 1.4.7 for tool_call_ids edge case * fix(Anthropic): messages.X.content.Y.tool_use.input: Input should be a valid dictionary * fix: handle text parts with tool_call_ids and empty text * fix: role initialization * refactor: don't make instructions required * refactor: improve typing of Text part * fix: setShowStopButton for agents route * chore: remove params for now * fix: add streamBuffer and streamRate to help prevent 'Overloaded' errors from Anthropic API * refactor: remove console.log statement in ContentRender component * chore: typing, rename Context to Delete Button * chore(DeleteButton): logging * refactor(Action): make accessible * style(Action): improve a11y again * refactor: remove use/mention of mongoose sessions * feat: first pass, sharing agents * feat: visual indicator for global agent, remove author when serving to non-author * wip: params * chore: fix typing issues * fix(schemas): typing * refactor: improve accessibility of ListCard component and fix console React warning * wip: reset templates for non-legacy new convos * Revert "wip: params" This reverts commitf8067e91d4. * Revert "refactor: dynamic form elements using react-hook-form Controllers" This reverts commit2150c4815d. * fix(Parameters): types and parameter effect update to only update local state to parameters * refactor: optimize useDebouncedInput hook for better performance * feat: first pass, anthropic bedrock params * chore: paramEndpoints check for endpointType too * fix: maxTokens to use coerceNumber.optional(), * feat: extra chat model params * chore: reduce code repetition * refactor: improve preset title handling in SaveAsPresetDialog component * refactor: improve preset handling in HeaderOptions component * chore: improve typing, replace legacy dialog for SaveAsPresetDialog * feat: save as preset from parameters panel * fix: multi-search in select dropdown when using Option type * refactor: update default showDefault value to false in Dynamic components * feat: Bedrock presets settings * chore: config, fix agents schema, update config version * refactor: update AWS region variable name in bedrock options endpoint to BEDROCK_AWS_DEFAULT_REGION * refactor: update baseEndpointSchema in config.ts to include baseURL property * refactor: update createRun function to include req parameter and set streamRate based on provider * feat: availableRegions via config * refactor: remove unused demo agent controller file * WIP: title * Update @librechat/agents to version 1.5.0 * chore: addTitle.js to handle empty responseText * feat: support images and titles * feat: context token updates * Refactor BaseClient test to use expect.objectContaining * refactor: add model select, remove header options params, move side panel params below prompts * chore: update models list, catch title error * feat: model service for bedrock models (env) * chore: Remove verbose debug log in AgentClient class following stream * feat(bedrock): track token spend; fix: token rates, value key mapping for AWS models * refactor: handle streamRate in `handleLLMNewToken` callback * chore: AWS Bedrock example config in `.env.example` * refactor: Rename bedrockMeta to bedrockGeneral in settings.ts and use for AI21 and Amazon Bedrock providers * refactor: Update `.env.example` with AWS Bedrock model IDs URL and additional notes * feat: titleModel support for bedrock * refactor: Update `.env.example` with additional notes for AWS Bedrock model IDs
This commit is contained in:
parent
8c14360263
commit
d59b62174f
134 changed files with 3684 additions and 1213 deletions
144
packages/data-provider/src/bedrock.ts
Normal file
144
packages/data-provider/src/bedrock.ts
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
import { z } from 'zod';
|
||||
import * as s from './schemas';
|
||||
|
||||
export const bedrockInputSchema = s.tConversationSchema
|
||||
.pick({
|
||||
/* LibreChat params; optionType: 'conversation' */
|
||||
modelLabel: true,
|
||||
promptPrefix: true,
|
||||
resendFiles: true,
|
||||
iconURL: true,
|
||||
greeting: true,
|
||||
spec: true,
|
||||
maxOutputTokens: true,
|
||||
maxContextTokens: true,
|
||||
/* Bedrock params; optionType: 'model' */
|
||||
region: true,
|
||||
system: true,
|
||||
model: true,
|
||||
maxTokens: true,
|
||||
temperature: true,
|
||||
topP: true,
|
||||
stop: true,
|
||||
/* Catch-all fields */
|
||||
topK: true,
|
||||
additionalModelRequestFields: true,
|
||||
})
|
||||
.transform(s.removeNullishValues)
|
||||
.catch(() => ({}));
|
||||
|
||||
export type BedrockConverseInput = z.infer<typeof bedrockInputSchema>;
|
||||
|
||||
export const bedrockInputParser = s.tConversationSchema
|
||||
.pick({
|
||||
/* LibreChat params; optionType: 'conversation' */
|
||||
modelLabel: true,
|
||||
promptPrefix: true,
|
||||
resendFiles: true,
|
||||
iconURL: true,
|
||||
greeting: true,
|
||||
spec: true,
|
||||
maxOutputTokens: true,
|
||||
maxContextTokens: true,
|
||||
/* Bedrock params; optionType: 'model' */
|
||||
region: true,
|
||||
model: true,
|
||||
maxTokens: true,
|
||||
temperature: true,
|
||||
topP: true,
|
||||
stop: true,
|
||||
/* Catch-all fields */
|
||||
topK: true,
|
||||
additionalModelRequestFields: true,
|
||||
})
|
||||
.catchall(z.any())
|
||||
.transform((data) => {
|
||||
const knownKeys = [
|
||||
'modelLabel',
|
||||
'promptPrefix',
|
||||
'resendFiles',
|
||||
'iconURL',
|
||||
'greeting',
|
||||
'spec',
|
||||
'maxOutputTokens',
|
||||
'additionalModelRequestFields',
|
||||
'region',
|
||||
'model',
|
||||
'maxTokens',
|
||||
'temperature',
|
||||
'topP',
|
||||
'stop',
|
||||
];
|
||||
|
||||
const additionalFields: Record<string, unknown> = {};
|
||||
const typedData = data as Record<string, unknown>;
|
||||
|
||||
Object.entries(typedData).forEach(([key, value]) => {
|
||||
if (!knownKeys.includes(key)) {
|
||||
if (key === 'topK') {
|
||||
additionalFields['top_k'] = value;
|
||||
} else {
|
||||
additionalFields[key] = value;
|
||||
}
|
||||
delete typedData[key];
|
||||
}
|
||||
});
|
||||
|
||||
if (Object.keys(additionalFields).length > 0) {
|
||||
typedData.additionalModelRequestFields = {
|
||||
...((typedData.additionalModelRequestFields as Record<string, unknown> | undefined) || {}),
|
||||
...additionalFields,
|
||||
};
|
||||
}
|
||||
|
||||
if (typedData.maxOutputTokens !== undefined) {
|
||||
typedData.maxTokens = typedData.maxOutputTokens;
|
||||
} else if (typedData.maxTokens !== undefined) {
|
||||
typedData.maxOutputTokens = typedData.maxTokens;
|
||||
}
|
||||
|
||||
return s.removeNullishValues(typedData) as BedrockConverseInput;
|
||||
})
|
||||
.catch(() => ({}));
|
||||
|
||||
export const bedrockOutputParser = (data: Record<string, unknown>) => {
|
||||
const knownKeys = [...Object.keys(s.tConversationSchema.shape), 'topK', 'top_k'];
|
||||
const result: Record<string, unknown> = {};
|
||||
|
||||
// Extract known fields from the root level
|
||||
Object.entries(data).forEach(([key, value]) => {
|
||||
if (knownKeys.includes(key)) {
|
||||
result[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
// Extract known fields from additionalModelRequestFields
|
||||
if (
|
||||
typeof data.additionalModelRequestFields === 'object' &&
|
||||
data.additionalModelRequestFields !== null
|
||||
) {
|
||||
Object.entries(data.additionalModelRequestFields as Record<string, unknown>).forEach(
|
||||
([key, value]) => {
|
||||
if (knownKeys.includes(key)) {
|
||||
if (key === 'top_k') {
|
||||
result['topK'] = value;
|
||||
} else {
|
||||
result[key] = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Handle maxTokens and maxOutputTokens
|
||||
if (result.maxTokens !== undefined && result.maxOutputTokens === undefined) {
|
||||
result.maxOutputTokens = result.maxTokens;
|
||||
} else if (result.maxOutputTokens !== undefined && result.maxTokens === undefined) {
|
||||
result.maxTokens = result.maxOutputTokens;
|
||||
}
|
||||
|
||||
// Remove additionalModelRequestFields from the result
|
||||
delete result.additionalModelRequestFields;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
|
@ -142,10 +142,19 @@ export const defaultAssistantsVersion = {
|
|||
|
||||
export const baseEndpointSchema = z.object({
|
||||
streamRate: z.number().optional(),
|
||||
baseURL: z.string().optional(),
|
||||
titlePrompt: z.string().optional(),
|
||||
titleModel: z.string().optional(),
|
||||
});
|
||||
|
||||
export type TBaseEndpoint = z.infer<typeof baseEndpointSchema>;
|
||||
|
||||
export const bedrockEndpointSchema = baseEndpointSchema.merge(
|
||||
z.object({
|
||||
availableRegions: z.array(z.string()).optional(),
|
||||
}),
|
||||
);
|
||||
|
||||
export const assistantEndpointSchema = baseEndpointSchema.merge(
|
||||
z.object({
|
||||
/* assistants specific */
|
||||
|
|
@ -169,7 +178,6 @@ export const assistantEndpointSchema = baseEndpointSchema.merge(
|
|||
]),
|
||||
/* general */
|
||||
apiKey: z.string().optional(),
|
||||
baseURL: z.string().optional(),
|
||||
models: z
|
||||
.object({
|
||||
default: z.array(z.string()).min(1),
|
||||
|
|
@ -179,7 +187,6 @@ export const assistantEndpointSchema = baseEndpointSchema.merge(
|
|||
.optional(),
|
||||
titleConvo: z.boolean().optional(),
|
||||
titleMethod: z.union([z.literal('completion'), z.literal('functions')]).optional(),
|
||||
titleModel: z.string().optional(),
|
||||
headers: z.record(z.any()).optional(),
|
||||
}),
|
||||
);
|
||||
|
|
@ -187,43 +194,39 @@ export const assistantEndpointSchema = baseEndpointSchema.merge(
|
|||
export type TAssistantEndpoint = z.infer<typeof assistantEndpointSchema>;
|
||||
|
||||
export const agentsEndpointSChema = baseEndpointSchema.merge(
|
||||
baseEndpointSchema.merge(
|
||||
z.object({
|
||||
/* assistants specific */
|
||||
disableBuilder: z.boolean().optional(),
|
||||
pollIntervalMs: z.number().optional(),
|
||||
timeoutMs: z.number().optional(),
|
||||
version: z.union([z.string(), z.number()]).default(2),
|
||||
supportedIds: z.array(z.string()).min(1).optional(),
|
||||
excludedIds: z.array(z.string()).min(1).optional(),
|
||||
privateAssistants: z.boolean().optional(),
|
||||
retrievalModels: z.array(z.string()).min(1).optional().default(defaultRetrievalModels),
|
||||
capabilities: z
|
||||
.array(z.nativeEnum(Capabilities))
|
||||
.optional()
|
||||
.default([
|
||||
Capabilities.code_interpreter,
|
||||
Capabilities.image_vision,
|
||||
Capabilities.retrieval,
|
||||
Capabilities.actions,
|
||||
Capabilities.tools,
|
||||
]),
|
||||
/* general */
|
||||
apiKey: z.string().optional(),
|
||||
baseURL: z.string().optional(),
|
||||
models: z
|
||||
.object({
|
||||
default: z.array(z.string()).min(1),
|
||||
fetch: z.boolean().optional(),
|
||||
userIdQuery: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
titleConvo: z.boolean().optional(),
|
||||
titleMethod: z.union([z.literal('completion'), z.literal('functions')]).optional(),
|
||||
titleModel: z.string().optional(),
|
||||
headers: z.record(z.any()).optional(),
|
||||
}),
|
||||
),
|
||||
z.object({
|
||||
/* assistants specific */
|
||||
disableBuilder: z.boolean().optional(),
|
||||
pollIntervalMs: z.number().optional(),
|
||||
timeoutMs: z.number().optional(),
|
||||
version: z.union([z.string(), z.number()]).default(2),
|
||||
supportedIds: z.array(z.string()).min(1).optional(),
|
||||
excludedIds: z.array(z.string()).min(1).optional(),
|
||||
privateAssistants: z.boolean().optional(),
|
||||
retrievalModels: z.array(z.string()).min(1).optional().default(defaultRetrievalModels),
|
||||
capabilities: z
|
||||
.array(z.nativeEnum(Capabilities))
|
||||
.optional()
|
||||
.default([
|
||||
Capabilities.code_interpreter,
|
||||
Capabilities.image_vision,
|
||||
Capabilities.retrieval,
|
||||
Capabilities.actions,
|
||||
Capabilities.tools,
|
||||
]),
|
||||
/* general */
|
||||
apiKey: z.string().optional(),
|
||||
models: z
|
||||
.object({
|
||||
default: z.array(z.string()).min(1),
|
||||
fetch: z.boolean().optional(),
|
||||
userIdQuery: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
titleConvo: z.boolean().optional(),
|
||||
titleMethod: z.union([z.literal('completion'), z.literal('functions')]).optional(),
|
||||
headers: z.record(z.any()).optional(),
|
||||
}),
|
||||
);
|
||||
|
||||
export type TAgentsEndpoint = z.infer<typeof agentsEndpointSChema>;
|
||||
|
|
@ -244,7 +247,6 @@ export const endpointSchema = baseEndpointSchema.merge(
|
|||
}),
|
||||
titleConvo: z.boolean().optional(),
|
||||
titleMethod: z.union([z.literal('completion'), z.literal('functions')]).optional(),
|
||||
titleModel: z.string().optional(),
|
||||
summarize: z.boolean().optional(),
|
||||
summaryModel: z.string().optional(),
|
||||
forcePrompt: z.boolean().optional(),
|
||||
|
|
@ -500,6 +502,7 @@ export const configSchema = z.object({
|
|||
[EModelEndpoint.assistants]: assistantEndpointSchema.optional(),
|
||||
[EModelEndpoint.agents]: agentsEndpointSChema.optional(),
|
||||
[EModelEndpoint.custom]: z.array(endpointSchema.partial()).optional(),
|
||||
[EModelEndpoint.bedrock]: baseEndpointSchema.optional(),
|
||||
})
|
||||
.strict()
|
||||
.refine((data) => Object.keys(data).length > 0, {
|
||||
|
|
@ -552,6 +555,7 @@ export const defaultEndpoints: EModelEndpoint[] = [
|
|||
EModelEndpoint.google,
|
||||
EModelEndpoint.anthropic,
|
||||
EModelEndpoint.custom,
|
||||
EModelEndpoint.bedrock,
|
||||
];
|
||||
|
||||
export const alternateName = {
|
||||
|
|
@ -566,6 +570,7 @@ export const alternateName = {
|
|||
[EModelEndpoint.google]: 'Google',
|
||||
[EModelEndpoint.anthropic]: 'Anthropic',
|
||||
[EModelEndpoint.custom]: 'Custom',
|
||||
[EModelEndpoint.bedrock]: 'AWS Bedrock',
|
||||
};
|
||||
|
||||
const sharedOpenAIModels = [
|
||||
|
|
@ -588,6 +593,52 @@ const sharedOpenAIModels = [
|
|||
'gpt-3.5-turbo-0613',
|
||||
];
|
||||
|
||||
const sharedAnthropicModels = [
|
||||
'claude-3-5-sonnet-20240620',
|
||||
'claude-3-opus-20240229',
|
||||
'claude-3-sonnet-20240229',
|
||||
'claude-3-haiku-20240307',
|
||||
'claude-2.1',
|
||||
'claude-2',
|
||||
'claude-1.2',
|
||||
'claude-1',
|
||||
'claude-1-100k',
|
||||
'claude-instant-1',
|
||||
'claude-instant-1-100k',
|
||||
];
|
||||
|
||||
export const bedrockModels = [
|
||||
'anthropic.claude-3-5-sonnet-20240620-v1:0',
|
||||
'anthropic.claude-3-haiku-20240307-v1:0',
|
||||
'anthropic.claude-3-opus-20240229-v1:0',
|
||||
'anthropic.claude-3-sonnet-20240229-v1:0',
|
||||
'anthropic.claude-v2',
|
||||
'anthropic.claude-v2:1',
|
||||
'anthropic.claude-instant-v1',
|
||||
'cohere.command-text-v14',
|
||||
'cohere.command-light-text-v14',
|
||||
'cohere.command-r-v1:0',
|
||||
'cohere.command-r-plus-v1:0',
|
||||
'meta.llama2-13b-chat-v1',
|
||||
'meta.llama2-70b-chat-v1',
|
||||
'meta.llama3-8b-instruct-v1:0',
|
||||
'meta.llama3-70b-instruct-v1:0',
|
||||
'meta.llama3-1-8b-instruct-v1:0',
|
||||
'meta.llama3-1-70b-instruct-v1:0',
|
||||
'meta.llama3-1-405b-instruct-v1:0',
|
||||
'mistral.mistral-7b-instruct-v0:2',
|
||||
'mistral.mixtral-8x7b-instruct-v0:1',
|
||||
'mistral.mistral-large-2402-v1:0',
|
||||
'mistral.mistral-large-2407-v1:0',
|
||||
'mistral.mistral-small-2402-v1:0',
|
||||
'ai21.jamba-instruct-v1:0',
|
||||
// 'ai21.j2-mid-v1', // no streaming
|
||||
// 'ai21.j2-ultra-v1', no conversation history
|
||||
'amazon.titan-text-lite-v1',
|
||||
'amazon.titan-text-express-v1',
|
||||
'amazon.titan-text-premier-v1:0',
|
||||
];
|
||||
|
||||
export const defaultModels = {
|
||||
[EModelEndpoint.azureAssistants]: sharedOpenAIModels,
|
||||
[EModelEndpoint.assistants]: ['chatgpt-4o-latest', ...sharedOpenAIModels],
|
||||
|
|
@ -606,19 +657,7 @@ export const defaultModels = {
|
|||
'code-bison',
|
||||
'code-bison-32k',
|
||||
],
|
||||
[EModelEndpoint.anthropic]: [
|
||||
'claude-3-5-sonnet-20240620',
|
||||
'claude-3-opus-20240229',
|
||||
'claude-3-sonnet-20240229',
|
||||
'claude-3-haiku-20240307',
|
||||
'claude-2.1',
|
||||
'claude-2',
|
||||
'claude-1.2',
|
||||
'claude-1',
|
||||
'claude-1-100k',
|
||||
'claude-instant-1',
|
||||
'claude-instant-1-100k',
|
||||
],
|
||||
[EModelEndpoint.anthropic]: sharedAnthropicModels,
|
||||
[EModelEndpoint.openAI]: [
|
||||
'chatgpt-4o-latest',
|
||||
...sharedOpenAIModels,
|
||||
|
|
@ -626,6 +665,7 @@ export const defaultModels = {
|
|||
'gpt-3.5-turbo-instruct-0914',
|
||||
'gpt-3.5-turbo-instruct',
|
||||
],
|
||||
[EModelEndpoint.bedrock]: bedrockModels,
|
||||
};
|
||||
|
||||
const fitlerAssistantModels = (str: string) => {
|
||||
|
|
@ -645,6 +685,7 @@ export const initialModelsConfig: TModelsConfig = {
|
|||
[EModelEndpoint.chatGPTBrowser]: ['text-davinci-002-render-sha'],
|
||||
[EModelEndpoint.google]: defaultModels[EModelEndpoint.google],
|
||||
[EModelEndpoint.anthropic]: defaultModels[EModelEndpoint.anthropic],
|
||||
[EModelEndpoint.bedrock]: defaultModels[EModelEndpoint.bedrock],
|
||||
};
|
||||
|
||||
export const EndpointURLs: { [key in EModelEndpoint]: string } = {
|
||||
|
|
@ -658,7 +699,8 @@ export const EndpointURLs: { [key in EModelEndpoint]: string } = {
|
|||
[EModelEndpoint.chatGPTBrowser]: `/api/ask/${EModelEndpoint.chatGPTBrowser}`,
|
||||
[EModelEndpoint.azureAssistants]: '/api/assistants/v1/chat',
|
||||
[EModelEndpoint.assistants]: '/api/assistants/v2/chat',
|
||||
[EModelEndpoint.agents]: '/api/agents/chat',
|
||||
[EModelEndpoint.agents]: `/api/${EModelEndpoint.agents}/chat`,
|
||||
[EModelEndpoint.bedrock]: `/api/${EModelEndpoint.bedrock}/chat`,
|
||||
};
|
||||
|
||||
export const modularEndpoints = new Set<EModelEndpoint | string>([
|
||||
|
|
@ -668,6 +710,13 @@ export const modularEndpoints = new Set<EModelEndpoint | string>([
|
|||
EModelEndpoint.openAI,
|
||||
EModelEndpoint.azureOpenAI,
|
||||
EModelEndpoint.custom,
|
||||
EModelEndpoint.agents,
|
||||
EModelEndpoint.bedrock,
|
||||
]);
|
||||
|
||||
export const paramEndpoints = new Set<EModelEndpoint | string>([
|
||||
EModelEndpoint.agents,
|
||||
EModelEndpoint.bedrock,
|
||||
]);
|
||||
|
||||
export const supportsBalanceCheck = {
|
||||
|
|
@ -679,6 +728,7 @@ export const supportsBalanceCheck = {
|
|||
[EModelEndpoint.agents]: true,
|
||||
[EModelEndpoint.azureAssistants]: true,
|
||||
[EModelEndpoint.azureOpenAI]: true,
|
||||
[EModelEndpoint.bedrock]: true,
|
||||
};
|
||||
|
||||
export const visionModels = [
|
||||
|
|
@ -1007,7 +1057,7 @@ export enum Constants {
|
|||
/** Key for the app's version. */
|
||||
VERSION = 'v0.7.5-rc1',
|
||||
/** Key for the Custom Config's version (librechat.yaml). */
|
||||
CONFIG_VERSION = '1.1.6',
|
||||
CONFIG_VERSION = '1.1.7',
|
||||
/** Standard value for the first message's `parentMessageId` value, to indicate no parent exists. */
|
||||
NO_PARENT = '00000000-0000-0000-0000-000000000000',
|
||||
/** Standard value for the initial conversationId before a request is sent */
|
||||
|
|
@ -1026,6 +1076,8 @@ export enum Constants {
|
|||
SAVED_TAG = 'Saved',
|
||||
/** Max number of Conversation starters for Agents/Assistants */
|
||||
MAX_CONVO_STARTERS = 4,
|
||||
/** Global/instance Project Name */
|
||||
GLOBAL_PROJECT_NAME = 'instance',
|
||||
}
|
||||
|
||||
export enum LocalStorageKeys {
|
||||
|
|
@ -1105,6 +1157,7 @@ export enum SystemCategories {
|
|||
|
||||
export const providerEndpointMap = {
|
||||
[EModelEndpoint.openAI]: EModelEndpoint.openAI,
|
||||
[EModelEndpoint.bedrock]: EModelEndpoint.bedrock,
|
||||
[EModelEndpoint.azureOpenAI]: EModelEndpoint.openAI,
|
||||
[EModelEndpoint.anthropic]: EModelEndpoint.anthropic,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ export const supportsFiles = {
|
|||
[EModelEndpoint.azureOpenAI]: true,
|
||||
[EModelEndpoint.anthropic]: true,
|
||||
[EModelEndpoint.custom]: true,
|
||||
[EModelEndpoint.bedrock]: true,
|
||||
};
|
||||
|
||||
export const excelFileTypes = [
|
||||
|
|
|
|||
|
|
@ -13,10 +13,18 @@ export type ComponentType =
|
|||
| 'checkbox'
|
||||
| 'switch'
|
||||
| 'dropdown'
|
||||
| 'combobox'
|
||||
| 'tags';
|
||||
|
||||
export type OptionType = 'conversation' | 'model' | 'custom';
|
||||
|
||||
export type Option = Record<string, unknown> & {
|
||||
label?: string;
|
||||
value: string | number | null;
|
||||
};
|
||||
|
||||
export type OptionWithIcon = Option & { icon?: React.ReactNode };
|
||||
|
||||
export enum ComponentTypes {
|
||||
Input = 'input',
|
||||
Textarea = 'textarea',
|
||||
|
|
@ -24,6 +32,7 @@ export enum ComponentTypes {
|
|||
Checkbox = 'checkbox',
|
||||
Switch = 'switch',
|
||||
Dropdown = 'dropdown',
|
||||
Combobox = 'combobox',
|
||||
Tags = 'tags',
|
||||
}
|
||||
|
||||
|
|
@ -45,6 +54,7 @@ export interface SettingDefinition {
|
|||
description?: string;
|
||||
type: 'number' | 'boolean' | 'string' | 'enum' | 'array';
|
||||
default?: number | boolean | string | string[];
|
||||
showLabel?: boolean;
|
||||
showDefault?: boolean;
|
||||
options?: string[];
|
||||
range?: SettingRange;
|
||||
|
|
@ -64,6 +74,11 @@ export interface SettingDefinition {
|
|||
maxTags?: number; // Specific to tags component
|
||||
includeInput?: boolean; // Specific to slider component
|
||||
descriptionSide?: 'top' | 'right' | 'bottom' | 'left';
|
||||
items?: OptionWithIcon[]; // Specific to combobox component
|
||||
searchPlaceholder?: string; // Specific to combobox component
|
||||
selectPlaceholder?: string; // Specific to combobox component
|
||||
searchPlaceholderCode?: boolean; // Specific to combobox component
|
||||
selectPlaceholderCode?: boolean; // Specific to combobox component
|
||||
}
|
||||
|
||||
export type DynamicSettingProps = Partial<SettingDefinition> & {
|
||||
|
|
@ -190,6 +205,7 @@ const minColumns = 1;
|
|||
const maxColumns = 4;
|
||||
const minSliderOptions = 2;
|
||||
const minDropdownOptions = 2;
|
||||
const minComboboxOptions = 2;
|
||||
|
||||
/**
|
||||
* Validates the provided setting using the constraints unique to each component type.
|
||||
|
|
@ -383,6 +399,19 @@ export function validateSettingDefinitions(settings: SettingsConfiguration): voi
|
|||
}
|
||||
}
|
||||
|
||||
if (setting.component === ComponentTypes.Combobox) {
|
||||
if (!setting.options || setting.options.length < minComboboxOptions) {
|
||||
errors.push({
|
||||
code: ZodIssueCode.custom,
|
||||
message: `Combobox component for setting ${setting.key} requires at least ${minComboboxOptions} options.`,
|
||||
path: ['options'],
|
||||
});
|
||||
}
|
||||
if (!setting.default && setting.options && setting.options.length > 0) {
|
||||
setting.default = setting.options[0];
|
||||
}
|
||||
}
|
||||
|
||||
// Default columnSpan
|
||||
if (!setting.columnSpan) {
|
||||
setting.columnSpan = Math.floor(columns / 2);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/* config */
|
||||
export * from './azure';
|
||||
export * from './bedrock';
|
||||
export * from './config';
|
||||
export * from './file-config';
|
||||
/* artifacts */
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import {
|
|||
compactAssistantSchema,
|
||||
compactAnthropicSchema,
|
||||
} from './schemas';
|
||||
import { bedrockInputSchema } from './bedrock';
|
||||
import { alternateName } from './config';
|
||||
|
||||
type EndpointSchema =
|
||||
|
|
@ -31,7 +32,8 @@ type EndpointSchema =
|
|||
| typeof chatGPTBrowserSchema
|
||||
| typeof gptPluginsSchema
|
||||
| typeof assistantSchema
|
||||
| typeof compactAgentsSchema;
|
||||
| typeof compactAgentsSchema
|
||||
| typeof bedrockInputSchema;
|
||||
|
||||
const endpointSchemas: Record<EModelEndpoint, EndpointSchema> = {
|
||||
[EModelEndpoint.openAI]: openAISchema,
|
||||
|
|
@ -45,6 +47,7 @@ const endpointSchemas: Record<EModelEndpoint, EndpointSchema> = {
|
|||
[EModelEndpoint.assistants]: assistantSchema,
|
||||
[EModelEndpoint.azureAssistants]: assistantSchema,
|
||||
[EModelEndpoint.agents]: compactAgentsSchema,
|
||||
[EModelEndpoint.bedrock]: bedrockInputSchema,
|
||||
};
|
||||
|
||||
// const schemaCreators: Record<EModelEndpoint, (customSchema: DefaultSchemaValues) => EndpointSchema> = {
|
||||
|
|
@ -64,6 +67,7 @@ export function getEnabledEndpoints() {
|
|||
EModelEndpoint.chatGPTBrowser,
|
||||
EModelEndpoint.gptPlugins,
|
||||
EModelEndpoint.anthropic,
|
||||
EModelEndpoint.bedrock,
|
||||
];
|
||||
|
||||
const endpointsEnv = process.env.ENDPOINTS ?? '';
|
||||
|
|
@ -182,12 +186,12 @@ export const parseConvo = ({
|
|||
}: {
|
||||
endpoint: EModelEndpoint;
|
||||
endpointType?: EModelEndpoint;
|
||||
conversation: Partial<s.TConversation | s.TPreset>;
|
||||
conversation: Partial<s.TConversation | s.TPreset> | null;
|
||||
possibleValues?: TPossibleValues;
|
||||
// TODO: POC for default schema
|
||||
// defaultSchema?: Partial<EndpointSchema>,
|
||||
}) => {
|
||||
let schema = endpointSchemas[endpoint];
|
||||
let schema = endpointSchemas[endpoint] as EndpointSchema | undefined;
|
||||
|
||||
if (!schema && !endpointType) {
|
||||
throw new Error(`Unknown endpoint: ${endpoint}`);
|
||||
|
|
@ -199,14 +203,14 @@ export const parseConvo = ({
|
|||
// schema = schemaCreators[endpoint](defaultSchema);
|
||||
// }
|
||||
|
||||
const convo = schema.parse(conversation) as s.TConversation;
|
||||
const convo = schema?.parse(conversation) as s.TConversation | undefined;
|
||||
const { models, secondaryModels } = possibleValues ?? {};
|
||||
|
||||
if (models && convo) {
|
||||
convo.model = getFirstDefinedValue(models) ?? convo.model;
|
||||
}
|
||||
|
||||
if (secondaryModels && convo.agentOptions) {
|
||||
if (secondaryModels && convo?.agentOptions) {
|
||||
convo.agentOptions.model = getFirstDefinedValue(secondaryModels) ?? convo.agentOptions.model;
|
||||
}
|
||||
|
||||
|
|
@ -214,14 +218,23 @@ export const parseConvo = ({
|
|||
};
|
||||
|
||||
export const getResponseSender = (endpointOption: t.TEndpointOption): string => {
|
||||
const { model, endpoint, endpointType, modelDisplayLabel, chatGptLabel, modelLabel, jailbreak } =
|
||||
endpointOption;
|
||||
const {
|
||||
model: _m,
|
||||
endpoint,
|
||||
endpointType,
|
||||
modelDisplayLabel,
|
||||
chatGptLabel,
|
||||
modelLabel,
|
||||
jailbreak,
|
||||
} = endpointOption;
|
||||
|
||||
const model = _m ?? '';
|
||||
if (
|
||||
[
|
||||
EModelEndpoint.openAI,
|
||||
EModelEndpoint.azureOpenAI,
|
||||
EModelEndpoint.bedrock,
|
||||
EModelEndpoint.gptPlugins,
|
||||
EModelEndpoint.azureOpenAI,
|
||||
EModelEndpoint.chatGPTBrowser,
|
||||
].includes(endpoint)
|
||||
) {
|
||||
|
|
@ -229,22 +242,28 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
|
|||
return chatGptLabel;
|
||||
} else if (model && model.includes('gpt-3')) {
|
||||
return 'GPT-3.5';
|
||||
} else if (model && model.includes('gpt-4o')) {
|
||||
return 'GPT-4o';
|
||||
} else if (model && model.includes('gpt-4')) {
|
||||
return 'GPT-4';
|
||||
} else if (model && model.includes('mistral')) {
|
||||
return 'Mistral';
|
||||
}
|
||||
return alternateName[endpoint] ?? 'ChatGPT';
|
||||
return (alternateName[endpoint] as string | undefined) ?? 'ChatGPT';
|
||||
}
|
||||
|
||||
if (endpoint === EModelEndpoint.bingAI) {
|
||||
return jailbreak ? 'Sydney' : 'BingAI';
|
||||
return jailbreak === true ? 'Sydney' : 'BingAI';
|
||||
}
|
||||
|
||||
if (endpoint === EModelEndpoint.anthropic) {
|
||||
return modelLabel ?? 'Claude';
|
||||
}
|
||||
|
||||
if (endpoint === EModelEndpoint.bedrock) {
|
||||
return modelLabel ?? alternateName[endpoint];
|
||||
}
|
||||
|
||||
if (endpoint === EModelEndpoint.google) {
|
||||
if (modelLabel) {
|
||||
return modelLabel;
|
||||
|
|
@ -266,6 +285,8 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
|
|||
return 'Mistral';
|
||||
} else if (model && model.includes('gpt-3')) {
|
||||
return 'GPT-3.5';
|
||||
} else if (model && model.includes('gpt-4o')) {
|
||||
return 'GPT-4o';
|
||||
} else if (model && model.includes('gpt-4')) {
|
||||
return 'GPT-4';
|
||||
} else if (modelDisplayLabel) {
|
||||
|
|
@ -286,6 +307,7 @@ type CompactEndpointSchema =
|
|||
| typeof bingAISchema
|
||||
| typeof compactAnthropicSchema
|
||||
| typeof compactChatGPTSchema
|
||||
| typeof bedrockInputSchema
|
||||
| typeof compactPluginsSchema;
|
||||
|
||||
const compactEndpointSchemas: Record<string, CompactEndpointSchema> = {
|
||||
|
|
@ -296,6 +318,7 @@ const compactEndpointSchemas: Record<string, CompactEndpointSchema> = {
|
|||
[EModelEndpoint.azureAssistants]: compactAssistantSchema,
|
||||
[EModelEndpoint.agents]: compactAgentsSchema,
|
||||
[EModelEndpoint.google]: compactGoogleSchema,
|
||||
[EModelEndpoint.bedrock]: bedrockInputSchema,
|
||||
/* BingAI needs all fields */
|
||||
[EModelEndpoint.bingAI]: bingAISchema,
|
||||
[EModelEndpoint.anthropic]: compactAnthropicSchema,
|
||||
|
|
|
|||
|
|
@ -23,9 +23,13 @@ export enum PermissionTypes {
|
|||
*/
|
||||
PROMPTS = 'PROMPTS',
|
||||
/**
|
||||
* Type for Bookmarks Permissions
|
||||
* Type for Bookmark Permissions
|
||||
*/
|
||||
BOOKMARKS = 'BOOKMARKS',
|
||||
/**
|
||||
* Type for Agent Permissions
|
||||
*/
|
||||
AGENTS = 'AGENTS',
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -42,20 +46,29 @@ export const promptPermissionsSchema = z.object({
|
|||
[Permissions.SHARED_GLOBAL]: z.boolean().default(false),
|
||||
[Permissions.USE]: z.boolean().default(true),
|
||||
[Permissions.CREATE]: z.boolean().default(true),
|
||||
[Permissions.SHARE]: z.boolean().default(false),
|
||||
// [Permissions.SHARE]: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const bookmarkPermissionsSchema = z.object({
|
||||
[Permissions.USE]: z.boolean().default(true),
|
||||
});
|
||||
|
||||
export const agentPermissionsSchema = z.object({
|
||||
[Permissions.SHARED_GLOBAL]: z.boolean().default(false),
|
||||
[Permissions.USE]: z.boolean().default(true),
|
||||
[Permissions.CREATE]: z.boolean().default(true),
|
||||
// [Permissions.SHARE]: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const roleSchema = z.object({
|
||||
name: z.string(),
|
||||
[PermissionTypes.PROMPTS]: promptPermissionsSchema,
|
||||
[PermissionTypes.BOOKMARKS]: bookmarkPermissionsSchema,
|
||||
[PermissionTypes.AGENTS]: agentPermissionsSchema,
|
||||
});
|
||||
|
||||
export type TRole = z.infer<typeof roleSchema>;
|
||||
export type TAgentPermissions = z.infer<typeof agentPermissionsSchema>;
|
||||
export type TPromptPermissions = z.infer<typeof promptPermissionsSchema>;
|
||||
export type TBookmarkPermissions = z.infer<typeof bookmarkPermissionsSchema>;
|
||||
|
||||
|
|
@ -66,16 +79,23 @@ const defaultRolesSchema = z.object({
|
|||
[Permissions.SHARED_GLOBAL]: z.boolean().default(true),
|
||||
[Permissions.USE]: z.boolean().default(true),
|
||||
[Permissions.CREATE]: z.boolean().default(true),
|
||||
[Permissions.SHARE]: z.boolean().default(true),
|
||||
// [Permissions.SHARE]: z.boolean().default(true),
|
||||
}),
|
||||
[PermissionTypes.BOOKMARKS]: bookmarkPermissionsSchema.extend({
|
||||
[Permissions.USE]: z.boolean().default(true),
|
||||
}),
|
||||
[PermissionTypes.AGENTS]: agentPermissionsSchema.extend({
|
||||
[Permissions.SHARED_GLOBAL]: z.boolean().default(true),
|
||||
[Permissions.USE]: z.boolean().default(true),
|
||||
[Permissions.CREATE]: z.boolean().default(true),
|
||||
// [Permissions.SHARE]: z.boolean().default(true),
|
||||
}),
|
||||
}),
|
||||
[SystemRoles.USER]: roleSchema.extend({
|
||||
name: z.literal(SystemRoles.USER),
|
||||
[PermissionTypes.PROMPTS]: promptPermissionsSchema,
|
||||
[PermissionTypes.BOOKMARKS]: bookmarkPermissionsSchema,
|
||||
[PermissionTypes.AGENTS]: agentPermissionsSchema,
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
@ -84,10 +104,12 @@ export const roleDefaults = defaultRolesSchema.parse({
|
|||
name: SystemRoles.ADMIN,
|
||||
[PermissionTypes.PROMPTS]: {},
|
||||
[PermissionTypes.BOOKMARKS]: {},
|
||||
[PermissionTypes.AGENTS]: {},
|
||||
},
|
||||
[SystemRoles.USER]: {
|
||||
name: SystemRoles.USER,
|
||||
[PermissionTypes.PROMPTS]: {},
|
||||
[PermissionTypes.BOOKMARKS]: {},
|
||||
[PermissionTypes.AGENTS]: {},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,11 +25,37 @@ export enum EModelEndpoint {
|
|||
azureAssistants = 'azureAssistants',
|
||||
agents = 'agents',
|
||||
custom = 'custom',
|
||||
bedrock = 'bedrock',
|
||||
}
|
||||
|
||||
export enum BedrockProviders {
|
||||
AI21 = 'ai21',
|
||||
Amazon = 'amazon',
|
||||
Anthropic = 'anthropic',
|
||||
Cohere = 'cohere',
|
||||
Meta = 'meta',
|
||||
MistralAI = 'mistral',
|
||||
StabilityAI = 'stability',
|
||||
}
|
||||
|
||||
export const getModelKey = (endpoint: EModelEndpoint | string, model: string) => {
|
||||
if (endpoint === EModelEndpoint.bedrock) {
|
||||
return model.split('.')[0] as BedrockProviders;
|
||||
}
|
||||
return model;
|
||||
};
|
||||
|
||||
export const getSettingsKeys = (endpoint: EModelEndpoint | string, model: string) => {
|
||||
const endpointKey = endpoint;
|
||||
const modelKey = getModelKey(endpointKey, model);
|
||||
const combinedKey = `${endpointKey}-${modelKey}`;
|
||||
return [combinedKey, endpointKey];
|
||||
};
|
||||
|
||||
export type AssistantsEndpoint = EModelEndpoint.assistants | EModelEndpoint.azureAssistants;
|
||||
|
||||
export const isAssistantsEndpoint = (endpoint?: AssistantsEndpoint | null | string): boolean => {
|
||||
export const isAssistantsEndpoint = (_endpoint?: AssistantsEndpoint | null | string): boolean => {
|
||||
const endpoint = _endpoint ?? '';
|
||||
if (!endpoint) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -38,7 +64,8 @@ export const isAssistantsEndpoint = (endpoint?: AssistantsEndpoint | null | stri
|
|||
|
||||
export type AgentProvider = Exclude<keyof typeof EModelEndpoint, EModelEndpoint.agents> | string;
|
||||
|
||||
export const isAgentsEndpoint = (endpoint?: EModelEndpoint.agents | null | string): boolean => {
|
||||
export const isAgentsEndpoint = (_endpoint?: EModelEndpoint.agents | null | string): boolean => {
|
||||
const endpoint = _endpoint ?? '';
|
||||
if (!endpoint) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -89,6 +116,7 @@ export const defaultAgentFormValues = {
|
|||
model_parameters: {},
|
||||
tools: [],
|
||||
provider: {},
|
||||
projectIds: [],
|
||||
code_interpreter: false,
|
||||
image_vision: false,
|
||||
retrieval: false,
|
||||
|
|
@ -295,6 +323,7 @@ export const endpointSettings = {
|
|||
[EModelEndpoint.google]: googleSettings,
|
||||
[EModelEndpoint.anthropic]: anthropicSettings,
|
||||
[EModelEndpoint.agents]: agentsSettings,
|
||||
[EModelEndpoint.bedrock]: agentsSettings,
|
||||
};
|
||||
|
||||
const google = endpointSettings[EModelEndpoint.google];
|
||||
|
|
@ -433,6 +462,25 @@ export const coerceNumber = z.union([z.number(), z.string()]).transform((val) =>
|
|||
return val;
|
||||
});
|
||||
|
||||
type DocumentTypeValue =
|
||||
| null
|
||||
| boolean
|
||||
| number
|
||||
| string
|
||||
| DocumentTypeValue[]
|
||||
| { [key: string]: DocumentTypeValue };
|
||||
|
||||
const DocumentType: z.ZodType<DocumentTypeValue> = z.lazy(() =>
|
||||
z.union([
|
||||
z.null(),
|
||||
z.boolean(),
|
||||
z.number(),
|
||||
z.string(),
|
||||
z.array(z.lazy(() => DocumentType)),
|
||||
z.record(z.lazy(() => DocumentType)),
|
||||
]),
|
||||
);
|
||||
|
||||
export const tConversationSchema = z.object({
|
||||
conversationId: z.string().nullable(),
|
||||
endpoint: eModelEndpointSchema.nullable(),
|
||||
|
|
@ -457,6 +505,7 @@ export const tConversationSchema = z.object({
|
|||
max_tokens: coerceNumber.optional(),
|
||||
/* Anthropic */
|
||||
promptCache: z.boolean().optional(),
|
||||
system: z.string().optional(),
|
||||
/* artifacts */
|
||||
artifacts: z.string().optional(),
|
||||
/* google */
|
||||
|
|
@ -475,6 +524,10 @@ export const tConversationSchema = z.object({
|
|||
assistant_id: z.string().optional(),
|
||||
/* agents */
|
||||
agent_id: z.string().optional(),
|
||||
/* AWS Bedrock */
|
||||
region: z.string().optional(),
|
||||
maxTokens: coerceNumber.optional(),
|
||||
additionalModelRequestFields: DocumentType.optional(),
|
||||
/* assistant + agents */
|
||||
instructions: z.string().optional(),
|
||||
additional_instructions: z.string().optional(),
|
||||
|
|
@ -618,7 +671,7 @@ export const openAISchema = tConversationSchema
|
|||
max_tokens: obj.max_tokens ?? undefined,
|
||||
};
|
||||
|
||||
if (obj.modelLabel) {
|
||||
if (obj.modelLabel != null && obj.modelLabel !== '') {
|
||||
result.modelLabel = null;
|
||||
}
|
||||
|
||||
|
|
@ -836,7 +889,7 @@ export const gptPluginsSchema = tConversationSchema
|
|||
maxContextTokens: obj.maxContextTokens ?? undefined,
|
||||
};
|
||||
|
||||
if (obj.modelLabel) {
|
||||
if (obj.modelLabel != null && obj.modelLabel !== '') {
|
||||
result.modelLabel = null;
|
||||
}
|
||||
|
||||
|
|
@ -863,16 +916,17 @@ export const gptPluginsSchema = tConversationSchema
|
|||
maxContextTokens: undefined,
|
||||
}));
|
||||
|
||||
export function removeNullishValues<T extends object>(obj: T): T {
|
||||
export function removeNullishValues<T extends Record<string, unknown>>(obj: T): Partial<T> {
|
||||
const newObj: Partial<T> = { ...obj };
|
||||
|
||||
(Object.keys(newObj) as Array<keyof T>).forEach((key) => {
|
||||
if (newObj[key] === undefined || newObj[key] === null || newObj[key] === '') {
|
||||
const value = newObj[key];
|
||||
if (value === undefined || value === null || value === '') {
|
||||
delete newObj[key];
|
||||
}
|
||||
});
|
||||
|
||||
return newObj as T;
|
||||
return newObj;
|
||||
}
|
||||
|
||||
export const assistantSchema = tConversationSchema
|
||||
|
|
@ -973,19 +1027,6 @@ export const agentsSchema = tConversationSchema
|
|||
maxContextTokens: undefined,
|
||||
}));
|
||||
|
||||
export const compactAgentsSchema = tConversationSchema
|
||||
.pick({
|
||||
model: true,
|
||||
agent_id: true,
|
||||
instructions: true,
|
||||
promptPrefix: true,
|
||||
iconURL: true,
|
||||
greeting: true,
|
||||
spec: true,
|
||||
})
|
||||
.transform(removeNullishValues)
|
||||
.catch(() => ({}));
|
||||
|
||||
export const compactOpenAISchema = tConversationSchema
|
||||
.pick({
|
||||
model: true,
|
||||
|
|
@ -1170,3 +1211,16 @@ export const compactPluginsSchema = tConversationSchema
|
|||
return removeNullishValues(newObj);
|
||||
})
|
||||
.catch(() => ({}));
|
||||
|
||||
export const compactAgentsSchema = tConversationSchema
|
||||
.pick({
|
||||
model: true,
|
||||
agent_id: true,
|
||||
instructions: true,
|
||||
additional_instructions: true,
|
||||
iconURL: true,
|
||||
greeting: true,
|
||||
spec: true,
|
||||
})
|
||||
.transform(removeNullishValues)
|
||||
.catch(() => ({}));
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ export type TConfig = {
|
|||
type?: EModelEndpoint;
|
||||
azure?: boolean;
|
||||
availableTools?: [];
|
||||
availableRegions?: string[];
|
||||
plugins?: Record<string, string>;
|
||||
name?: string;
|
||||
iconURL?: string;
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ export namespace Agents {
|
|||
export type MessageContentText = {
|
||||
type: ContentTypes.TEXT;
|
||||
text: string;
|
||||
tool_call_ids?: string[];
|
||||
};
|
||||
|
||||
export type MessageContentImageUrl = {
|
||||
type: 'image_url';
|
||||
type: ContentTypes.IMAGE_URL;
|
||||
image_url: string | { url: string; detail?: ImageDetail };
|
||||
};
|
||||
|
||||
|
|
@ -21,7 +22,7 @@ export namespace Agents {
|
|||
| MessageContentText
|
||||
| MessageContentImageUrl
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
| (Record<string, any> & { type?: ContentTypes | 'image_url' | 'text_delta' | string })
|
||||
| (Record<string, any> & { type?: ContentTypes | string })
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
| (Record<string, any> & { type?: never });
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ export namespace Agents {
|
|||
|
||||
/** The arguments to the tool call */
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
args: string | Record<string, any>;
|
||||
args?: string | Record<string, any>;
|
||||
|
||||
/** If provided, an identifier associated with the tool call */
|
||||
id?: string;
|
||||
|
|
@ -50,14 +51,14 @@ export namespace Agents {
|
|||
/** The Step Id of the Tool Call */
|
||||
id: string;
|
||||
/** The Completed Tool Call */
|
||||
tool_call: ToolCall;
|
||||
tool_call?: ToolCall;
|
||||
/** The content index of the tool call */
|
||||
index: number;
|
||||
};
|
||||
|
||||
export type ToolCallContent = {
|
||||
type: ContentTypes.TOOL_CALL;
|
||||
tool_call: ToolCall;
|
||||
tool_call?: ToolCall;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -180,8 +181,8 @@ export namespace Agents {
|
|||
tool_calls: AgentToolCall[];
|
||||
};
|
||||
export type ToolCallDelta = {
|
||||
type: StepTypes.TOOL_CALLS;
|
||||
tool_calls: ToolCallChunk[];
|
||||
type: StepTypes.TOOL_CALLS | string;
|
||||
tool_calls?: ToolCallChunk[];
|
||||
};
|
||||
export type AgentToolCall = FunctionToolCall | ToolCall;
|
||||
export interface ExtendedMessageContent {
|
||||
|
|
@ -215,5 +216,5 @@ export namespace Agents {
|
|||
*/
|
||||
content?: MessageContentComplex[];
|
||||
}
|
||||
export type ContentType = ContentTypes.TEXT | 'image_url' | string;
|
||||
export type ContentType = ContentTypes.TEXT | ContentTypes.IMAGE_URL | string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ export type Agent = {
|
|||
file_ids: string[];
|
||||
instructions: string | null;
|
||||
tools?: string[];
|
||||
projectIds?: string[];
|
||||
tool_kwargs?: Record<string, unknown>;
|
||||
tool_resources?: ToolResources;
|
||||
metadata?: Record<string, unknown>;
|
||||
|
|
@ -192,8 +193,10 @@ export type AgentUpdateParams = {
|
|||
tools?: Array<FunctionTool | string>;
|
||||
tool_resources?: ToolResources;
|
||||
provider?: AgentProvider;
|
||||
model: string | null;
|
||||
model_parameters: AgentModelParameters;
|
||||
model?: string | null;
|
||||
model_parameters?: AgentModelParameters;
|
||||
projectIds?: string[];
|
||||
removeProjectIds?: string[];
|
||||
};
|
||||
|
||||
export type AgentListParams = {
|
||||
|
|
@ -381,7 +384,7 @@ export type ContentPart = (
|
|||
|
||||
export type TMessageContentParts =
|
||||
| { type: ContentTypes.ERROR; text: Text & PartMetadata }
|
||||
| { type: ContentTypes.TEXT; text: string | (Text & PartMetadata) }
|
||||
| { type: ContentTypes.TEXT; text: string | (Text & PartMetadata); tool_call_ids?: string[] }
|
||||
| {
|
||||
type: ContentTypes.TOOL_CALL;
|
||||
tool_call: (
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
export enum ContentTypes {
|
||||
TEXT = 'text',
|
||||
TEXT_DELTA = 'text_delta',
|
||||
TOOL_CALL = 'tool_call',
|
||||
IMAGE_FILE = 'image_file',
|
||||
IMAGE_URL = 'image_url',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue