📥 feat: Import Conversations from LibreChat, ChatGPT, Chatbot UI (#2355)

* Basic implementation of ChatGPT conversation import

* remove debug code

* Handle citations

* Fix updatedAt in import

* update default model

* Use job scheduler to handle import requests

* import job status endpoint

* Add wrapper around Agenda

* Rate limits for import endpoint

* rename import api path

* Batch save import to mongo

* Improve naming

* Add documenting comments

* Test for importers

* Change button for importing conversations

* Frontend changes

* Import job status endpoint

* Import endpoint response

* Add translations to new phrases

* Fix conversations refreshing

* cleanup unused functions

* set timeout for import job status polling

* Add documentation

* get extra spaces back

* Improve error message

* Fix translation files after merge

* fix translation files 2

* Add zh translation for import functionality

* Sync mailisearch index after import

* chore: add dummy uri for jest tests, as MONGO_URI should only be real for E2E tests

* docs: fix links

* docs: fix conversationsImport section

* fix: user role issue for librechat imports

* refactor: import conversations from json
- organize imports
- add additional jsdocs
- use multer with diskStorage to avoid loading file into memory outside of job
- use filepath instead of loading data string for imports
- replace console logs and some logger.info() with logger.debug
- only use multer for import route

* fix: undefined metadata edge case and replace ChatGtp -> ChatGpt

* Refactor importChatGptConvo function to handle undefined metadata edge case and replace ChatGtp with ChatGpt

* fix: chatgpt importer

* feat: maintain tree relationship for librechat messages

* chore: use enum

* refactor: saveMessage to use single object arg, replace console logs, add userId to log message

* chore: additional comment

* chore: multer edge case

* feat: first pass, maintain tree relationship

* chore: organize

* chore: remove log

* ci: add heirarchy test for chatgpt

* ci: test maintaining of heirarchy for librechat

* wip: allow non-text content type messages

* refactor: import content part object json string

* refactor: more content types to format

* chore: consolidate messageText formatting

* docs: update on changes, bump data-provider/config versions, update readme

* refactor(indexSync): singleton pattern for MeiliSearchClient

* refactor: debug log after batch is done

* chore: add back indexSync error handling

---------

Co-authored-by: jakubmieszczak <jakub.mieszczak@zendesk.com>
Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
Denis Palnitsky 2024-05-02 08:48:26 +02:00 committed by GitHub
parent 3b44741cf9
commit ab6fbe48f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
64 changed files with 3795 additions and 98 deletions

View file

@ -1202,3 +1202,58 @@
* @property {OllamaModel[]} models - the list of models available.
* @memberof typedefs
*/
/**
* @typedef {Object} ChatGPTAuthor
* @property {string} role - The role of the author (e.g., 'assistant', 'system', 'user').
* @property {?string} name - The name of the author, if available.
* @property {Object} metadata - Additional metadata related to the author.
* @memberof typedefs
*/
/**
* @typedef {Object} ChatGPTContentPart
* @property {string} content_type - The type of content (e.g., 'text').
* @property {string[]} parts - The textual parts of the message.
* @memberof typedefs
*/
/**
* @typedef {Object} ChatGPTMetadata
* @property {boolean} is_visually_hidden_from_conversation - Indicates if the message should be hidden.
* @property {?Array<Object>} citations - Potential citations included in the message.
* @memberof typedefs
*/
/**
* @typedef {Object} ChatGPTMessage
* @property {string} id - Unique identifier for the message.
* @property {?ChatGPTAuthor} author - The author of the message.
* @property {?number} create_time - Creation time as a Unix timestamp.
* @property {?number} update_time - Last update time as a Unix timestamp.
* @property {ChatGPTContentPart} content - Content of the message.
* @property {string} status - Status of the message (e.g., 'finished_successfully').
* @property {boolean} end_turn - Indicates if it's the end of a conversation turn.
* @property {number} weight - A numerical value representing the weight/importance of the message.
* @property {ChatGPTMetadata} metadata - Metadata associated with the message.
* @property {string} recipient - Intended recipient of the message.
* @memberof typedefs
*/
/**
* @typedef {Object} ChatGPTMapping
* @property {ChatGPTMessage} message - Details of the message.
* @property {string} id - Identifier of the message.
* @property {?string} parent - Parent message ID.
* @property {string[]} children - Child message IDs.
* @memberof typedefs
*/
/**
* @typedef {Object} ChatGPTConvo
* @property {string} title - Title of the conversation.
* @property {number} create_time - Creation time of the conversation as a Unix timestamp.
* @property {number} update_time - Last update time of the conversation as a Unix timestamp.
* @property {Object.<string, ChatGPTMapping>} mapping - Mapping of message nodes within the conversation.
* @memberof typedefs
*/