diff --git a/docs/guides/memory/use_memory.md b/docs/guides/memory/use_memory.md index 8af1051f54..492bfbdff6 100644 --- a/docs/guides/memory/use_memory.md +++ b/docs/guides/memory/use_memory.md @@ -50,7 +50,7 @@ What is stored in the memory: ### Memory size -The default capacity allocated to the memory and the corresponding embeddings in bytes. Defaults to `5242880` (5MB). +The default capacity allocated to the memory and the corresponding embeddings in bytes. Defaults to `5242880` (5MB). :::tip NOTE A 1KB message with a 1024-dimension embedding occupies approximately 9KB of memory (1KB + 1024 x 8Bytes = 9KB). With a default limit of 5 MB, the system can store roughly 500 such messages. @@ -74,7 +74,7 @@ Manually forgotten memory entries are completely excluded from the results retur When the Memory reaches its storage limit and the automatic forgetting policy is applied, entries that were previously forgotten manually are also prioritized for removal. This allows the system to reclaim capacity more intelligently while respecting earlier user curation decisions. -## Enhance Agent context +## Enhance Agent context Under [Retrieval](../agent/agent_component_reference/retrieval.mdx) and [Message](../agent/agent_component_reference/message.md) component settings, a new Memory invocation capability is available. In the Message component, users can configure the Agent to write selected data into a designated Memory, while the Retrieval component can be set to read from that same Memory to answer future queries. This enables a simple Q&A bot Agent to accumulate context over time and respond with richer, memory-aware answers. diff --git a/docs/references/http_api_reference.md b/docs/references/http_api_reference.md index 077f42fc6e..5fc8c8b231 100644 --- a/docs/references/http_api_reference.md +++ b/docs/references/http_api_reference.md @@ -4216,8 +4216,8 @@ curl --request POST \ Optional model override when a specific chat model should be used for this request. - `"pass_all_history_messages"`: (*Body Parameter*), `boolean` When `chat_id` and `session_id` are provided, defaults to `false`, so the server uses stored session history and only the latest user message from the request. Set to `true` to replace/use the submitted full `messages` history, and overrides the stored session history. -- `"legacy"`: (*Body Parameter*), `boolean` - Defaults to `false`. Enables backward compatibility with RAGFlow v0.23.0 for streaming responses. When set to `true`: +- `"legacy"`: (*Body Parameter*), `boolean` + Defaults to `false`. Enables backward compatibility with RAGFlow v0.23.0 for streaming responses. When set to `true`: - Cumulative output: The `"answer"` field in each chunk returns the entire text generated so far, rather than just the new tokens (deltas). - No reasoning markers: The `start_to_think` and `end_to_think` signals are stripped from the stream. @@ -4801,7 +4801,7 @@ curl --request POST \ Variables specified in the **Begin** component. - `"user_id"`: (*Body parameter*), `string` The optional user-defined ID. Valid *only* when no `session_id` is provided. -- `"chat_template_kwargs"`: (*Body parameter*), `object` +- `"chat_template_kwargs"`: (*Body parameter*), `object` Optional passthrough parameters for the underlying LLM's chat template. Commonly used to toggle thinking/reasoning modes on supported models (e.g., `{"enable_thinking": false}`). :::tip NOTE @@ -4926,19 +4926,19 @@ curl --request POST \ ##### Request parameters -- `"agent_id"`: (*Body parameter*), `string`, *Required* +- `"agent_id"`: (*Body parameter*), `string`, *Required* The ID of the associated agent. -- `"messages"`: (*Body parameter*), `list[object]`, *Required* +- `"messages"`: (*Body parameter*), `list[object]`, *Required* OpenAI-style chat messages. -- `"openai-compatible"`: (*Body parameter*), `boolean`, *Required* +- `"openai-compatible"`: (*Body parameter*), `boolean`, *Required* Must be `true` to enable OpenAI-compatible responses. -- `"stream"`: (*Body parameter*), `boolean` +- `"stream"`: (*Body parameter*), `boolean` Whether to return streaming chunks. -- `"session_id"`: (*Body parameter*), `string` +- `"session_id"`: (*Body parameter*), `string` Optional existing session ID. -- `"model"`: (*Body parameter*), `string` +- `"model"`: (*Body parameter*), `string` Optional compatibility field. The server still routes by `agent_id`. -- `"chat_template_kwargs"`: (*Body parameter*), `object` +- `"chat_template_kwargs"`: (*Body parameter*), `object` Optional passthrough parameters for the underlying LLM's chat template. Commonly used to toggle thinking/reasoning modes on supported models (e.g., `{"enable_thinking": false}`). ##### Response @@ -7709,7 +7709,7 @@ or **POST** `/api/v1/folders/{folder_id}/commits` -Creates a new snapshot commit for the specified folder. +Creates a new snapshot commit for the specified folder. This endpoint also supports: - `/api/v1/workspace/{workspace_id}/commits` (alias, workspace_id == folder_id) - `/api/v1/datasets/{dataset_id}/commits` (resolves dataset to its folder) @@ -7721,9 +7721,9 @@ This endpoint also supports: - Headers: - `'Authorization: Bearer '` - Body: - - `'message'`: `string` (required) + - `'message'`: `string` (required) The commit message. - - `'files'`: `list[object]` (required) + - `'files'`: `list[object]` (required) The list of file changes. Each file change is an object with the following fields: ##### Request example @@ -7744,9 +7744,9 @@ curl --request POST \ ##### Request parameters -- `"message"`: (*Body parameter*), `string`, *Required* +- `"message"`: (*Body parameter*), `string`, *Required* The commit message describing the changes. -- `"files"`: (*Body parameter*), `list[object]`, *Required* +- `"files"`: (*Body parameter*), `list[object]`, *Required* Each file change object supports the following fields: | Field | Type | Required | Description | @@ -7797,7 +7797,7 @@ Failure: **GET** `/api/v1/folders/{folder_id}/commits` -Lists all commits for the specified folder with pagination. +Lists all commits for the specified folder with pagination. Also available at: - `/api/v1/workspace/{workspace_id}/commits` - `/api/v1/datasets/{dataset_id}/commits` @@ -7824,13 +7824,13 @@ curl --request GET \ ##### Request parameters -- `"page"`: (*Query parameter*), `int`, *Optional* +- `"page"`: (*Query parameter*), `int`, *Optional* Page number. Defaults to 1. -- `"page_size"`: (*Query parameter*), `int`, *Optional* +- `"page_size"`: (*Query parameter*), `int`, *Optional* Number of items per page. Defaults to 15. -- `"order_by"`: (*Query parameter*), `string`, *Optional* +- `"order_by"`: (*Query parameter*), `string`, *Optional* Sort field. Defaults to `"create_time"`. -- `"desc"`: (*Query parameter*), `bool`, *Optional* +- `"desc"`: (*Query parameter*), `bool`, *Optional* Sort descending. Defaults to `true`. #### Response @@ -7865,7 +7865,7 @@ Success: **GET** `/api/v1/folders/{folder_id}/commits/{commit_id}` -Retrieves the details of a specific commit, including its file changes. +Retrieves the details of a specific commit, including its file changes. Also available at: - `/api/v1/workspace/{workspace_id}/commits/{commit_id}` - `/api/v1/datasets/{dataset_id}/commits/{commit_id}` @@ -7887,9 +7887,9 @@ curl --request GET \ ##### Request parameters -- `"folder_id"`: (*Path parameter*), `string`, *Required* +- `"folder_id"`: (*Path parameter*), `string`, *Required* The folder ID. -- `"commit_id"`: (*Path parameter*), `string`, *Required* +- `"commit_id"`: (*Path parameter*), `string`, *Required* The commit ID. #### Response @@ -7936,7 +7936,7 @@ Failure: **GET** `/api/v1/folders/{folder_id}/commits/{commit_id}/files` -Lists the file changes associated with a specific commit. +Lists the file changes associated with a specific commit. Also available at: - `/api/v1/workspace/{workspace_id}/commits/{commit_id}/files` - `/api/v1/datasets/{dataset_id}/commits/{commit_id}/files` @@ -7985,7 +7985,7 @@ Success: **GET** `/api/v1/folders/{folder_id}/commits/diff?from={commit_id}&to={commit_id}` -Compares two commits and returns the differences. +Compares two commits and returns the differences. Also available at: - `/api/v1/workspace/{workspace_id}/commits/diff?from=...&to=...` - `/api/v1/datasets/{dataset_id}/commits/diff?from=...&to=...` @@ -7997,9 +7997,9 @@ Also available at: - Headers: - `'Authorization: Bearer '` - Query: - - `'from'`: `string` (required) + - `'from'`: `string` (required) The source commit ID. - - `'to'`: `string` (required) + - `'to'`: `string` (required) The target commit ID. ##### Request example @@ -8012,9 +8012,9 @@ curl --request GET \ ##### Request parameters -- `"from"`: (*Query parameter*), `string`, *Required* +- `"from"`: (*Query parameter*), `string`, *Required* The source commit ID. -- `"to"`: (*Query parameter*), `string`, *Required* +- `"to"`: (*Query parameter*), `string`, *Required* The target commit ID. #### Response @@ -8053,7 +8053,7 @@ Failure: **GET** `/api/v1/folders/{folder_id}/changes` -Returns the uncommitted changes for the specified folder (similar to `git status`). +Returns the uncommitted changes for the specified folder (similar to `git status`). Also available at: - `/api/v1/workspace/{workspace_id}/changes` - `/api/v1/datasets/{dataset_id}/changes` @@ -8106,7 +8106,7 @@ Success: **GET** `/api/v1/folders/{folder_id}/commits/{commit_id}/tree` -Retrieves the full folder tree snapshot as it existed at a specific commit. +Retrieves the full folder tree snapshot as it existed at a specific commit. Also available at: - `/api/v1/workspace/{workspace_id}/commits/{commit_id}/tree` - `/api/v1/datasets/{dataset_id}/commits/{commit_id}/tree` @@ -8174,7 +8174,7 @@ Success: **GET** `/api/v1/folders/{folder_id}/commits/{commit_id}/files/{file_id}/content` -Retrieves the file content as it existed at a specific commit. +Retrieves the file content as it existed at a specific commit. Also available at: - `/api/v1/workspace/{workspace_id}/commits/{commit_id}/files/{file_id}/content` - `/api/v1/datasets/{dataset_id}/commits/{commit_id}/files/{file_id}/content` diff --git a/docs/references/python_api_reference.md b/docs/references/python_api_reference.md index 6ae8c971a8..cd1fd49cff 100644 --- a/docs/references/python_api_reference.md +++ b/docs/references/python_api_reference.md @@ -129,7 +129,7 @@ RAGFlow.create_dataset( avatar: Optional[str] = None, description: Optional[str] = None, embedding_model: Optional[str] = "BAAI/bge-large-zh-v1.5@BAAI", - permission: str = "me", + permission: str = "me", chunk_method: str = "naive", parser_config: DataSet.ParserConfig = None ) -> DataSet @@ -157,7 +157,7 @@ A brief description of the dataset to create. Defaults to `None`. ##### permission -Specifies who can access the dataset to create. Available options: +Specifies who can access the dataset to create. Available options: - `"me"`: (Default) Only you can manage the dataset. - `"team"`: All team members can manage the dataset. @@ -182,29 +182,29 @@ The chunking method of the dataset to create. Available options: The parser configuration of the dataset. A `ParserConfig` object's attributes vary based on the selected `chunk_method`: -- `chunk_method`=`"naive"`: +- `chunk_method`=`"naive"`: `{"chunk_token_num":512,"delimiter":"\\n","html4excel":False,"layout_recognize":True,"raptor":{"use_raptor":False},"parent_child":{"use_parent_child":False,"children_delimiter":"\\n"}}`. -- `chunk_method`=`"qa"`: +- `chunk_method`=`"qa"`: `{"raptor": {"use_raptor": False}}` -- `chunk_method`=`"manuel"`: +- `chunk_method`=`"manuel"`: `{"raptor": {"use_raptor": False}}` -- `chunk_method`=`"table"`: +- `chunk_method`=`"table"`: `None` -- `chunk_method`=`"paper"`: +- `chunk_method`=`"paper"`: `{"raptor": {"use_raptor": False}}` -- `chunk_method`=`"book"`: +- `chunk_method`=`"book"`: `{"raptor": {"use_raptor": False}}` -- `chunk_method`=`"laws"`: +- `chunk_method`=`"laws"`: `{"raptor": {"use_raptor": False}}` -- `chunk_method`=`"picture"`: +- `chunk_method`=`"picture"`: `None` -- `chunk_method`=`"presentation"`: +- `chunk_method`=`"presentation"`: `{"raptor": {"use_raptor": False}}` -- `chunk_method`=`"one"`: +- `chunk_method`=`"one"`: `None` -- `chunk_method`=`"knowledge-graph"`: +- `chunk_method`=`"knowledge-graph"`: `{"chunk_token_num":128,"delimiter":"\\n","entity_types":["organization","person","location","event","time"]}` -- `chunk_method`=`"email"`: +- `chunk_method`=`"email"`: `None` #### Returns @@ -262,9 +262,9 @@ rag_object.delete_datasets(delete_all=True) ```python RAGFlow.list_datasets( - page: int = 1, - page_size: int = 30, - orderby: str = "create_time", + page: int = 1, + page_size: int = 30, + orderby: str = "create_time", desc: bool = True, id: str = None, name: str = None, @@ -361,25 +361,25 @@ A dictionary representing the attributes to update, with the following keys: - Basic Multilingual Plane (BMP) only - Maximum 128 characters - Case-insensitive -- `"avatar"`: (*Body parameter*), `string` +- `"avatar"`: (*Body parameter*), `string` The updated base64 encoding of the avatar. - Maximum 65535 characters -- `"embedding_model"`: (*Body parameter*), `string` - The updated embedding model name. +- `"embedding_model"`: (*Body parameter*), `string` + The updated embedding model name. - Ensure that `"chunk_count"` is `0` before updating `"embedding_model"`. - Maximum 255 characters - Must follow `model_name@model_factory` format -- `"permission"`: (*Body parameter*), `string` - The updated dataset permission. Available options: +- `"permission"`: (*Body parameter*), `string` + The updated dataset permission. Available options: - `"me"`: (Default) Only you can manage the dataset. - `"team"`: All team members can manage the dataset. -- `"pagerank"`: (*Body parameter*), `int` +- `"pagerank"`: (*Body parameter*), `int` refer to [Set page rank](https://ragflow.io/docs/dev/set_page_rank) - Default: `0` - Minimum: `0` - Maximum: `100` -- `"chunk_method"`: (*Body parameter*), `enum` - The chunking method for the dataset. Available options: +- `"chunk_method"`: (*Body parameter*), `enum` + The chunking method for the dataset. Available options: - `"naive"`: General (default) - `"book"`: Book - `"email"`: Email @@ -429,7 +429,7 @@ Uploads documents to the current dataset. A list of dictionaries representing the documents to upload, each containing the following keys: -- `"display_name"`: (Optional) The file name to display in the dataset. +- `"display_name"`: (Optional) The file name to display in the dataset. - `"blob"`: (Optional) The binary content of the file to upload. #### Returns @@ -475,29 +475,29 @@ A dictionary representing the attributes to update, with the following keys: - `"one"`: One - `"email"`: Email - `"parser_config"`: `dict[str, Any]` The parsing configuration for the document. Its attributes vary based on the selected `"chunk_method"`: - - `"chunk_method"`=`"naive"`: + - `"chunk_method"`=`"naive"`: `{"chunk_token_num":128,"delimiter":"\\n","html4excel":False,"layout_recognize":True,"raptor":{"use_raptor":False},"parent_child":{"use_parent_child":False,"children_delimiter":"\\n"}}`. - - `chunk_method`=`"qa"`: + - `chunk_method`=`"qa"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"manuel"`: + - `chunk_method`=`"manuel"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"table"`: + - `chunk_method`=`"table"`: `None` - - `chunk_method`=`"paper"`: + - `chunk_method`=`"paper"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"book"`: + - `chunk_method`=`"book"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"laws"`: + - `chunk_method`=`"laws"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"presentation"`: + - `chunk_method`=`"presentation"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"picture"`: + - `chunk_method`=`"picture"`: `None` - - `chunk_method`=`"one"`: + - `chunk_method`=`"one"`: `None` - - `chunk_method`=`"knowledge-graph"`: + - `chunk_method`=`"knowledge-graph"`: `{"chunk_token_num":128,"delimiter":"\\n","entity_types":["organization","person","location","event","time"]}` - - `chunk_method`=`"email"`: + - `chunk_method`=`"email"`: `None` #### Returns @@ -630,27 +630,27 @@ A `Document` object contains the following attributes: - `"FAIL"` - `status`: `string` Reserved for future use. - `parser_config`: `ParserConfig` Configuration object for the parser. Its attributes vary based on the selected `chunk_method`: - - `chunk_method`=`"naive"`: + - `chunk_method`=`"naive"`: `{"chunk_token_num":128,"delimiter":"\\n","html4excel":False,"layout_recognize":True,"raptor":{"use_raptor":False}}`. - - `chunk_method`=`"qa"`: + - `chunk_method`=`"qa"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"manuel"`: + - `chunk_method`=`"manuel"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"table"`: + - `chunk_method`=`"table"`: `None` - - `chunk_method`=`"paper"`: + - `chunk_method`=`"paper"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"book"`: + - `chunk_method`=`"book"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"laws"`: + - `chunk_method`=`"laws"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"presentation"`: + - `chunk_method`=`"presentation"`: `{"raptor": {"use_raptor": False}}` - - `chunk_method`=`"picture"`: + - `chunk_method`=`"picture"`: `None` - - `chunk_method`=`"one"`: + - `chunk_method`=`"one"`: `None` - - `chunk_method`=`"email"`: + - `chunk_method`=`"email"`: `None` #### Examples @@ -776,9 +776,9 @@ A list of tuples with detailed parsing results: ... ] ``` -- `status`: The final parsing state (e.g., `success`, `failed`, `cancelled`). -- `chunk_count`: The number of content chunks created from the document. -- `token_count`: The total number of tokens processed. +- `status`: The final parsing state (e.g., `success`, `failed`, `cancelled`). +- `chunk_count`: The number of content chunks created from the document. +- `token_count`: The total number of tokens processed. --- @@ -1075,11 +1075,11 @@ The user query or query keywords. Defaults to `""`. ##### dataset_ids: `list[str]`, *Required* -The IDs of the datasets to search. Defaults to `None`. +The IDs of the datasets to search. Defaults to `None`. ##### document_ids: `list[str]` -The IDs of the documents to search. Defaults to `None`. You must ensure all selected documents use the same embedding model. Otherwise, an error will occur. +The IDs of the documents to search. Defaults to `None`. You must ensure all selected documents use the same embedding model. Otherwise, an error will occur. ##### page: `int` @@ -1112,7 +1112,7 @@ Indicates whether to enable keyword-based matching: - `True`: Enable keyword-based matching. - `False`: Disable keyword-based matching (default). -##### cross_languages: `list[string]` +##### cross_languages: `list[string]` The languages that should be translated into, in order to achieve keywords retrievals in different languages. @@ -1244,7 +1244,7 @@ A dictionary containing the attributes to be updated. Supported keys include: - `"dataset_ids"`: `list[string]` A list of unique identifiers for the datasets associated with the assistant. - `"llm_id"`: `string` The unique identifier or name of the LLM to be used. - `"llm_setting"`: `dict` Configuration for LLM generation parameters: - - `"temperature"`: `float` Controls the randomness of the model's output. + - `"temperature"`: `float` Controls the randomness of the model's output. - `"top_p"`: `float` Sets the nucleus sampling threshold. - `"presence_penalty"`: `float` Penalizes tokens based on whether they have already appeared in the text. - `"frequency_penalty"`: `float` Penalizes tokens based on their existing frequency in the text. @@ -1322,9 +1322,9 @@ rag_object.delete_chats(delete_all=True) ```python RAGFlow.list_chats( - page: int = 1, - page_size: int = 30, - orderby: str = "create_time", + page: int = 1, + page_size: int = 30, + orderby: str = "create_time", desc: bool = True, id: str | None = None, name: str | None = None, @@ -1625,27 +1625,27 @@ The content of the message. Defaults to `"Hi! I am your assistant, can I help yo A list of `Chunk` objects representing references to the message, each containing the following attributes: -- `id` `string` +- `id` `string` The chunk ID. -- `content` `string` +- `content` `string` The content of the chunk. -- `img_id` `string` +- `img_id` `string` The ID of the snapshot of the chunk. Applicable only when the source of the chunk is an image, PPT, PPTX, or PDF file. -- `document_id` `string` +- `document_id` `string` The ID of the referenced document. -- `document_name` `string` +- `document_name` `string` The name of the referenced document. -- `document_metadata` `dict` +- `document_metadata` `dict` Optional document metadata, returned only when `extra_body.reference_metadata.include` is `true`. -- `position` `list[str]` +- `position` `list[str]` The location information of the chunk within the referenced document. -- `dataset_id` `string` +- `dataset_id` `string` The ID of the dataset to which the referenced document belongs. -- `similarity` `float` +- `similarity` `float` A composite similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity. It is the weighted sum of `vector_similarity` and `term_similarity`. -- `vector_similarity` `float` +- `vector_similarity` `float` A vector similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity between vector embeddings. -- `term_similarity` `float` +- `term_similarity` `float` A keyword similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity between keywords. #### Examples @@ -1656,7 +1656,7 @@ from ragflow_sdk import RAGFlow rag_object = RAGFlow(api_key="", base_url="http://:9380") assistant = rag_object.list_chats(name="Miss R") assistant = assistant[0] -session = assistant.create_session() +session = assistant.create_session() print("\n==================== Miss R =====================\n") print("Hello. What can I do for you?") @@ -1664,7 +1664,7 @@ print("Hello. What can I do for you?") while True: question = input("\n==================== User =====================\n> ") print("\n==================== Miss R =====================\n") - + cont = "" for ans in session.ask(question, stream=True): print(ans.content[len(cont):], end='', flush=True) @@ -1768,27 +1768,27 @@ The content of the message. Defaults to `"Hi! I am your assistant, can I help yo A list of `Chunk` objects representing references to the message, each containing the following attributes: -- `id` `string` +- `id` `string` The chunk ID. -- `content` `string` +- `content` `string` The content of the chunk. -- `image_id` `string` +- `image_id` `string` The ID of the snapshot of the chunk. Applicable only when the source of the chunk is an image, PPT, PPTX, or PDF file. -- `document_id` `string` +- `document_id` `string` The ID of the referenced document. -- `document_name` `string` +- `document_name` `string` The name of the referenced document. -- `document_metadata` `dict` +- `document_metadata` `dict` Optional document metadata, returned only when `extra_body.reference_metadata.include` is `true`. -- `position` `list[str]` +- `position` `list[str]` The location information of the chunk within the referenced document. -- `dataset_id` `string` +- `dataset_id` `string` The ID of the dataset to which the referenced document belongs. -- `similarity` `float` +- `similarity` `float` A composite similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity. It is the weighted sum of `vector_similarity` and `term_similarity`. -- `vector_similarity` `float` +- `vector_similarity` `float` A vector similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity between vector embeddings. -- `term_similarity` `float` +- `term_similarity` `float` A keyword similarity score of the chunk ranging from `0` to `1`, with a higher value indicating greater similarity between keywords. #### Examples @@ -1807,7 +1807,7 @@ print("Hello. What can I do for you?") while True: question = input("\n===== User ====\n> ") print("\n==== Miss R ====\n") - + cont = "" for ans in session.ask(question, stream=True): print(ans.content[len(cont):], end='', flush=True) @@ -1845,9 +1845,9 @@ print(message.reference) ```python Agent.list_sessions( - page: int = 1, - page_size: int = 30, - orderby: str = "update_time", + page: int = 1, + page_size: int = 30, + orderby: str = "update_time", desc: bool = True, id: str = None ) -> List[Session] @@ -1946,9 +1946,9 @@ agent.delete_sessions(delete_all=True) ```python RAGFlow.list_agents( - page: int = 1, - page_size: int = 30, - orderby: str = "update_time", + page: int = 1, + page_size: int = 30, + orderby: str = "update_time", desc: bool = True ) -> List[Agent] ``` @@ -2162,9 +2162,9 @@ rag_object.delete_agent("58af890a2a8911f0a71a11b922ed82d6") ```python Ragflow.create_memory( - name: str, - memory_type: list[str], - embd_id: str, + name: str, + memory_type: list[str], + embd_id: str, llm_id: str ) -> Memory ``` @@ -2180,7 +2180,7 @@ The unique name of the memory to create. It must adhere to the following require - Basic Multilingual Plane (BMP) only - Maximum 128 characters -##### memory_type: `list[str]`, *Required* +##### memory_type: `list[str]`, *Required* Specifies the types of memory to extract. Available options: @@ -2244,7 +2244,7 @@ Configurations to update. Available configurations: - Basic Multilingual Plane (BMP) only - Maximum 128 characters, *Optional* -- `avatar`: `string`, *Optional* +- `avatar`: `string`, *Optional* The updated base64 encoding of the avatar. @@ -2319,11 +2319,11 @@ memory_object.update({"name": "New_name"}) ```python Ragflow.list_memory( - page: int = 1, - page_size: int = 50, - tenant_id: str | list[str] = None, - memory_type: str | list[str] = None, - storage_type: str = None, + page: int = 1, + page_size: int = 50, + tenant_id: str | list[str] = None, + memory_type: str | list[str] = None, + storage_type: str = None, keywords: str = None) -> dict ``` @@ -2364,7 +2364,7 @@ The name of memory to retrieve, supports fuzzy search. #### Returns -Success: A dict of `Memory` object list and total count. +Success: A dict of `Memory` object list and total count. ```json {"memory_list": list[Memory], "total_count": int} @@ -2453,9 +2453,9 @@ rag_object.delete_memory("your memory_id") ```python Memory.list_memory_messages( - agent_id: str | list[str]=None, - keywords: str=None, - page: int=1, + agent_id: str | list[str]=None, + keywords: str=None, + page: int=1, page_size: int=50 ) -> dict ``` @@ -2482,7 +2482,7 @@ The number of messages on each page. Defaults to `50`. #### Returns -Success: a dict of messages and meta info. +Success: a dict of messages and meta info. ```json {"messages": {"message_list": [{message dict}], "total_count": int}, "storage_type": "table"} @@ -2507,11 +2507,11 @@ memory_obejct.list_memory_messages() ```python Ragflow.add_message( - memory_id: list[str], - agent_id: str, - session_id: str, - user_input: str, - agent_response: str, + memory_id: list[str], + agent_id: str, + session_id: str, + user_input: str, + agent_response: str, user_id: str = "" ) -> str ``` @@ -2646,13 +2646,13 @@ memory_object.update_message_status(message_id, True) ```python Ragflow.search_message( - query: str, - memory_id: list[str], - agent_id: str=None, + query: str, + memory_id: list[str], + agent_id: str=None, session_id: str=None, user_id: str=None, - similarity_threshold: float=0.2, - keywords_similarity_weight: float=0.7, + similarity_threshold: float=0.2, + keywords_similarity_weight: float=0.7, top_n: int=10 ) -> list[dict] ``` @@ -2719,9 +2719,9 @@ rag_object.search_message("your question", ["your memory_id"]) ```python Ragflow.get_recent_messages( - memory_id: list[str], - agent_id: str=None, - session_id: str=None, + memory_id: list[str], + agent_id: str=None, + session_id: str=None, limit: int=10 ) -> list[dict] ``` diff --git a/tools/firecrawl/README.md b/tools/firecrawl/README.md index 06255e929a..c0c0105578 100644 --- a/tools/firecrawl/README.md +++ b/tools/firecrawl/README.md @@ -186,7 +186,7 @@ The integration includes robust error handling for: ## 🤝 **Contributing** -This integration was created as part of the [Firecrawl bounty program](https://github.com/firecrawl/firecrawl/issues/2167). +This integration was created as part of the [Firecrawl bounty program](https://github.com/firecrawl/firecrawl/issues/2167). ### Development 1. Fork the RAGFlow repository @@ -213,4 +213,4 @@ This integration was developed as part of the Firecrawl bounty program to bridge **Ready for RAGFlow Integration!** 🚀 -This integration enables RAGFlow users to easily import web content into their knowledge retrieval systems, expanding the ecosystem for both Firecrawl and RAGFlow. \ No newline at end of file +This integration enables RAGFlow users to easily import web content into their knowledge retrieval systems, expanding the ecosystem for both Firecrawl and RAGFlow. diff --git a/web/src/pages/user-setting/data-source/add-datasource-modal.tsx b/web/src/pages/user-setting/data-source/add-datasource-modal.tsx index 38b9efff3f..b3efdf4799 100644 --- a/web/src/pages/user-setting/data-source/add-datasource-modal.tsx +++ b/web/src/pages/user-setting/data-source/add-datasource-modal.tsx @@ -1,7 +1,7 @@ import { DynamicForm, FormFieldConfig } from '@/components/dynamic-form'; import { Modal } from '@/components/ui/modal/modal'; import { IModalProps } from '@/interfaces/common'; -import { useEffect, useState } from 'react'; +import { useMemo } from 'react'; import { FieldValues } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; import { @@ -21,17 +21,27 @@ const AddDataSourceModal = ({ onOk, }: IModalProps & { sourceData?: IDataSorceInfo }) => { const { t } = useTranslation(); - const [fields, setFields] = useState([]); - - useEffect(() => { - if (sourceData) { - setFields([ - ...getDataSourceFormBaseFields(t), - ...getDataSourceFieldsWithExtras(t, sourceData.id as any), - ] as FormFieldConfig[]); + const fields = useMemo(() => { + if (!sourceData) { + return []; } + return [ + ...getDataSourceFormBaseFields(t), + ...getDataSourceFieldsWithExtras(t, sourceData.id as any), + ] as FormFieldConfig[]; }, [sourceData, t]); + const defaultValues = useMemo( + () => + mergeDataSourceFormValues( + DataSourceFormDefaultValues[ + sourceData?.id as keyof typeof DataSourceFormDefaultValues + ] as FieldValues, + getCommonExtraDefaultValues(), + ) as FieldValues, + [sourceData], + ); + const handleOk = async (values?: FieldValues) => { await onOk?.(values); hideModal?.(); @@ -58,14 +68,7 @@ const AddDataSourceModal = ({ onSubmit={(data) => { console.log(data); }} - defaultValues={ - mergeDataSourceFormValues( - DataSourceFormDefaultValues[ - sourceData?.id as keyof typeof DataSourceFormDefaultValues - ] as FieldValues, - getCommonExtraDefaultValues(), - ) as FieldValues - } + defaultValues={defaultValues} labelClassName="font-normal" >
diff --git a/web/src/pages/user-setting/data-source/data-source-detail-page/index.tsx b/web/src/pages/user-setting/data-source/data-source-detail-page/index.tsx index acf3bbbd1c..15c7fdb4ac 100644 --- a/web/src/pages/user-setting/data-source/data-source-detail-page/index.tsx +++ b/web/src/pages/user-setting/data-source/data-source-detail-page/index.tsx @@ -44,13 +44,7 @@ const SourceDetailPage = () => { } }, [detail, dataSourceInfo]); - const [fields, setFields] = useState([]); const [isDirty, setIsDirty] = useState(false); - const [defaultValues, setDefaultValues] = useState( - DataSourceFormDefaultValues[ - detail?.source as keyof typeof DataSourceFormDefaultValues - ] as FieldValues, - ); const customFields = useMemo(() => { return [ @@ -115,6 +109,38 @@ const SourceDetailPage = () => { ]; }, [t]); + const fields = useMemo(() => { + if (!detail) { + return []; + } + const baseFields = getDataSourceFormBaseFields(t).map((field) => + field.name === 'name' ? { ...field, disabled: true } : { ...field }, + ); + const allFields = [ + ...baseFields, + ...getDataSourceFieldsWithExtras(t, detail.source as any), + ...customFields, + ] as FormFieldConfig[]; + return allFields.map((field) => ({ + ...field, + horizontal: true, + onChange: undefined, + })); + }, [detail, customFields, t]); + + const defaultValues = useMemo(() => { + if (!detail) { + return {}; + } + return mergeDataSourceFormValues( + DataSourceFormDefaultValues[ + detail.source as keyof typeof DataSourceFormDefaultValues + ] as FieldValues, + getCommonExtraDefaultValues(), + detail as FieldValues, + ); + }, [detail]); + const { addLoading, handleAddOk } = useAddDataSource({ isEdit: true }); const { loading: testLoading, handleTest } = useTestDataSource(); @@ -171,47 +197,8 @@ const SourceDetailPage = () => { }, [actionMode, t]); useEffect(() => { - const baseFields = getDataSourceFormBaseFields(t).map((field) => { - if (field.name === 'name') { - return { - ...field, - disabled: true, - }; - } else { - return { - ...field, - }; - } - }); - if (detail) { - const fields = [ - ...baseFields, - ...getDataSourceFieldsWithExtras(t, detail.source as any), - ...customFields, - ] as FormFieldConfig[]; - - const newFields = fields.map((field) => { - return { - ...field, - horizontal: true, - onChange: undefined, - }; - }); - setFields(newFields); - - const defaultValueTemp = { - ...mergeDataSourceFormValues( - DataSourceFormDefaultValues[ - detail?.source as keyof typeof DataSourceFormDefaultValues - ] as FieldValues, - getCommonExtraDefaultValues(), - detail as FieldValues, - ), - }; - setDefaultValues(defaultValueTemp); - setIsDirty(false); - } - }, [detail, customFields, onSubmit, t]); + setIsDirty(false); + }, [detail]); useEffect(() => { const instance = formRef.current;