mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
* feat: assistant name/icon in Landing & Header * feat: assistname in textarea placeholder, and use `Assistant` as default name * feat: display non-image files in user messages * fix: only render files if files.length is > 0 * refactor(config -> file-config): move file related configuration values to separate module, add excel types * chore: spreadsheet file rendering * fix(Landing): dark mode style for Assistant Name * refactor: move progress incrementing to own hook, start smaller, cap near limit \(1\) * refactor(useContentHandler): add empty Text part if last part was completed tool or image * chore: add accordion trigger border styling for dark mode * feat: Assistant Builder model selection * chore: use Spinner when Assistant is mutating * fix(get/assistants): return correct response object `AssistantListResponse` * refactor(Spinner): pass size as prop * refactor: make assistant crud mutations optimistic, add types for options * chore: remove assistants route and view * chore: move assistant builder components to separate directory * feat(ContextButton): delete Assistant via context button/dialog, add localization * refactor: conditionally show use and context menu buttons, add localization for create assistant * feat: save side panel states to localStorage * style(SidePanel): improve avatar menu and assistant select styling for dark mode * refactor: make NavToggle reusable for either side (left or right), add SidePanel Toggle with ability to close it completely * fix: resize handle and navToggle behavior * fix(/avatar/:assistant_id): await `deleteFile` and assign unique name to uploaded image * WIP: file UI components from PR #576 * refactor(OpenAIMinimalIcon): pass className * feat: formatDate helper fn * feat: DataTableColumnHeader * feat: add row selection, formatted row values, number of rows selected * WIP: add files to Side panel temporarily * feat: `LB_QueueAsyncCall`: Leaky Bucket queue for external APIs, use in `processDeleteRequest` * fix(TFile): correct `source` type with `FileSources` * fix(useFileHandling): use `continue` instead of return when iterating multiple files, add file type to extendedFile * chore: add generic setter type * refactor(processDeleteRequest): settle promises to prevent rejections from processing deletions, log errors * feat: `useFileDeletion` to reuse file deletion logic * refactor(useFileDeletion): make `setFiles` an optional param and use object as param * feat: useDeleteFilesFromTable * feat: use real `files` data and add deletion action to data table * fix(Table): make headers sticky * feat: add dynamic filtering for columns; only show to user Host or OpenAI storage type * style(DropdownMenu): replace `slate` with `gray` * style(DataTable): apply dark mode themes and other misc styling * style(Columns): add color to OpenAI Storage option * refactor(FileContainer): make file preview reusable * refactor(Images): make image preview reusable * refactor(FilePreview): make file prop optional for FileIcon and FilePreview, fix relative style * feat(Columns): add file/image previews, set a minimum size to show for file size in bytes * WIP: File Panel with real files and formatted * feat: open files dialog from panel * style: file data table mobile and general column styling fixes * refactor(api/files): return files sorted by the most recently updated * refactor: provide fileMap through context to prevent re-selecting files to map in different areas; remove unused imports commented out in PanelColumns * refactor(ExtendFile): make File type optional, add `attached` to prevent attached files from being deleted on remove, make Message.files a partial TFile type * feat: attach files through file panel * refactor(useFileHandling): move files to the start of cache list when uploaded * refactor(useDeleteFilesMutation): delete files from cache when successfully deleted from server * fix(FileRow): handle possible edge case of duplication due to attaching recently uploaded file * style(SidePanel): make resize grip border transparent, remove unnecessary styling on close sidepanel button * feat: action utilities and tests * refactor(actions): add `ValidationResult` type and change wording for no server URL found * refactor(actions): check for empty server URL * fix(data-provider): revert tsconfig to fix type issue resolution * feat(client): first pass of actions input for assistants * refactor(FunctionSignature): change method to output object instead of string * refactor(models/Assistant): add actions field to schema, use searchParams object for methods, and add `getAssistant` * feat: post actions input first pass - create new Action document - add actions to Assistant DB document - create /action/:assistant_id POST route - pass more props down from PanelSwitcher, derive assistant_id from switcher - move privacy policy to ActionInput - reset data on input change/validation - add `useUpdateAction` - conform FunctionSignature type to FunctionTool - add action, assistant doc, update hook related types * refactor: optimize assistant/actions relationship - past domain in metadata as hostname and not a URL - include domain in tool name - add `getActions` for actions retrieval by user - add `getAssistants` for assistant docs retrieval by user - add `assistant_id` to Action schema - move actions to own module as a subroute to `api/assistants` - add `useGetActionsQuery` and `useGetAssistantDocsQuery` hooks - fix Action type def * feat: show assistant actions in assistant builder * feat: switch to actions on action click, editing action styling * fix: add Assistant state for builder panel to allow immediate selection of newly created assistants as well as retaining the current assistant when switching to a different panel within the builder * refactor(SidePanel/NavToggle): offset less from right when SidePanel is completely collapsed * chore: rename `processActions` -> `processRequiredActions` * chore: rename Assistant API Action to RequiredAction * refactor(actions): avoid nesting actual API params under generic `requestBody` to optimize LLM token usage * fix(handleTools): avoid calling `validTool` if not defined, add optional param to skip the loading of specs, which throws an error in the context of assistants * WIP: working first pass of toolCalls generated from openapi specs * WIP: first pass ToolCall styling * feat: programmatic iv encryption/decryption helpers * fix: correct ActionAuth types/enums, and define type for AuthForm * feat: encryption/decryption helpers for Action AuthMetadata * refactor(getActions): remove sensitive fields from query response * refactor(POST/actions): encrypt and remove sensitive fields from mutation response * fix(ActionService): change ESM import to CJS * feat: frontend auth handling for actions + optimistic update on action update/creation * refactor(actions): use the correct variables and types for setAuth method * refactor: POST /:assistant_id action can now handle updating an existing action, add `saved_auth_fields` to determine when user explicitly saves new auth creds. only send auth metadata if user explicitly saved fields * refactor(createActionTool): catch errors and send back meaningful error message, add flag to `getActions` to determine whether to retrieve sensitive values or not * refactor(ToolService): add `action` property to ToolCall PartMetadata to determine if the tool call was an action, fix parsing function name issue with actionDelimiter * fix(ActionRequest): use URL class to correctly join endpoint parts for `execute` call * feat: delete assistant actions * refactor: conditionally show Available actions * refactor: show `retrieval` and `code_interpreter` as Capabilities, swap `Switch` for `Checkbox` * chore: remove shadow-stroke from messages * WIP: first pass of Assistants Knowledge attachments * refactor: remove AssistantsProvider in favor of FormProvider, fix selectedAssistant re-render bug, map Assistant file_ids to files via fileMap, initialize Knowledge component with mapped files if any exist * fix: prevent deleting files on assistant file upload * chore: remove console.log * refactor(useUploadFileMutation): update files and assistants cache on upload * chore: disable oauth option as not supported yet * feat: cancel assistant runs * refactor: initialize OpenAI client with helper function, resolve all related circular dependencies * fix(DALL-E): initialization * fix(process): openai client initialization * fix: select an existing Assistant when the active one is deleted * chore: allow attaching files for assistant endpoint, send back relevant OpenAI error message when uploading, deconstruct openAI initialization correctly, add `message_file` to formData when a file is attached to the message but not the assistant * fix: add assistant_id on newConvo * fix(initializeClient): import fix * chore: swap setAssistant for setOption in useEffect * fix(DALL-E): add processFileURL to loadTools call * chore: add customConfig to debug logs * feat: delete threads on convo delete * chore: replace Assistants icon * chore: remove console.dir() in `abortRun` * feat(AssistantService): accumulate text values from run in openai.responseText * feat: titling for assistants endpoint * chore: move panel file components to appropriate directory, add file checks for attaching files, change icon for Attach Files * refactor: add localizations to tools, plugins, add condition for adding/remove user plugins so tool selections don't affect this value * chore: disable `import from url` action for now * chore: remove textMimeTypes from default fileConfig for now * fix: catch tool errors and send as outputs with error messages * fix: React warning about button as descendant of button * style: retrieval and cancelled icon * WIP: pass isSubmitting to Parts, use InProgressCall to display cancelled tool calls correctly, show domain/function name * fix(meilisearch): fix `postSaveHook` issue where indexing expects a mongo document, and join all text content parts for meili indexing * ci: fix dall-e tests * ci: fix client tests * fix: button types in actions panel * fix: plugin auth form persisting across tool selections * fix(ci): update AppService spec with `loadAndFormatTools` * fix(clearConvos): add id check earlier on * refactor(AssistantAvatar): set previewURL dynamically when emtadata.avatar changes * feat(assistants): addTitle cache setting * fix(useSSE): resolve rebase conflicts * fix: delete mutation * style(SidePanel): make grip visible on active and hover, invisible otherwise * ci: add data-provider tests to workflow, also update eslint/tsconfig to recognize specs, and add `text/csv` to fileConfig * fix: handle edge case where auth object is undefined, and log errors * refactor(actions): resolve schemas, add tests for resolving refs, import specs from separate file for tests * chore: remove comment * fix(ActionsInput): re-render bug when initializing states with action fields * fix(patch/assistant): filter undefined tools * chore: add logging for errors in assistants routes * fix(updateAssistant): map actions to functions to avoid overwriting * fix(actions): properly handle GET paths * fix(convos): unhandled delete thread exception * refactor(AssistantService): pass both thread_id and conversationId when sending intermediate assistant messages, remove `mapMessagesToSteps` from AssistantService * refactor(useSSE): replace all messages with runMessages and pass latestMessageId to abortRun; fix(checkMessageGaps): include tool calls when syncing messages * refactor(assistants/chat): invoke `createOnTextProgress` after thread creation * chore: add typing * style: sidepanel styling * style: action tool call domain styling * feat(assistants): default models, limit retrieval to certain models, add env variables to to env.example * feat: assistants api key in EndpointService * refactor: set assistant model to conversation on assistant switch * refactor: set assistant model to conversation on assistant select from panel * fix(retrieveAndProcessFile): catch attempt to download file with `assistant` purpose which is not allowed; add logging * feat: retrieval styling, handling, and logging * chore: rename ASSISTANTS_REVERSE_PROXY to ASSISTANTS_BASE_URL * feat: FileContext for file metadata * feat: context file mgmt and filtering * style(Select): hover/rounded changes * refactor: explicit conversation switch, endpoint dependent, through `useSelectAssistant`, which does not create new chat if current endpoint is assistant endpoint * fix(AssistantAvatar): make empty previewURL if no avatar present * refactor: side panel mobile styling * style: merge tool and action section, optimize mobile styling for action/tool buttons * fix: localStorage issues * fix(useSelectAssistant): invoke react query hook directly in select hook as Map was not being updated in time * style: light mode fixes * fix: prevent sidepanel nav styling from shifting layout up * refactor: change default layout (collapsed by default) * style: mobile optimization of DataTable * style: datatable * feat: client-side hide right-side panel * chore(useNewConvo): add partial typing for preset * fix(useSelectAssistant): pass correct model name by using template as preset * WIP: assistant presets * refactor(ToolService): add native solution for `TavilySearchResults` and log tool output errors * refactor: organize imports and use native TavilySearchResults * fix(TavilySearchResults): stringify result * fix(ToolCall): show tool call outputs when not an action * chore: rename Prompt Prefix to custom instructions (in user facing text only) * refactor(EditPresetDialog): Optimize setting title by debouncing, reset preset on dialog close to avoid state mixture * feat: add `presetOverride` to overwrite active conversation settings when saving a Preset (relevant for client side updates only) * feat: Assistant preset settings (client-side) * fix(Switcher): only set assistant_id and model if current endpoint is Assistants * feat: use `useDebouncedInput` for updating conversation settings, starting with EditPresetDialog title setting and Assistant instructions setting * feat(Assistants): add instructions field to settings * feat(chat/assistants): pass conversation settings to run body * wip: begin localization and only allow actions if the assistant is created * refactor(AssistantsPanel): knowledge localization, allow tools on creation * feat: experimental: allow 'priming' values before assistant is created, that would normally require an assistant_id to be defined * chore: trim console logs and make more meaningful * chore: toast messages * fix(ci): date test * feat: create file when uploading Assistant Avatar * feat: file upload rate limiting from custom config with dynamic file route initialization * refactor: use file upload limiters on post routes only * refactor(fileConfig): add endpoints field for endpoint specific fileconfigs, add mergeConfig function, add tests * refactor: fileConfig route, dynamic multer instances used on all '/' and '/images' POST routes, data service and query hook * feat: supportedMimeTypesSchema, test for array of regex * feat: configurable file config limits * chore: clarify assistants file knowledge prereq. * chore(useTextarea): default to localized 'Assistant' if assistant name is empty * feat: configurable file limits and toggle file upload per endpoint * fix(useUploadFileMutation): prevent updating assistant.files cache if file upload is a message_file attachment * fix(AssistantSelect): set last selected assistant only when timeout successfully runs * refactor(queries): disable assistant queries if assistants endpoint is not enabled * chore(Switcher): add localization * chore: pluralize `assistant` for `EModelEndpoint key and value * feat: show/hide assistant UI components based on endpoint availability; librechat.yaml config for disabling builder section and setting polling/timeout intervals * fix(compactEndpointSchemas): use EModelEndpoint for schema access * feat(runAssistant): use configured values from `librechat.yaml` for `pollIntervalMs` and `timeout` * fix: naming issue * wip: revert landing * 🎉 happy birthday LibreChat (#1768) * happy birthday LibreChat * Refactor endpoint condition in Landing component * Update birthday message in Eng.tsx * fix(/config): avoid nesting ternaries * refactor(/config): check birthday --------- Co-authored-by: Danny Avila <messagedaniel@protonmail.com> * fix: landing * fix: landing * fix(useMessageHelpers): hardcoded check to use EModelEndpoint instead * fix(ci): convo test revert to main * fix(assistants/chat): fix issue where assistant_id was being saved as model for convo * chore: added logging, promises racing to prevent longer timeouts, explicit setting of maxRetries and timeouts, robust catching of invalid abortRun params * refactor: use recoil state for `showStopButton` and only show for assistants endpoint after syncing conversation data * refactor: optimize abortRun strategy using localStorage, refactor `abortConversation` to use async/await and await the result, refactor how the abortKey cache is set for runs * fix(checkMessageGaps): assign `assistant_id` to synced messages if defined; prevents UI from showing blank assistant for cancelled messages * refactor: re-order sequence of chat route, only allow aborting messages after run is created, cancel abortRun if there was a cancelling error (likely due already cancelled in chat route), and add extra logging * chore(typedefs): add httpAgent type to OpenAIClient * refactor: use custom implementation of retrieving run with axios to allow for timing out run query * fix(waitForRun): handle timed out run retrieval query * refactor: update preset conditions: - presets will retain settings when a different endpoint is selected; for existing convos, either when modular or is assistant switch - no longer use `navigateToConvo` on preset select * fix: temporary calculator hack as expects string input when invoked * fix: cancel abortRun only when cancelling error is a result of the run already being cancelled * chore: remove use of `fileMaxSizeMB` and total counterpart (redundant) * docs: custom config documentation update * docs: assistants api setup and dotenv, new custom config fields * refactor(Switcher): make Assistant switcher sticky in SidePanel * chore(useSSE): remove console log of data and message index * refactor(AssistantPanel): button styling and add secondary select button to bottom of panel * refactor(OpenAIClient): allow passing conversationId to RunManager through titleConvo and initializeLLM to properly record title context tokens used in cases where conversationId was not defined by the client * feat(assistants): token tracking for assistant runs * chore(spendTokens): improve logging * feat: support/exclude specific assistant Ids * chore: add update `librechat.example.yaml`, optimize `AppService` handling, new tests for `AppService`, optimize missing/outdate config logging * chore: mount docker logs to root of project * chore: condense axios errors * chore: bump vite * chore: vite hot reload fix using latest version * chore(getOpenAIModels): sort instruct models to the end of models list * fix(assistants): user provided key * fix(assistants): user provided key, invalidate more queries on revoke --------- Co-authored-by: Marco Beretta <81851188+Berry-13@users.noreply.github.com>
738 lines
32 KiB
JavaScript
738 lines
32 KiB
JavaScript
/**
|
|
* @namespace typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports OpenAI
|
|
* @typedef {import('openai').OpenAI} OpenAI
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports Assistant
|
|
* @typedef {import('librechat-data-provider').Assistant} Assistant
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports AssistantDocument
|
|
* @typedef {import('librechat-data-provider').AssistantDocument} AssistantDocument
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports OpenAIFile
|
|
* @typedef {import('librechat-data-provider').File} OpenAIFile
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports TConfig
|
|
* @typedef {import('librechat-data-provider').TConfig} TConfig
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports TPlugin
|
|
* @typedef {import('librechat-data-provider').TPlugin} TPlugin
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports TCustomConfig
|
|
* @typedef {import('librechat-data-provider').TCustomConfig} TCustomConfig
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports TMessage
|
|
* @typedef {import('librechat-data-provider').TMessage} TMessage
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports TPlugin
|
|
* @typedef {import('librechat-data-provider').TPlugin} TPlugin
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports FileSources
|
|
* @typedef {import('librechat-data-provider').FileSources} FileSources
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports TMessage
|
|
* @typedef {import('librechat-data-provider').TMessage} TMessage
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports ImageFile
|
|
* @typedef {import('librechat-data-provider').ImageFile} ImageFile
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports ActionRequest
|
|
* @typedef {import('librechat-data-provider').ActionRequest} ActionRequest
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports Action
|
|
* @typedef {import('librechat-data-provider').Action} Action
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports ActionMetadata
|
|
* @typedef {import('librechat-data-provider').ActionMetadata} ActionMetadata
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports ActionAuth
|
|
* @typedef {import('librechat-data-provider').ActionAuth} ActionAuth
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports DeleteFilesBody
|
|
* @typedef {import('librechat-data-provider').DeleteFilesBody} DeleteFilesBody
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports FileMetadata
|
|
* @typedef {Object} FileMetadata
|
|
* @property {string} file_id - The identifier of the file.
|
|
* @property {string} [temp_file_id] - The temporary identifier of the file.
|
|
* @property {string} endpoint - The conversation endpoint origin for the file upload.
|
|
* @property {string} [assistant_id] - The assistant ID if file upload is in the `knowledge` context.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Object} ImageOnlyMetadata
|
|
* @property {number} width - The width of the image.
|
|
* @property {number} height - The height of the image.
|
|
*
|
|
* @typedef {FileMetadata & ImageOnlyMetadata} ImageMetadata
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports MongoFile
|
|
* @typedef {import('~/models/schema/fileSchema.js').MongoFile} MongoFile
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports AssistantCreateParams
|
|
* @typedef {import('librechat-data-provider').AssistantCreateParams} AssistantCreateParams
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports AssistantUpdateParams
|
|
* @typedef {import('librechat-data-provider').AssistantUpdateParams} AssistantUpdateParams
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports AssistantListParams
|
|
* @typedef {import('librechat-data-provider').AssistantListParams} AssistantListParams
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports AssistantListResponse
|
|
* @typedef {import('librechat-data-provider').AssistantListResponse} AssistantListResponse
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports ContentPart
|
|
* @typedef {import('librechat-data-provider').ContentPart} ContentPart
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports StepTypes
|
|
* @typedef {import('librechat-data-provider').StepTypes} StepTypes
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports TContentData
|
|
* @typedef {import('librechat-data-provider').TContentData} TContentData
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports ContentPart
|
|
* @typedef {import('librechat-data-provider').ContentPart} ContentPart
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports PartMetadata
|
|
* @typedef {import('librechat-data-provider').PartMetadata} PartMetadata
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports ThreadMessage
|
|
* @typedef {import('openai').OpenAI.Beta.Threads.ThreadMessage} ThreadMessage
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports TAssistantEndpoint
|
|
* @typedef {import('librechat-data-provider').TAssistantEndpoint} TAssistantEndpoint
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* Represents details of the message creation by the run step, including the ID of the created message.
|
|
*
|
|
* @exports MessageCreationStepDetails
|
|
* @typedef {Object} MessageCreationStepDetails
|
|
* @property {Object} message_creation - Details of the message creation.
|
|
* @property {string} message_creation.message_id - The ID of the message that was created by this run step.
|
|
* @property {'message_creation'} type - Always 'message_creation'.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* Represents a text log output from the Code Interpreter tool call.
|
|
* @typedef {Object} CodeLogOutput
|
|
* @property {'logs'} type - Always 'logs'.
|
|
* @property {string} logs - The text output from the Code Interpreter tool call.
|
|
*/
|
|
|
|
/**
|
|
* Represents an image output from the Code Interpreter tool call.
|
|
* @typedef {Object} CodeImageOutput
|
|
* @property {'image'} type - Always 'image'.
|
|
* @property {Object} image - The image object.
|
|
* @property {string} image.file_id - The file ID of the image.
|
|
*/
|
|
|
|
/**
|
|
* Details of the Code Interpreter tool call the run step was involved in.
|
|
* Includes the tool call ID, the code interpreter definition, and the type of tool call.
|
|
*
|
|
* @typedef {Object} CodeToolCall
|
|
* @property {string} id - The ID of the tool call.
|
|
* @property {Object} code_interpreter - The Code Interpreter tool call definition.
|
|
* @property {string} code_interpreter.input - The input to the Code Interpreter tool call.
|
|
* @property {Array<(CodeLogOutput | CodeImageOutput)>} code_interpreter.outputs - The outputs from the Code Interpreter tool call.
|
|
* @property {'code_interpreter'} type - The type of tool call, always 'code_interpreter'.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* Details of a Function tool call the run step was involved in.
|
|
* Includes the tool call ID, the function definition, and the type of tool call.
|
|
*
|
|
* @typedef {Object} FunctionToolCall
|
|
* @property {string} id - The ID of the tool call object.
|
|
* @property {Object} function - The definition of the function that was called.
|
|
* @property {string} function.arguments - The arguments passed to the function.
|
|
* @property {string} function.name - The name of the function.
|
|
* @property {string|null} function.output - The output of the function, null if not submitted.
|
|
* @property {'function'} type - The type of tool call, always 'function'.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* Details of a Retrieval tool call the run step was involved in.
|
|
* Includes the tool call ID and the type of tool call.
|
|
*
|
|
* @typedef {Object} RetrievalToolCall
|
|
* @property {string} id - The ID of the tool call object.
|
|
* @property {unknown} retrieval - An empty object for now.
|
|
* @property {'retrieval'} type - The type of tool call, always 'retrieval'.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* Details of the tool calls involved in a run step.
|
|
* Can be associated with one of three types of tools: `code_interpreter`, `retrieval`, or `function`.
|
|
*
|
|
* @typedef {Object} ToolCallsStepDetails
|
|
* @property {Array<CodeToolCall | RetrievalToolCall | FunctionToolCall>} tool_calls - An array of tool calls the run step was involved in.
|
|
* @property {'tool_calls'} type - Always 'tool_calls'.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* Details of the tool calls involved in a run step.
|
|
* Can be associated with one of three types of tools: `code_interpreter`, `retrieval`, or `function`.
|
|
*
|
|
* @exports StepToolCall
|
|
* @typedef {(CodeToolCall | RetrievalToolCall | FunctionToolCall) & PartMetadata} StepToolCall
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* Represents a tool call object required for certain actions in the OpenAI API,
|
|
* including the function definition and type of the tool call.
|
|
*
|
|
* @exports RequiredActionFunctionToolCall
|
|
* @typedef {Object} RequiredActionFunctionToolCall
|
|
* @property {string} id - The ID of the tool call, referenced when submitting tool outputs.
|
|
* @property {Object} function - The function definition associated with the tool call.
|
|
* @property {string} function.arguments - The arguments that the model expects to be passed to the function.
|
|
* @property {string} function.name - The name of the function.
|
|
* @property {'function'} type - The type of tool call the output is required for, currently always 'function'.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports RunManager
|
|
* @typedef {import('./server/services/Runs/RunManager.js').RunManager} RunManager
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports Thread
|
|
* @typedef {Object} Thread
|
|
* @property {string} id - The identifier of the thread.
|
|
* @property {'thread'} object - The object type, always 'thread'.
|
|
* @property {number} created_at - The Unix timestamp (in seconds) for when the thread was created.
|
|
* @property {Object} [metadata] - Optional metadata associated with the thread.
|
|
* @property {Message[]} [messages] - An array of messages associated with the thread.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports Message
|
|
* @typedef {Object} Message
|
|
* @property {string} id - The identifier of the message.
|
|
* @property {'thread.message'} object - The object type, always 'thread.message'.
|
|
* @property {number} created_at - The Unix timestamp (in seconds) for when the message was created.
|
|
* @property {string} thread_id - The thread ID that this message belongs to.
|
|
* @property {'user'|'assistant'} role - The entity that produced the message. One of 'user' or 'assistant'.
|
|
* @property {Object[]} content - The content of the message in an array of text and/or images.
|
|
* @property {'text'|'image_file'} content[].type - The type of content, either 'text' or 'image_file'.
|
|
* @property {Object} [content[].text] - The text content, present if type is 'text'.
|
|
* @property {string} content[].text.value - The data that makes up the text.
|
|
* @property {Object[]} [content[].text.annotations] - Annotations for the text content.
|
|
* @property {Object} [content[].image_file] - The image file content, present if type is 'image_file'.
|
|
* @property {string} content[].image_file.file_id - The File ID of the image in the message content.
|
|
* @property {string[]} [file_ids] - Optional list of File IDs for the message.
|
|
* @property {string|null} [assistant_id] - If applicable, the ID of the assistant that authored this message.
|
|
* @property {string|null} [run_id] - If applicable, the ID of the run associated with the authoring of this message.
|
|
* @property {Object} [metadata] - Optional metadata for the message, a map of key-value pairs.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports UserMessageContent
|
|
* @typedef {Object} UserMessageContent
|
|
* @property {Object[]} content - The content of the message in an array of text and/or images.
|
|
* @property {string} content[].type - The type of content, either 'text' or 'image_file'.
|
|
* @property {Object} [content[].text] - The text content, present if type is 'text'.
|
|
* @property {string} content[].text.value - The data that makes up the text.
|
|
* @property {Object} [content[].image_url] - The image file content, present if type is 'image_file'.
|
|
* @property {string} content[].image_url.url - The File ID of the image in the message content.
|
|
* @property {'auto' | 'low' | 'high'} content[].image_url.detail: 'auto' - the quality to use for the image, either 'auto', 'low', or 'high'.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* Represents a message payload with various potential properties,
|
|
* including roles, sender information, and content.
|
|
*
|
|
* @typedef {Object} PayloadMessage
|
|
* @property {string} [role] - The role of the message sender (e.g., 'user', 'assistant').
|
|
* @property {string} [name] - The name associated with the message.
|
|
* @property {string} [sender] - The sender of the message.
|
|
* @property {string} [text] - The text content of the message.
|
|
* @property {(string|Array<UserMessageContent>)} [content] - The content of the message, which could be a string or an array of the 'content' property from the Message type.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports FunctionTool
|
|
* @typedef {Object} FunctionTool
|
|
* @property {'function'} type - The type of tool, 'function'.
|
|
* @property {Object} function - The function definition.
|
|
* @property {string} function.description - A description of what the function does.
|
|
* @property {string} function.name - The name of the function to be called.
|
|
* @property {Object} function.parameters - The parameters the function accepts, described as a JSON Schema object.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports Tool
|
|
* @typedef {Object} Tool
|
|
* @property {'code_interpreter'|'retrieval'|'function'} type - The type of tool, can be 'code_interpreter', 'retrieval', or 'function'.
|
|
* @property {FunctionTool} [function] - The function tool, present if type is 'function'.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports Run
|
|
* @typedef {Object} Run
|
|
* @property {string} id - The identifier of the run.
|
|
* @property {string} object - The object type, always 'thread.run'.
|
|
* @property {number} created_at - The Unix timestamp (in seconds) for when the run was created.
|
|
* @property {string} thread_id - The ID of the thread that was executed on as a part of this run.
|
|
* @property {string} assistant_id - The ID of the assistant used for execution of this run.
|
|
* @property {'queued'|'in_progress'|'requires_action'|'cancelling'|'cancelled'|'failed'|'completed'|'expired'} status - The status of the run: queued, in_progress, requires_action, cancelling, cancelled, failed, completed, or expired.
|
|
* @property {Object} [required_action] - Details on the action required to continue the run.
|
|
* @property {string} required_action.type - The type of required action, always 'submit_tool_outputs'.
|
|
* @property {Object} required_action.submit_tool_outputs - Details on the tool outputs needed for the run to continue.
|
|
* @property {Object[]} required_action.submit_tool_outputs.tool_calls - A list of the relevant tool calls.
|
|
* @property {string} required_action.submit_tool_outputs.tool_calls[].id - The ID of the tool call.
|
|
* @property {string} required_action.submit_tool_outputs.tool_calls[].type - The type of tool call the output is required for, always 'function'.
|
|
* @property {Object} required_action.submit_tool_outputs.tool_calls[].function - The function definition.
|
|
* @property {string} required_action.submit_tool_outputs.tool_calls[].function.name - The name of the function.
|
|
* @property {string} required_action.submit_tool_outputs.tool_calls[].function.arguments - The arguments that the model expects you to pass to the function.
|
|
* @property {Object} [last_error] - The last error associated with this run.
|
|
* @property {string} last_error.code - One of 'server_error' or 'rate_limit_exceeded'.
|
|
* @property {string} last_error.message - A human-readable description of the error.
|
|
* @property {number} [expires_at] - The Unix timestamp (in seconds) for when the run will expire.
|
|
* @property {number} [started_at] - The Unix timestamp (in seconds) for when the run was started.
|
|
* @property {number} [cancelled_at] - The Unix timestamp (in seconds) for when the run was cancelled.
|
|
* @property {number} [failed_at] - The Unix timestamp (in seconds) for when the run failed.
|
|
* @property {number} [completed_at] - The Unix timestamp (in seconds) for when the run was completed.
|
|
* @property {string} [model] - The model that the assistant used for this run.
|
|
* @property {string} [instructions] - The instructions that the assistant used for this run.
|
|
* @property {string} [additional_instructions] - Optional. Appends additional instructions
|
|
* at theend of the instructions for the run. This is useful for modifying
|
|
* @property {Tool[]} [tools] - The list of tools used for this run.
|
|
* @property {string[]} [file_ids] - The list of File IDs used for this run.
|
|
* @property {Object} [metadata] - Metadata associated with this run.
|
|
* @property {Object} [usage] - Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).
|
|
* @property {number} [usage.completion_tokens] - Number of completion tokens used over the course of the run.
|
|
* @property {number} [usage.prompt_tokens] - Number of prompt tokens used over the course of the run.
|
|
* @property {number} [usage.total_tokens] - Total number of tokens used (prompt + completion).
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports RunStep
|
|
* @typedef {Object} RunStep
|
|
* @property {string} id - The identifier of the run step.
|
|
* @property {string} object - The object type, always 'thread.run.step'.
|
|
* @property {number} created_at - The Unix timestamp (in seconds) for when the run step was created.
|
|
* @property {string} assistant_id - The ID of the assistant associated with the run step.
|
|
* @property {string} thread_id - The ID of the thread that was run.
|
|
* @property {string} run_id - The ID of the run that this run step is a part of.
|
|
* @property {'message_creation' | 'tool_calls'} type - The type of run step.
|
|
* @property {'in_progress' | 'cancelled' | 'failed' | 'completed' | 'expired'} status - The status of the run step.
|
|
* @property {MessageCreationStepDetails | ToolCallsStepDetails} step_details - The details of the run step.
|
|
* @property {Object} [last_error] - The last error associated with this run step.
|
|
* @property {'server_error' | 'rate_limit_exceeded'} last_error.code - One of 'server_error' or 'rate_limit_exceeded'.
|
|
* @property {string} last_error.message - A human-readable description of the error.
|
|
* @property {number} [expired_at] - The Unix timestamp (in seconds) for when the run step expired.
|
|
* @property {number} [cancelled_at] - The Unix timestamp (in seconds) for when the run step was cancelled.
|
|
* @property {number} [failed_at] - The Unix timestamp (in seconds) for when the run step failed.
|
|
* @property {number} [completed_at] - The Unix timestamp (in seconds) for when the run step completed.
|
|
* @property {Object} [metadata] - Metadata associated with this run step, a map of up to 16 key-value pairs.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports StepMessage
|
|
* @typedef {Object} StepMessage
|
|
* @property {Message} message - The complete message object created by the step.
|
|
* @property {string} id - The identifier of the run step.
|
|
* @property {string} object - The object type, always 'thread.run.step'.
|
|
* @property {number} created_at - The Unix timestamp (in seconds) for when the run step was created.
|
|
* @property {string} assistant_id - The ID of the assistant associated with the run step.
|
|
* @property {string} thread_id - The ID of the thread that was run.
|
|
* @property {string} run_id - The ID of the run that this run step is a part of.
|
|
* @property {'message_creation'|'tool_calls'} type - The type of run step, either 'message_creation' or 'tool_calls'.
|
|
* @property {'in_progress'|'cancelled'|'failed'|'completed'|'expired'} status - The status of the run step, can be 'in_progress', 'cancelled', 'failed', 'completed', or 'expired'.
|
|
* @property {Object} step_details - The details of the run step.
|
|
* @property {Object} [last_error] - The last error associated with this run step.
|
|
* @property {string} last_error.code - One of 'server_error' or 'rate_limit_exceeded'.
|
|
* @property {string} last_error.message - A human-readable description of the error.
|
|
* @property {number} [expired_at] - The Unix timestamp (in seconds) for when the run step expired.
|
|
* @property {number} [cancelled_at] - The Unix timestamp (in seconds) for when the run step was cancelled.
|
|
* @property {number} [failed_at] - The Unix timestamp (in seconds) for when the run step failed.
|
|
* @property {number} [completed_at] - The Unix timestamp (in seconds) for when the run step completed.
|
|
* @property {Object} [metadata] - Metadata associated with this run step, a map of up to 16 key-value pairs.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports AgentAction
|
|
* @typedef {Object} AgentAction
|
|
* @property {string} tool - The name of the tool used.
|
|
* @property {string} toolInput - The input provided to the tool.
|
|
* @property {string} log - A log or message associated with the action.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports AgentFinish
|
|
* @typedef {Object} AgentFinish
|
|
* @property {Record<string, any>} returnValues - The return values of the agent's execution.
|
|
* @property {string} log - A log or message associated with the finish.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports OpenAIAssistantFinish
|
|
* @typedef {AgentFinish & { run_id: string; thread_id: string; }} OpenAIAssistantFinish
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports OpenAIAssistantAction
|
|
* @typedef {AgentAction & { toolCallId: string; run_id: string; thread_id: string; }} OpenAIAssistantAction
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports EndpointServiceConfig
|
|
* @typedef {Object} EndpointServiceConfig
|
|
* @property {string} openAIApiKey - The API key for OpenAI.
|
|
* @property {string} azureOpenAIApiKey - The API key for Azure OpenAI.
|
|
* @property {boolean} useAzurePlugins - Flag to indicate if Azure plugins are used.
|
|
* @property {boolean} userProvidedOpenAI - Flag to indicate if OpenAI API key is user provided.
|
|
* @property {string} googleKey - The Palm key.
|
|
* @property {boolean|{userProvide: boolean}} [openAI] - Flag to indicate if OpenAI endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [assistant] - Flag to indicate if Assistant endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [azureOpenAI] - Flag to indicate if Azure OpenAI endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [chatGPTBrowser] - Flag to indicate if ChatGPT Browser endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [anthropic] - Flag to indicate if Anthropic endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [bingAI] - Flag to indicate if BingAI endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [google] - Flag to indicate if BingAI endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean, userProvideURL: boolean, name: string}} [custom] - Custom Endpoint configuration.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports Plugin
|
|
* @typedef {Object} Plugin
|
|
* @property {string} pluginKey - The key of the plugin.
|
|
* @property {string} name - The name of the plugin.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports GptPlugins
|
|
* @typedef {Object} GptPlugins
|
|
* @property {Plugin[]} plugins - An array of plugins available.
|
|
* @property {string[]} availableAgents - Available agents, 'classic' or 'functions'.
|
|
* @property {boolean} userProvide - A flag indicating if the user has provided the data.
|
|
* @property {boolean} azure - A flag indicating if azure plugins are used.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports DefaultConfig
|
|
* @typedef {Object} DefaultConfig
|
|
* @property {boolean|{userProvide: boolean}} [openAI] - Flag to indicate if OpenAI endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [assistant] - Flag to indicate if Assistant endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [azureOpenAI] - Flag to indicate if Azure OpenAI endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [chatGPTBrowser] - Flag to indicate if ChatGPT Browser endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [anthropic] - Flag to indicate if Anthropic endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [bingAI] - Flag to indicate if BingAI endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean}} [google] - Flag to indicate if Google endpoint is user provided, or its configuration.
|
|
* @property {boolean|{userProvide: boolean, userProvideURL: boolean, name: string}} [custom] - Custom Endpoint configuration.
|
|
* @property {boolean|GptPlugins} [gptPlugins] - Configuration for GPT plugins.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports EndpointConfig
|
|
* @typedef {boolean|TConfig} EndpointConfig
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports EndpointWithOrder
|
|
* @typedef {Object} EndpointWithOrder
|
|
* @property {EndpointConfig} config - The configuration of the endpoint.
|
|
* @property {number} order - The order of the endpoint.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports RequiredAction
|
|
* @typedef {Object} RequiredAction
|
|
* @property {string} tool - The name of the function.
|
|
* @property {Object} toolInput - The args to invoke the function with.
|
|
* @property {string} toolCallId - The ID of the tool call.
|
|
* @property {Run['id']} run_id - Run identifier.
|
|
* @property {Thread['id']} thread_id - Thread identifier.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports StructuredTool
|
|
* @typedef {Object} StructuredTool
|
|
* @property {string} name - The name of the function.
|
|
* @property {string} description - The description of the function.
|
|
* @property {import('zod').ZodTypeAny} schema - The structured zod schema.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports ToolOutput
|
|
* @typedef {Object} ToolOutput
|
|
* @property {string} tool_call_id - The ID of the tool call.
|
|
* @property {Object} output - The output of the tool, which can vary in structure.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @exports ToolOutputs
|
|
* @typedef {Object} ToolOutputs
|
|
* @property {ToolOutput[]} tool_outputs - Array of tool outputs.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Object} ModelOptions
|
|
* @property {string} modelName - The name of the model.
|
|
* @property {number} [temperature] - The temperature setting for the model.
|
|
* @property {number} [presence_penalty] - The presence penalty setting.
|
|
* @property {number} [frequency_penalty] - The frequency penalty setting.
|
|
* @property {number} [max_tokens] - The maximum number of tokens to generate.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Object} ConfigOptions
|
|
* @property {string} [basePath] - The base path for the API requests.
|
|
* @property {Object} [baseOptions] - Base options for the API requests, including headers.
|
|
* @property {Object} [httpAgent] - The HTTP agent for the request.
|
|
* @property {Object} [httpsAgent] - The HTTPS agent for the request.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Object} Callbacks
|
|
* @property {Function} [handleChatModelStart] - A callback function for handleChatModelStart
|
|
* @property {Function} [handleLLMEnd] - A callback function for handleLLMEnd
|
|
* @property {Function} [handleLLMError] - A callback function for handleLLMError
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Object} AzureOptions
|
|
* @property {string} [azureOpenAIApiKey] - The Azure OpenAI API key.
|
|
* @property {string} [azureOpenAIApiInstanceName] - The Azure OpenAI API instance name.
|
|
* @property {string} [azureOpenAIApiDeploymentName] - The Azure OpenAI API deployment name.
|
|
* @property {string} [azureOpenAIApiVersion] - The Azure OpenAI API version.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Object} TokenConfig
|
|
* A configuration object mapping model keys to their respective prompt, completion rates, and context limit.
|
|
* @property {number} prompt - The prompt rate
|
|
* @property {number} completion - The completion rate
|
|
* @property {number} context - The maximum context length supported by the model.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Record<string, TokenConfig>} EndpointTokenConfig
|
|
* An endpoint's config object mapping model keys to their respective prompt, completion rates, and context limit.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Object} ResponseMessage
|
|
* @property {string} conversationId - The ID of the conversation.
|
|
* @property {string} thread_id - The ID of the thread.
|
|
* @property {string} messageId - The ID of the message (from LibreChat).
|
|
* @property {string} parentMessageId - The ID of the parent message.
|
|
* @property {string} user - The ID of the user.
|
|
* @property {string} assistant_id - The ID of the assistant.
|
|
* @property {string} role - The role of the response.
|
|
* @property {string} model - The model used in the response.
|
|
* @property {ContentPart[]} content - The content parts accumulated from the run.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Object} RunResponse
|
|
* @property {Run} run - The detailed information about the run.
|
|
* @property {RunStep[]} steps - An array of steps taken during the run.
|
|
* @property {StepMessage[]} messages - An array of messages related to the run.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
/**
|
|
* @callback InProgressFunction
|
|
* @param {Object} params - The parameters for the in progress step.
|
|
* @param {RunStep} params.step - The step object with details about the message creation.
|
|
* @returns {Promise<void>} - A promise that resolves when the step is processed.
|
|
* @memberof typedefs
|
|
*/
|
|
|
|
// /**
|
|
// * @typedef {OpenAI & {
|
|
// * req: Express.Request,
|
|
// * res: Express.Response
|
|
// * getPartialText: () => string,
|
|
// * processedFileIds: Set<string>,
|
|
// * mappedOrder: Map<string, number>,
|
|
// * completeToolCallSteps: Set<string>,
|
|
// * seenCompletedMessages: Set<string>,
|
|
// * seenToolCalls: Map<string, StepToolCall>,
|
|
// * progressCallback: (options: Object) => void,
|
|
// * addContentData: (data: TContentData) => void,
|
|
// * responseMessage: ResponseMessage,
|
|
// * }} OpenAIClient - for reference only
|
|
// */
|
|
|
|
/**
|
|
* @typedef {Object} OpenAIClientType
|
|
*
|
|
* @property {Express.Request} req - The Express request object.
|
|
* @property {Express.Response} res - The Express response object.
|
|
* @property {?import('https-proxy-agent').HttpsProxyAgent} httpAgent - An optional HTTP proxy agent for the request.
|
|
|
|
* @property {() => string} getPartialText - Retrieves the current tokens accumulated by `progressCallback`.
|
|
*
|
|
* Note: not used until real streaming is implemented by OpenAI.
|
|
*
|
|
* @property {string} responseText -The accumulated text values for the current run.
|
|
* @property {Set<string>} processedFileIds - A set of IDs for processed files.
|
|
* @property {Map<string, number>} mappedOrder - A map to maintain the order of individual `tool_calls` and `steps`.
|
|
* @property {Set<string>} [attachedFileIds] - A set of user attached file ids; necessary to track which files are downloadable.
|
|
* @property {Set<string>} completeToolCallSteps - A set of completed tool call steps.
|
|
* @property {Set<string>} seenCompletedMessages - A set of completed messages that have been seen/processed.
|
|
* @property {Map<string, StepToolCall>} seenToolCalls - A map of tool calls that have been seen/processed.
|
|
* @property {(data: TContentData) => void} addContentData - Updates the response message's relevant
|
|
* @property {InProgressFunction} in_progress - Updates the response message's relevant
|
|
* content array with the part by index & sends intermediate SSE message with content data.
|
|
*
|
|
* Note: does not send intermediate SSE message for messages, which are streamed
|
|
* (may soon be streamed) directly from OpenAI API.
|
|
*
|
|
* @property {ResponseMessage} responseMessage - A message object for responses.
|
|
*
|
|
* @typedef {OpenAI & OpenAIClientType} OpenAIClient
|
|
*/
|
|
|
|
/**
|
|
* The body of the request to create a run, specifying the assistant, model,
|
|
* instructions, and any additional parameters needed for the run.
|
|
*
|
|
* @typedef {Object} CreateRunBody
|
|
* @property {string} assistant_id - The ID of the assistant to use for this run.
|
|
* @property {string} [model] - Optional. The ID of the model to be used for this run.
|
|
* @property {string} [instructions] - Optional. Override the default system message of the assistant.
|
|
* @property {string} [additional_instructions] - Optional. Appends additional instructions
|
|
* at the end of the instructions for the run. Useful for modifying behavior on a per-run basis without overriding other instructions.
|
|
* @property {Object[]} [tools] - Optional. Override the tools the assistant can use for this run. Should include tool call ID and the type of tool call.
|
|
* @property {string[]} [file_ids] - Optional. List of File IDs the assistant can use for this run.
|
|
* **Note:** The API seems to prefer files added to messages, not runs.
|
|
* @property {Object} [metadata] - Optional. Metadata for the run.
|
|
* @memberof typedefs
|
|
*/
|