diff --git a/docs/references/http_api_reference.md b/docs/references/http_api_reference.md index 73dbea28d..eca63d145 100644 --- a/docs/references/http_api_reference.md +++ b/docs/references/http_api_reference.md @@ -9,19 +9,17 @@ A complete reference for RAGFlow's RESTful API. Before proceeding, please ensure --- -:::tip API GROUPING -Dataset Management -::: +## DATASET MANAGEMENT --- -## Create dataset +### Create dataset **POST** `/api/v1/datasets` Creates a dataset. -### Request +#### Request - Method: POST - URL: `/api/v1/datasets` @@ -38,7 +36,7 @@ Creates a dataset. - `"chunk_method"`: `string` - `"parser_config"`: `object` -#### Request example +##### Request example ```bash curl --request POST \ @@ -50,7 +48,7 @@ curl --request POST \ }' ``` -#### Request parameters +##### Request parameters - `"name"`: (*Body parameter*), `string`, *Required* The unique name of the dataset to create. It must adhere to the following requirements: @@ -114,7 +112,7 @@ curl --request POST \ - `"delimiter"`: Defaults to `"\n!?。;!?"`. - `"entity_types"`: Defaults to `["organization","person","location","event","time"]` -### Response +#### Response Success: @@ -166,13 +164,13 @@ Failure: --- -## Delete datasets +### Delete datasets **DELETE** `/api/v1/datasets` Deletes datasets by ID. -### Request +#### Request - Method: DELETE - URL: `/api/v1/datasets` @@ -182,7 +180,7 @@ Deletes datasets by ID. - Body: - `"ids"`: `list[string]` -#### Request example +##### Request example ```bash curl --request DELETE \ @@ -194,12 +192,12 @@ curl --request DELETE \ }' ``` -#### Request parameters +##### Request parameters - `"ids"`: (*Body parameter*), `list[string]` The IDs of the datasets to delete. If it is not specified, all datasets will be deleted. -### Response +#### Response Success: @@ -220,13 +218,13 @@ Failure: --- -## Update dataset +### Update dataset **PUT** `/api/v1/datasets/{dataset_id}` Updates configurations for a specified dataset. -### Request +#### Request - Method: PUT - URL: `/api/v1/datasets/{dataset_id}` @@ -238,7 +236,7 @@ Updates configurations for a specified dataset. - `"embedding_model"`: `string` - `"chunk_method"`: `enum` -#### Request example +##### Request example ```bash curl --request PUT \ @@ -251,7 +249,7 @@ curl --request PUT \ }' ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The ID of the dataset to update. @@ -276,7 +274,7 @@ curl --request PUT \ - `"knowledge_graph"`: Knowledge Graph Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens! -### Response +#### Response Success: @@ -297,20 +295,20 @@ Failure: --- -## List datasets +### List datasets **GET** `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}` Lists datasets. -### Request +#### Request - Method: GET - URL: `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}` - Headers: - `'Authorization: Bearer '` -#### Request example +##### Request example ```bash curl --request GET \ @@ -318,7 +316,7 @@ curl --request GET \ --header 'Authorization: Bearer ' ``` -#### Request parameters +##### Request parameters - `page`: (*Filter parameter*) Specifies the page on which the datasets will be displayed. Defaults to `1`. @@ -335,7 +333,7 @@ curl --request GET \ - `id`: (*Filter parameter*) The ID of the dataset to retrieve. -### Response +#### Response Success: @@ -391,19 +389,17 @@ Failure: --- -:::tip API GROUPING -File Management within Dataset -::: +## FILE MANAGEMENT WITHIN DATASET --- -## Upload documents +### Upload documents **POST** `/api/v1/datasets/{dataset_id}/documents` Uploads documents to a specified dataset. -### Request +#### Request - Method: POST - URL: `/api/v1/datasets/{dataset_id}/documents` @@ -413,7 +409,7 @@ Uploads documents to a specified dataset. - Form: - `'file=@{FILE_PATH}'` -#### Request example +##### Request example ```bash curl --request POST \ @@ -424,14 +420,14 @@ curl --request POST \ --form 'file=@./test2.pdf' ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The ID of the dataset to which the documents will be uploaded. - `'file'`: (*Body parameter*) A document to upload. -### Response +#### Response Success: @@ -475,13 +471,13 @@ Failure: --- -## Update document +### Update document **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}` Updates configurations for a specified document. -### Request +#### Request - Method: PUT - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}` @@ -493,7 +489,7 @@ Updates configurations for a specified document. - `"chunk_method"`:`string` - `"parser_config"`:`object` -#### Request example +##### Request example ```bash curl --request PUT \ @@ -509,7 +505,7 @@ curl --request PUT \ ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The ID of the associated dataset. @@ -548,7 +544,7 @@ curl --request PUT \ - `"delimiter"`: Defaults to `"\n!?。;!?"`. - `"entity_types"`: Defaults to `["organization","person","location","event","time"]` -### Response +#### Response Success: @@ -569,13 +565,13 @@ Failure: --- -## Download document +### Download document **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}` Downloads a document from a specified dataset. -### Request +#### Request - Method: GET - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}` @@ -584,7 +580,7 @@ Downloads a document from a specified dataset. - Output: - `'{PATH_TO_THE_FILE}'` -#### Request example +##### Request example ```bash curl --request GET \ @@ -593,14 +589,14 @@ curl --request GET \ --output ./ragflow.txt ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The associated dataset ID. - `documents_id`: (*Path parameter*) The ID of the document to download. -### Response +#### Response Success: @@ -619,13 +615,13 @@ Failure: --- -## List documents +### List documents **GET** `/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}` Lists documents in a specified dataset. -### Request +#### Request - Method: GET - URL: `/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}` @@ -633,7 +629,7 @@ Lists documents in a specified dataset. - `'content-Type: application/json'` - `'Authorization: Bearer '` -#### Request example +##### Request example ```bash curl --request GET \ @@ -641,7 +637,7 @@ curl --request GET \ --header 'Authorization: Bearer ' ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The associated dataset ID. @@ -660,7 +656,7 @@ curl --request GET \ - `id`: (*Filter parameter*), `string` The ID of the document to retrieve. -### Response +#### Response Success: @@ -716,13 +712,13 @@ Failure: --- -## Delete documents +### Delete documents **DELETE** `/api/v1/datasets/{dataset_id}/documents` Deletes documents by ID. -### Request +#### Request - Method: DELETE - URL: `/api/v1/datasets/{dataset_id}/documents` @@ -732,7 +728,7 @@ Deletes documents by ID. - Body: - `"ids"`: `list[string]` -#### Request example +##### Request example ```bash curl --request DELETE \ @@ -745,14 +741,14 @@ curl --request DELETE \ }' ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The associated dataset ID. - `"ids"`: (*Body parameter*), `list[string]` The IDs of the documents to delete. If it is not specified, all documents in the specified dataset will be deleted. -### Response +#### Response Success: @@ -773,13 +769,13 @@ Failure: --- -## Parse documents +### Parse documents **POST** `/api/v1/datasets/{dataset_id}/chunks` Parses documents in a specified dataset. -### Request +#### Request - Method: POST - URL: `/api/v1/datasets/{dataset_id}/chunks` @@ -789,7 +785,7 @@ Parses documents in a specified dataset. - Body: - `"document_ids"`: `list[string]` -#### Request example +##### Request example ```bash curl --request POST \ @@ -802,14 +798,14 @@ curl --request POST \ }' ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The dataset ID. - `"document_ids"`: (*Body parameter*), `list[string]`, *Required* The IDs of the documents to parse. -### Response +#### Response Success: @@ -830,13 +826,13 @@ Failure: --- -## Stop parsing documents +### Stop parsing documents **DELETE** `/api/v1/datasets/{dataset_id}/chunks` Stops parsing specified documents. -### Request +#### Request - Method: DELETE - URL: `/api/v1/datasets/{dataset_id}/chunks` @@ -846,7 +842,7 @@ Stops parsing specified documents. - Body: - `"document_ids"`: `list[string]` -#### Request example +##### Request example ```bash curl --request DELETE \ @@ -859,14 +855,14 @@ curl --request DELETE \ }' ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The associated dataset ID. - `"document_ids"`: (*Body parameter*), `list[string]`, *Required* The IDs of the documents for which the parsing should be stopped. -### Response +#### Response Success: @@ -887,13 +883,13 @@ Failure: --- -## Add chunk +### Add chunk **POST** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks` Adds a chunk to a specified document in a specified dataset. -### Request +#### Request - Method: POST - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks` @@ -904,7 +900,7 @@ Adds a chunk to a specified document in a specified dataset. - `"content"`: `string` - `"important_keywords"`: `list[string]` -#### Request example +##### Request example ```bash curl --request POST \ @@ -917,7 +913,7 @@ curl --request POST \ }' ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The associated dataset ID. @@ -928,7 +924,7 @@ curl --request POST \ - `"important_keywords`(*Body parameter*), `list[string]` The key terms or phrases to tag with the chunk. -### Response +#### Response Success: @@ -962,20 +958,20 @@ Failure: --- -## List chunks +### List chunks **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={id}` Lists chunks in a specified document. -### Request +#### Request - Method: GET - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={chunk_id}` - Headers: - `'Authorization: Bearer '` -#### Request example +##### Request example ```bash curl --request GET \ @@ -983,7 +979,7 @@ curl --request GET \ --header 'Authorization: Bearer ' ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The associated dataset ID. @@ -998,7 +994,7 @@ curl --request GET \ - `id`(*Filter parameter*), `string` The ID of the chunk to retrieve. -### Response +#### Response Success: @@ -1069,13 +1065,13 @@ Failure: --- -## Delete chunks +### Delete chunks **DELETE** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks` Deletes chunks by ID. -### Request +#### Request - Method: DELETE - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks` @@ -1085,7 +1081,7 @@ Deletes chunks by ID. - Body: - `"chunk_ids"`: `list[string]` -#### Request example +##### Request example ```bash curl --request DELETE \ @@ -1098,7 +1094,7 @@ curl --request DELETE \ }' ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The associated dataset ID. @@ -1107,7 +1103,7 @@ curl --request DELETE \ - `"chunk_ids"`: (*Body parameter*), `list[string]` The IDs of the chunks to delete. If it is not specified, all chunks of the specified document will be deleted. -### Response +#### Response Success: @@ -1128,13 +1124,13 @@ Failure: --- -## Update chunk +### Update chunk **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}` Updates content or configurations for a specified chunk. -### Request +#### Request - Method: PUT - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}` @@ -1146,7 +1142,7 @@ Updates content or configurations for a specified chunk. - `"important_keywords"`: `list[string]` - `"available"`: `boolean` -#### Request example +##### Request example ```bash curl --request PUT \ @@ -1160,7 +1156,7 @@ curl --request PUT \ }' ``` -#### Request parameters +##### Request parameters - `dataset_id`: (*Path parameter*) The associated dataset ID. @@ -1177,7 +1173,7 @@ curl --request PUT \ - `true`: Available (default) - `false`: Unavailable -### Response +#### Response Success: @@ -1198,13 +1194,13 @@ Failure: --- -## Retrieve chunks +### Retrieve chunks **POST** `/api/v1/retrieval` Retrieves chunks from specified datasets. -### Request +#### Request - Method: POST - URL: `/api/v1/retrieval` @@ -1224,7 +1220,7 @@ Retrieves chunks from specified datasets. - `"keyword"`: `boolean` - `"highlight"`: `boolean` -#### Request example +##### Request example ```bash curl --request POST \ @@ -1239,7 +1235,7 @@ curl --request POST \ }' ``` -#### Request parameter +##### Request parameter - `"question"`: (*Body parameter*), `string`, *Required* The user query or query keywords. @@ -1268,7 +1264,7 @@ curl --request POST \ - `true`: Enable highlighting of matched terms. - `false`: Disable highlighting of matched terms (default). -### Response +#### Response Success: @@ -1320,19 +1316,17 @@ Failure: --- -:::tip API GROUPING -Chat Assistant Management -::: +## CHAT ASSISTANT MANAGEMENT --- -## Create chat assistant +### Create chat assistant **POST** `/api/v1/chats` Creates a chat assistant. -### Request +#### Request - Method: POST - URL: `/api/v1/chats` @@ -1346,7 +1340,7 @@ Creates a chat assistant. - `"llm"`: `object` - `"prompt"`: `object` -#### Request example +##### Request example ```shell curl --request POST \ @@ -1359,7 +1353,7 @@ curl --request POST \ }' ``` -#### Request parameters +##### Request parameters - `"name"`: (*Body parameter*), `string`, *Required* The name of the chat assistant. @@ -1396,7 +1390,7 @@ curl --request POST \ - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`. - `"prompt"`: `string` The prompt content. -### Response +#### Response Success: @@ -1459,13 +1453,13 @@ Failure: --- -## Update chat assistant +### Update chat assistant **PUT** `/api/v1/chats/{chat_id}` Updates configurations for a specified chat assistant. -### Request +#### Request - Method: PUT - URL: `/api/v1/chats/{chat_id}` @@ -1479,7 +1473,7 @@ Updates configurations for a specified chat assistant. - `"llm"`: `object` - `"prompt"`: `object` -#### Request example +##### Request example ```bash curl --request PUT \ @@ -1531,7 +1525,7 @@ curl --request PUT \ - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`. - `"prompt"`: `string` The prompt content. -### Response +#### Response Success: @@ -1552,13 +1546,13 @@ Failure: --- -## Delete chat assistants +### Delete chat assistants **DELETE** `/api/v1/chats` Deletes chat assistants by ID. -### Request +#### Request - Method: DELETE - URL: `/api/v1/chats` @@ -1568,7 +1562,7 @@ Deletes chat assistants by ID. - Body: - `"ids"`: `list[string]` -#### Request example +##### Request example ```bash curl --request DELETE \ @@ -1581,12 +1575,12 @@ curl --request DELETE \ }' ``` -#### Request parameters +##### Request parameters - `"ids"`: (*Body parameter*), `list[string]` The IDs of the chat assistants to delete. If it is not specified, all chat assistants in the system will be deleted. -### Response +#### Response Success: @@ -1607,20 +1601,20 @@ Failure: --- -## List chat assistants +### List chat assistants **GET** `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={chat_name}&id={chat_id}` Lists chat assistants. -### Request +#### Request - Method: GET - URL: `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}` - Headers: - `'Authorization: Bearer '` -#### Request example +##### Request example ```bash curl --request GET \ @@ -1628,7 +1622,7 @@ curl --request GET \ --header 'Authorization: Bearer ' ``` -#### Request parameters +##### Request parameters - `page`: (*Filter parameter*), `integer` Specifies the page on which the chat assistants will be displayed. Defaults to `1`. @@ -1645,7 +1639,7 @@ curl --request GET \ - `name`: (*Filter parameter*), `string` The name of the chat assistant to retrieve. -### Response +#### Response Success: @@ -1706,13 +1700,19 @@ Failure: } ``` -## Create session with chat assistant +--- + +## CHAT SESSIONS + +--- + +### Create session with chat assistant **POST** `/api/v1/chats/{chat_id}/sessions` Creates a session with a chat assistant. -### Request +#### Request - Method: POST - URL: `/api/v1/chats/{chat_id}/sessions` @@ -1722,7 +1722,7 @@ Creates a session with a chat assistant. - Body: - `"name"`: `string` -#### Request example +##### Request example ```bash curl --request POST \ @@ -1735,14 +1735,14 @@ curl --request POST \ }' ``` -#### Request parameters +##### Request parameters - `chat_id`: (*Path parameter*) The ID of the associated chat assistant. - `"name"`: (*Body parameter*), `string` The name of the chat session to create. -### Response +#### Response Success: @@ -1778,13 +1778,13 @@ Failure: --- -## Update session +### Update session **PUT** `/api/v1/chats/{chat_id}/sessions/{session_id}` Updates a session of a specified chat assistant. -### Request +#### Request - Method: PUT - URL: `/api/v1/chats/{chat_id}/sessions/{session_id}` @@ -1794,7 +1794,7 @@ Updates a session of a specified chat assistant. - Body: - `"name`: `string` -#### Request example +##### Request example ```bash curl --request PUT \ @@ -1807,7 +1807,7 @@ curl --request PUT \ }' ``` -#### Request Parameter +##### Request Parameter - `chat_id`: (*Path parameter*) The ID of the associated chat assistant. @@ -1816,7 +1816,7 @@ curl --request PUT \ - `"name"`: (*Body Parameter), `string` The revised name of the session. -### Response +#### Response Success: @@ -1837,20 +1837,20 @@ Failure: --- -## List sessions +### List sessions **GET** `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}` Lists sessions associated with a specified chat assistant. -### Request +#### Request - Method: GET - URL: `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}` - Headers: - `'Authorization: Bearer '` -#### Request example +##### Request example ```bash curl --request GET \ @@ -1858,7 +1858,7 @@ curl --request GET \ --header 'Authorization: Bearer ' ``` -#### Request Parameters +##### Request Parameters - `chat_id`: (*Path parameter*) The ID of the associated chat assistant. @@ -1877,7 +1877,7 @@ curl --request GET \ - `id`: (*Filter parameter*), `string` The ID of the chat session to retrieve. -### Response +#### Response Success: @@ -1915,13 +1915,13 @@ Failure: --- -## Delete sessions +### Delete sessions **DELETE** `/api/v1/chats/{chat_id}/sessions` Deletes sessions of a chat assistant by ID. -### Request +#### Request - Method: DELETE - URL: `/api/v1/chats/{chat_id}/sessions` @@ -1931,10 +1931,9 @@ Deletes sessions of a chat assistant by ID. - Body: - `"ids"`: `list[string]` -#### Request example +##### Request example ```bash -# Either id or name must be provided, but not both. curl --request DELETE \ --url http://{address}/api/v1/chats/{chat_id}/sessions \ --header 'Content-Type: application/json' \ @@ -1945,14 +1944,14 @@ curl --request DELETE \ }' ``` -#### Request Parameters +##### Request Parameters - `chat_id`: (*Path parameter*) The ID of the associated chat assistant. - `"ids"`: (*Body Parameter*), `list[string]` The IDs of the sessions to delete. If it is not specified, all sessions associated with the specified chat assistant will be deleted. -### Response +#### Response Success: @@ -1973,7 +1972,7 @@ Failure: --- -## Converse with chat assistant +### Converse with chat assistant **POST** `/api/v1/chats/{chat_id}/completions` @@ -1994,7 +1993,7 @@ Asks a specified chat assistant a question to start an AI-powered conversation. ::: -### Request +#### Request - Method: POST - URL: `/api/v1/chats/{chat_id}/completions` @@ -2006,7 +2005,7 @@ Asks a specified chat assistant a question to start an AI-powered conversation. - `"stream"`: `boolean` - `"session_id"`: `string` -#### Request example +##### Request example ```bash curl --request POST \ @@ -2029,7 +2028,8 @@ curl --request POST \ "session_id":"9fa7691cb85c11ef9c5f0242ac120005" }' ``` -#### Request Parameters + +##### Request Parameters - `chat_id`: (*Path parameter*) The ID of the associated chat assistant. @@ -2042,7 +2042,8 @@ curl --request POST \ - `"session_id"`: (*Body Parameter*) The ID of session. If it is not provided, a new session will be generated. -### Response +#### Response + Success without `session_id`: ```text data:{ @@ -2148,15 +2149,13 @@ Failure: --- -## Create session with agent - -*If there are parameters in the `begin` component, the session cannot be created in this way.* +### Create session with agent **POST** `/api/v1/agents/{agent_id}/sessions` Creates a session with an agent. -### Request +#### Request - Method: POST - URL: `/api/v1/agents/{agent_id}/sessions` @@ -2165,7 +2164,7 @@ Creates a session with an agent. - `'Authorization: Bearer '` - Body: -#### Request example +##### Request example ```bash curl --request POST \ @@ -2176,12 +2175,12 @@ curl --request POST \ }' ``` -#### Request parameters +##### Request parameters - `agent_id`: (*Path parameter*) The ID of the associated agent assistant. -### Response +#### Response Success: @@ -2299,7 +2298,7 @@ Failure: --- -## Converse with agent +### Converse with agent **POST** `/api/v1/agents/{agent_id}/completions` @@ -2320,7 +2319,7 @@ Asks a specified agent a question to start an AI-powered conversation. ::: -### Request +#### Request - Method: POST - URL: `/api/v1/agents/{agent_id}/completions` @@ -2332,7 +2331,7 @@ Asks a specified agent a question to start an AI-powered conversation. - `"stream"`: `boolean` - `"session_id"`: `string` - other parameters: `string` -#### Request example +##### Request example ```bash curl --request POST \ @@ -2368,7 +2367,7 @@ curl --request POST \ ``` -#### Request Parameters +##### Request Parameters - `agent_id`: (*Path parameter*), `string` The ID of the associated agent assistant. @@ -2382,7 +2381,7 @@ curl --request POST \ The ID of the session. If it is not provided, a new session will be generated. - Other parameters: (*Body Parameter*) The parameters in the begin component. -### Response +#### Response success without `session_id` provided and with no parameters in the `begin` component: ```text data:{ @@ -2600,20 +2599,20 @@ Failure: --- -## List agent sessions +### List agent sessions **GET** `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}` Lists sessions associated with a specified agent. -### Request +#### Request - Method: GET - URL: `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}` - Headers: - `'Authorization: Bearer '` -#### Request example +##### Request example ```bash curl --request GET \ @@ -2621,7 +2620,7 @@ curl --request GET \ --header 'Authorization: Bearer ' ``` -#### Request Parameters +##### Request Parameters - `agent_id`: (*Path parameter*) The ID of the associated agent. @@ -2638,7 +2637,7 @@ curl --request GET \ - `id`: (*Filter parameter*), `string` The ID of the agent session to retrieve. -### Response +#### Response Success: @@ -2789,21 +2788,23 @@ Failure: "message": "You don't own the agent ccd2f856b12311ef94ca0242ac1200052." } ``` + --- -## List agents + +### List agents **GET** `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}` Lists agents. -### Request +#### Request - Method: GET - URL: `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}` - Headers: - `'Authorization: Bearer '` -#### Request example +##### Request example ```bash curl --request GET \ @@ -2811,7 +2812,7 @@ curl --request GET \ --header 'Authorization: Bearer ' ``` -#### Request parameters +##### Request parameters - `page`: (*Filter parameter*), `integer` Specifies the page on which the agents will be displayed. Defaults to `1`. @@ -2828,7 +2829,7 @@ curl --request GET \ - `name`: (*Filter parameter*), `string` The name of the agent to retrieve. -### Response +#### Response Success: @@ -2897,4 +2898,6 @@ Failure: "code": 102, "message": "The agent doesn't exist." } -``` \ No newline at end of file +``` + +--- \ No newline at end of file diff --git a/docs/references/python_api_reference.md b/docs/references/python_api_reference.md index 839ebe156..61c7f0538 100644 --- a/docs/references/python_api_reference.md +++ b/docs/references/python_api_reference.md @@ -7,22 +7,21 @@ slug: /python_api_reference A complete reference for RAGFlow's Python APIs. Before proceeding, please ensure you [have your RAGFlow API key ready for authentication](https://ragflow.io/docs/dev/acquire_ragflow_api_key). ---- - -:::tip API GROUPING -Dataset Management -::: - ---- -### Install the RAGFlow SDK - -To install the RAGFlow SDK, run the following command in your terminal: +:::tip NOTE +Run the following command to download the Python SDK: ```bash pip install ragflow-sdk ``` +::: -## Create dataset +--- + +## DATASET MANAGEMENT + +--- + +### Create dataset ```python RAGFlow.create_dataset( @@ -39,9 +38,9 @@ RAGFlow.create_dataset( Creates a dataset. -### Parameters +#### Parameters -#### name: `str`, *Required* +##### name: `str`, *Required* The unique name of the dataset to create. It must adhere to the following requirements: @@ -53,29 +52,29 @@ The unique name of the dataset to create. It must adhere to the following requir - Maximum 65,535 characters. - Case-insensitive. -#### avatar: `str` +##### avatar: `str` Base64 encoding of the avatar. Defaults to `""` -#### description: `str` +##### description: `str` A brief description of the dataset to create. Defaults to `""`. -#### language: `str` +##### language: `str` The language setting of the dataset to create. Available options: - `"English"` (default) - `"Chinese"` -#### permission +##### permission 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. -#### chunk_method, `str` +##### chunk_method, `str` The chunking method of the dataset to create. Available options: @@ -93,7 +92,7 @@ The chunking method of the dataset to create. Available options: Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens! - `"email"`: Email -#### parser_config +##### parser_config The parser configuration of the dataset. A `ParserConfig` object's attributes vary based on the selected `chunk_method`: @@ -122,12 +121,12 @@ The parser configuration of the dataset. A `ParserConfig` object's attributes va - `chunk_method`=`"email"`: `None` -### Returns +#### Returns - Success: A `dataset` object. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -138,7 +137,7 @@ dataset = rag_object.create_dataset(name="kb_1") --- -## Delete datasets +### Delete datasets ```python RAGFlow.delete_datasets(ids: list[str] = None) @@ -146,18 +145,18 @@ RAGFlow.delete_datasets(ids: list[str] = None) Deletes datasets by ID. -### Parameters +#### Parameters -#### ids: `list[str]`, *Required* +##### ids: `list[str]`, *Required* The IDs of the datasets to delete. Defaults to `None`. If it is not specified, all datasets will be deleted. -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python rag_object.delete_datasets(ids=["id_1","id_2"]) @@ -165,7 +164,7 @@ rag_object.delete_datasets(ids=["id_1","id_2"]) --- -## List datasets +### List datasets ```python RAGFlow.list_datasets( @@ -180,50 +179,50 @@ RAGFlow.list_datasets( Lists datasets. -### Parameters +#### Parameters -#### page: `int` +##### page: `int` Specifies the page on which the datasets will be displayed. Defaults to `1`. -#### page_size: `int` +##### page_size: `int` The number of datasets on each page. Defaults to `30`. -#### orderby: `str` +##### orderby: `str` The field by which datasets should be sorted. Available options: - `"create_time"` (default) - `"update_time"` -#### desc: `bool` +##### desc: `bool` Indicates whether the retrieved datasets should be sorted in descending order. Defaults to `True`. -#### id: `str` +##### id: `str` The ID of the dataset to retrieve. Defaults to `None`. -#### name: `str` +##### name: `str` The name of the dataset to retrieve. Defaults to `None`. -### Returns +#### Returns - Success: A list of `DataSet` objects. - Failure: `Exception`. -### Examples +#### Examples -#### List all datasets +##### List all datasets ```python for dataset in rag_object.list_datasets(): print(dataset) ``` -#### Retrieve a dataset by ID +##### Retrieve a dataset by ID ```python dataset = rag_object.list_datasets(id = "id_1") @@ -232,7 +231,7 @@ print(dataset[0]) --- -## Update dataset +### Update dataset ```python DataSet.update(update_message: dict) @@ -240,9 +239,9 @@ DataSet.update(update_message: dict) Updates configurations for the current dataset. -### Parameters +#### Parameters -#### update_message: `dict[str, str|int]`, *Required* +##### update_message: `dict[str, str|int]`, *Required* A dictionary representing the attributes to update, with the following keys: @@ -264,12 +263,12 @@ A dictionary representing the attributes to update, with the following keys: - `"knowledge_graph"`: Knowledge Graph Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens! -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -281,13 +280,11 @@ dataset.update({"embedding_model":"BAAI/bge-zh-v1.5", "chunk_method":"manual"}) --- -:::tip API GROUPING -File Management within Dataset -::: +## FILE MANAGEMENT WITHIN DATASET --- -## Upload documents +### Upload documents ```python DataSet.upload_documents(document_list: list[dict]) @@ -295,21 +292,21 @@ DataSet.upload_documents(document_list: list[dict]) Uploads documents to the current dataset. -### Parameters +#### Parameters -#### document_list: `list[dict]`, *Required* +##### document_list: `list[dict]`, *Required* 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. - `"blob"`: (Optional) The binary content of the file to upload. -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python dataset = rag_object.create_dataset(name="kb_name") @@ -318,7 +315,7 @@ dataset.upload_documents([{"display_name": "1.txt", "blob": " bytes @@ -401,11 +398,11 @@ Document.download() -> bytes Downloads the current document. -### Returns +#### Returns The downloaded document in bytes. -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -421,7 +418,7 @@ print(doc) --- -## List documents +### List documents ```python Dataset.list_documents(id:str =None, keywords: str=None, page: int=1, page_size:int = 30, order_by:str = "create_time", desc: bool = True) -> list[Document] @@ -429,36 +426,36 @@ Dataset.list_documents(id:str =None, keywords: str=None, page: int=1, page_size: Lists documents in the current dataset. -### Parameters +#### Parameters -#### id: `str` +##### id: `str` The ID of the document to retrieve. Defaults to `None`. -#### keywords: `str` +##### keywords: `str` The keywords used to match document titles. Defaults to `None`. -#### page: `int` +##### page: `int` Specifies the page on which the documents will be displayed. Defaults to `1`. -#### page_size: `int` +##### page_size: `int` The maximum number of documents on each page. Defaults to `30`. -#### orderby: `str` +##### orderby: `str` The field by which documents should be sorted. Available options: - `"create_time"` (default) - `"update_time"` -#### desc: `bool` +##### desc: `bool` Indicates whether the retrieved documents should be sorted in descending order. Defaults to `True`. -### Returns +#### Returns - Success: A list of `Document` objects. - Failure: `Exception`. @@ -513,7 +510,7 @@ A `Document` object contains the following attributes: - `chunk_method`=`"email"`: `None` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -530,7 +527,7 @@ for doc in dataset.list_documents(keywords="rag", page=0, page_size=12): --- -## Delete documents +### Delete documents ```python DataSet.delete_documents(ids: list[str] = None) @@ -538,18 +535,18 @@ DataSet.delete_documents(ids: list[str] = None) Deletes documents by ID. -### Parameters +#### Parameters -#### ids: `list[list]` +##### ids: `list[list]` The IDs of the documents to delete. Defaults to `None`. If it is not specified, all documents in the dataset will be deleted. -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -562,7 +559,7 @@ dataset.delete_documents(ids=["id_1","id_2"]) --- -## Parse documents +### Parse documents ```python DataSet.async_parse_documents(document_ids:list[str]) -> None @@ -570,18 +567,18 @@ DataSet.async_parse_documents(document_ids:list[str]) -> None Parses documents in the current dataset. -### Parameters +#### Parameters -#### document_ids: `list[str]`, *Required* +##### document_ids: `list[str]`, *Required* The IDs of the documents to parse. -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python rag_object = RAGFlow(api_key="", base_url="http://:9380") @@ -602,7 +599,7 @@ print("Async bulk parsing initiated.") --- -## Stop parsing documents +### Stop parsing documents ```python DataSet.async_cancel_parse_documents(document_ids:list[str])-> None @@ -610,18 +607,18 @@ DataSet.async_cancel_parse_documents(document_ids:list[str])-> None Stops parsing specified documents. -### Parameters +#### Parameters -#### document_ids: `list[str]`, *Required* +##### document_ids: `list[str]`, *Required* The IDs of the documents for which parsing should be stopped. -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python rag_object = RAGFlow(api_key="", base_url="http://:9380") @@ -644,7 +641,7 @@ print("Async bulk parsing cancelled.") --- -## Add chunk +### Add chunk ```python Document.add_chunk(content:str, important_keywords:list[str] = []) -> Chunk @@ -652,17 +649,17 @@ Document.add_chunk(content:str, important_keywords:list[str] = []) -> Chunk Adds a chunk to the current document. -### Parameters +#### Parameters -#### content: `str`, *Required* +##### content: `str`, *Required* The text content of the chunk. -#### important_keywords: `list[str]` +##### important_keywords: `list[str]` The key terms or phrases to tag with the chunk. -### Returns +#### Returns - Success: A `Chunk` object. - Failure: `Exception`. @@ -681,8 +678,7 @@ A `Chunk` object contains the following attributes: - `False`: Unavailable - `True`: Available (default) - -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -697,7 +693,7 @@ chunk = doc.add_chunk(content="xxxxxxx") --- -## List chunks +### List chunks ```python Document.list_chunks(keywords: str = None, page: int = 1, page_size: int = 30, id : str = None) -> list[Chunk] @@ -705,30 +701,30 @@ Document.list_chunks(keywords: str = None, page: int = 1, page_size: int = 30, i Lists chunks in the current document. -### Parameters +#### Parameters -#### keywords: `str` +##### keywords: `str` The keywords used to match chunk content. Defaults to `None` -#### page: `int` +##### page: `int` Specifies the page on which the chunks will be displayed. Defaults to `1`. -#### page_size: `int` +##### page_size: `int` The maximum number of chunks on each page. Defaults to `30`. -#### id: `str` +##### id: `str` The ID of the chunk to retrieve. Default: `None` -### Returns +#### Returns - Success: A list of `Chunk` objects. - Failure: `Exception`. -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -743,7 +739,7 @@ for chunk in doc.list_chunks(keywords="rag", page=0, page_size=12): --- -## Delete chunks +### Delete chunks ```python Document.delete_chunks(chunk_ids: list[str]) @@ -751,18 +747,18 @@ Document.delete_chunks(chunk_ids: list[str]) Deletes chunks by ID. -### Parameters +#### Parameters -#### chunk_ids: `list[str]` +##### chunk_ids: `list[str]` The IDs of the chunks to delete. Defaults to `None`. If it is not specified, all chunks of the current document will be deleted. -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -778,7 +774,7 @@ doc.delete_chunks(["id_1","id_2"]) --- -## Update chunk +### Update chunk ```python Chunk.update(update_message: dict) @@ -786,9 +782,9 @@ Chunk.update(update_message: dict) Updates content or configurations for the current chunk. -### Parameters +#### Parameters -#### update_message: `dict[str, str|list[str]|int]` *Required* +##### update_message: `dict[str, str|list[str]|int]` *Required* A dictionary representing the attributes to update, with the following keys: @@ -798,12 +794,12 @@ A dictionary representing the attributes to update, with the following keys: - `False`: Unavailable - `True`: Available (default) -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -819,7 +815,7 @@ chunk.update({"content":"sdfx..."}) --- -## Retrieve chunks +### Retrieve chunks ```python RAGFlow.retrieve(question:str="", dataset_ids:list[str]=None, document_ids=list[str]=None, page:int=1, page_size:int=30, similarity_threshold:float=0.2, vector_similarity_weight:float=0.3, top_k:int=1024,rerank_id:str=None,keyword:bool=False,higlight:bool=False) -> list[Chunk] @@ -827,64 +823,64 @@ RAGFlow.retrieve(question:str="", dataset_ids:list[str]=None, document_ids=list[ Retrieves chunks from specified datasets. -### Parameters +#### Parameters -#### question: `str`, *Required* +##### question: `str`, *Required* The user query or query keywords. Defaults to `""`. -#### dataset_ids: `list[str]`, *Required* +##### dataset_ids: `list[str]`, *Required* The IDs of the datasets to search. Defaults to `None`. If you do not set this argument, ensure that you set `document_ids`. -#### document_ids: `list[str]` +##### 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. If you do not set this argument, ensure that you set `dataset_ids`. -#### page: `int` +##### page: `int` The starting index for the documents to retrieve. Defaults to `1`. -#### page_size: `int` +##### page_size: `int` The maximum number of chunks to retrieve. Defaults to `30`. -#### Similarity_threshold: `float` +##### Similarity_threshold: `float` The minimum similarity score. Defaults to `0.2`. -#### vector_similarity_weight: `float` +##### vector_similarity_weight: `float` The weight of vector cosine similarity. Defaults to `0.3`. If x represents the vector cosine similarity, then (1 - x) is the term similarity weight. -#### top_k: `int` +##### top_k: `int` The number of chunks engaged in vector cosine computaton. Defaults to `1024`. -#### rerank_id: `str` +##### rerank_id: `str` The ID of the rerank model. Defaults to `None`. -#### keyword: `bool` +##### keyword: `bool` Indicates whether to enable keyword-based matching: - `True`: Enable keyword-based matching. - `False`: Disable keyword-based matching (default). -#### highlight: `bool` +##### highlight: `bool` Specifies whether to enable highlighting of matched terms in the results: - `True`: Enable highlighting of matched terms. - `False`: Disable highlighting of matched terms (default). -### Returns +#### Returns - Success: A list of `Chunk` objects representing the document chunks. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -909,13 +905,11 @@ for c in rag_object.retrieve(question="What's ragflow?", --- -:::tip API GROUPING -Chat Assistant Management -::: +## CHAT ASSISTANT MANAGEMENT --- -## Create chat assistant +### Create chat assistant ```python RAGFlow.create_chat( @@ -929,21 +923,21 @@ RAGFlow.create_chat( Creates a chat assistant. -### Parameters +#### Parameters -#### name: `str`, *Required* +##### name: `str`, *Required* The name of the chat assistant. -#### avatar: `str` +##### avatar: `str` Base64 encoding of the avatar. Defaults to `""`. -#### dataset_ids: `list[str]` +##### dataset_ids: `list[str]` The IDs of the associated datasets. Defaults to `[""]`. -#### llm: `Chat.LLM` +##### llm: `Chat.LLM` The LLM settings for the chat assistant to create. Defaults to `None`. When the value is `None`, a dictionary with the following values will be generated as the default. An `LLM` object contains the following attributes: @@ -960,7 +954,7 @@ The LLM settings for the chat assistant to create. Defaults to `None`. When the - `max_token`: `int` The maximum length of the model's output, measured in the number of tokens (words or pieces of words). Defaults to `512`. If disabled, you lift the maximum token limit, allowing the model to determine the number of tokens in its responses. -#### prompt: `Chat.Prompt` +##### prompt: `Chat.Prompt` Instructions for the LLM to follow. A `Prompt` object contains the following attributes: @@ -977,12 +971,12 @@ Instructions for the LLM to follow. A `Prompt` object contains the following at - `show_quote`: `bool` Indicates whether the source of text should be displayed. Defaults to `True`. - `prompt`: `str` The prompt content. -### Returns +#### Returns - Success: A `Chat` object representing the chat assistant. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -997,7 +991,7 @@ assistant = rag_object.create_chat("Miss R", dataset_ids=dataset_ids) --- -## Update chat assistant +### Update chat assistant ```python Chat.update(update_message: dict) @@ -1005,9 +999,9 @@ Chat.update(update_message: dict) Updates configurations for the current chat assistant. -### Parameters +#### Parameters -#### update_message: `dict[str, str|list[str]|dict[]]`, *Required* +##### update_message: `dict[str, str|list[str]|dict[]]`, *Required* A dictionary representing the attributes to update, with the following keys: @@ -1035,12 +1029,12 @@ A dictionary representing the attributes to update, with the following keys: - `"show_quote`: `bool` Indicates whether the source of text should be displayed Defaults to `True`. - `"prompt"`: `str` The prompt content. -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -1054,7 +1048,7 @@ assistant.update({"name": "Stefan", "llm": {"temperature": 0.8}, "prompt": {"top --- -## Delete chat assistants +### Delete chat assistants ```python RAGFlow.delete_chats(ids: list[str] = None) @@ -1062,18 +1056,18 @@ RAGFlow.delete_chats(ids: list[str] = None) Deletes chat assistants by ID. -### Parameters +#### Parameters -#### ids: `list[str]` +##### ids: `list[str]` The IDs of the chat assistants to delete. Defaults to `None`. If it is empty or not specified, all chat assistants in the system will be deleted. -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -1084,7 +1078,7 @@ rag_object.delete_chats(ids=["id_1","id_2"]) --- -## List chat assistants +### List chat assistants ```python RAGFlow.list_chats( @@ -1099,41 +1093,41 @@ RAGFlow.list_chats( Lists chat assistants. -### Parameters +#### Parameters -#### page: `int` +##### page: `int` Specifies the page on which the chat assistants will be displayed. Defaults to `1`. -#### page_size: `int` +##### page_size: `int` The number of chat assistants on each page. Defaults to `30`. -#### orderby: `str` +##### orderby: `str` The attribute by which the results are sorted. Available options: - `"create_time"` (default) - `"update_time"` -#### desc: `bool` +##### desc: `bool` Indicates whether the retrieved chat assistants should be sorted in descending order. Defaults to `True`. -#### id: `str` +##### id: `str` The ID of the chat assistant to retrieve. Defaults to `None`. -#### name: `str` +##### name: `str` The name of the chat assistant to retrieve. Defaults to `None`. -### Returns +#### Returns - Success: A list of `Chat` objects. - Failure: `Exception`. -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -1145,13 +1139,11 @@ for assistant in rag_object.list_chats(): --- -:::tip API GROUPING -Chat Session APIs -::: +## CHAT SESSIONS --- -## Create session with chat assistant +### Create session with chat assistant ```python Chat.create_session(name: str = "New session") -> Session @@ -1159,22 +1151,22 @@ Chat.create_session(name: str = "New session") -> Session Creates a session with the current chat assistant. -### Parameters +#### Parameters -#### name: `str` +##### name: `str` The name of the chat session to create. -### Returns +#### Returns - Success: A `Session` object containing the following attributes: - `id`: `str` The auto-generated unique identifier of the created session. - `name`: `str` The name of the created session. - - `message`: `list[Message]` The messages of the created session assistant. Default: `[{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}]` + - `message`: `list[Message]` The opening message of the created session. Default: `[{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}]` - `chat_id`: `str` The ID of the associated chat assistant. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -1187,7 +1179,7 @@ session = assistant.create_session() --- -## Update chat assistant's session +### Update chat assistant's session ```python Session.update(update_message: dict) @@ -1195,20 +1187,20 @@ Session.update(update_message: dict) Updates the current session of the current chat assistant. -### Parameters +#### Parameters -#### update_message: `dict[str, Any]`, *Required* +##### update_message: `dict[str, Any]`, *Required* A dictionary representing the attributes to update, with only one key: - `"name"`: `str` The revised name of the session. -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -1222,7 +1214,7 @@ session.update({"name": "updated_name"}) --- -## List chat assistant's sessions +### List chat assistant's sessions ```python Chat.list_sessions( @@ -1237,41 +1229,41 @@ Chat.list_sessions( Lists sessions associated with the current chat assistant. -### Parameters +#### Parameters -#### page: `int` +##### page: `int` Specifies the page on which the sessions will be displayed. Defaults to `1`. -#### page_size: `int` +##### page_size: `int` The number of sessions on each page. Defaults to `30`. -#### orderby: `str` +##### orderby: `str` The field by which sessions should be sorted. Available options: - `"create_time"` (default) - `"update_time"` -#### desc: `bool` +##### desc: `bool` Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `True`. -#### id: `str` +##### id: `str` The ID of the chat session to retrieve. Defaults to `None`. -#### name: `str` +##### name: `str` The name of the chat session to retrieve. Defaults to `None`. -### Returns +#### Returns - Success: A list of `Session` objects associated with the current chat assistant. - Failure: `Exception`. -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -1285,7 +1277,7 @@ for session in assistant.list_sessions(): --- -## Delete chat assistant's sessions +### Delete chat assistant's sessions ```python Chat.delete_sessions(ids:list[str] = None) @@ -1293,18 +1285,18 @@ Chat.delete_sessions(ids:list[str] = None) Deletes sessions of the current chat assistant by ID. -### Parameters +#### Parameters -#### ids: `list[str]` +##### ids: `list[str]` The IDs of the sessions to delete. Defaults to `None`. If it is not specified, all sessions associated with the current chat assistant will be deleted. -### Returns +#### Returns - Success: No value is returned. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -1317,7 +1309,7 @@ assistant.delete_sessions(ids=["id_1","id_2"]) --- -## Converse with chat assistant +### Converse with chat assistant ```python Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]] @@ -1329,35 +1321,35 @@ Asks a specified chat assistant a question to start an AI-powered conversation. In streaming mode, not all responses include a reference, as this depends on the system's judgement. ::: -### Parameters +#### Parameters -#### question: `str`, *Required* +##### question: `str`, *Required* The question to start an AI-powered conversation. -#### stream: `bool` +##### stream: `bool` Indicates whether to output responses in a streaming way: - `True`: Enable streaming (default). - `False`: Disable streaming. -### Returns +#### Returns -- A `Message` object containing the response to the question if `stream` is set to `False` +- A `Message` object containing the response to the question if `stream` is set to `False`. - An iterator containing multiple `message` objects (`iter[Message]`) if `stream` is set to `True` The following shows the attributes of a `Message` object: -#### id: `str` +##### id: `str` The auto-generated message ID. -#### content: `str` +##### content: `str` The content of the message. Defaults to `"Hi! I am your assistant, can I help you?"`. -#### reference: `list[Chunk]` +##### reference: `list[Chunk]` A list of `Chunk` objects representing references to the message, each containing the following attributes: @@ -1382,7 +1374,7 @@ A list of `Chunk` objects representing references to the message, each containin - `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 +#### Examples ```python from ragflow_sdk import RAGFlow @@ -1407,15 +1399,15 @@ while True: --- -## Create session with agent -*If there are parameters in the `begin` component, the session cannot be created in this way.* +### Create session with agent + ```python Agent.create_session(id,rag) -> Session ``` -Creates a session with the current agent. +Creates a session with the current agent. -### Returns +#### Returns - Success: A `Session` object containing the following attributes: - `id`: `str` The auto-generated unique identifier of the created session. @@ -1423,7 +1415,7 @@ Creates a session with the current agent. - `agent_id`: `str` The ID of the associated agent assistant. - Failure: `Exception` -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -1435,7 +1427,7 @@ session = create_session(AGENT_ID,rag_object) --- -## Converse with agent +### Converse with agent ```python Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]] @@ -1447,35 +1439,35 @@ Asks a specified agent a question to start an AI-powered conversation. In streaming mode, not all responses include a reference, as this depends on the system's judgement. ::: -### Parameters +#### Parameters -#### question: `str`, *Required* +##### question: `str`, *Required* The question to start an AI-powered conversation. -#### stream: `bool` +##### stream: `bool` Indicates whether to output responses in a streaming way: - `True`: Enable streaming (default). - `False`: Disable streaming. -### Returns +#### Returns - A `Message` object containing the response to the question if `stream` is set to `False` - An iterator containing multiple `message` objects (`iter[Message]`) if `stream` is set to `True` The following shows the attributes of a `Message` object: -#### id: `str` +##### id: `str` The auto-generated message ID. -#### content: `str` +##### content: `str` The content of the message. Defaults to `"Hi! I am your assistant, can I help you?"`. -#### reference: `list[Chunk]` +##### reference: `list[Chunk]` A list of `Chunk` objects representing references to the message, each containing the following attributes: @@ -1500,7 +1492,7 @@ A list of `Chunk` objects representing references to the message, each containin - `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 +#### Examples ```python from ragflow_sdk import RAGFlow,Agent @@ -1521,9 +1513,10 @@ while True: print(ans.content[len(cont):], end='', flush=True) cont = ans.content ``` + --- -## List agent sessions +### List agent sessions ```python Agent.list_sessions( @@ -1539,38 +1532,37 @@ Agent.list_sessions( Lists sessions associated with the current agent. -### Parameters +#### Parameters -#### page: `int` +##### page: `int` Specifies the page on which the sessions will be displayed. Defaults to `1`. -#### page_size: `int` +##### page_size: `int` The number of sessions on each page. Defaults to `30`. -#### orderby: `str` +##### orderby: `str` The field by which sessions should be sorted. Available options: - `"create_time"` - `"update_time"`(default) -#### desc: `bool` +##### desc: `bool` Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `True`. -#### id: `str` +##### id: `str` The ID of the agent session to retrieve. Defaults to `None`. - -### Returns +#### Returns - Success: A list of `Session` objects associated with the current agent. - Failure: `Exception`. -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow @@ -1583,7 +1575,8 @@ for session in sessions: ``` --- -## List agents + +### List agents ```python RAGFlow.list_agents( @@ -1598,45 +1591,47 @@ RAGFlow.list_agents( Lists agents. -### Parameters +#### Parameters -#### page: `int` +##### page: `int` Specifies the page on which the agents will be displayed. Defaults to `1`. -#### page_size: `int` +##### page_size: `int` The number of agents on each page. Defaults to `30`. -#### orderby: `str` +##### orderby: `str` The attribute by which the results are sorted. Available options: - `"create_time"` (default) - `"update_time"` -#### desc: `bool` +##### desc: `bool` Indicates whether the retrieved agents should be sorted in descending order. Defaults to `True`. -#### id: `str` +##### id: `str` The ID of the agent to retrieve. Defaults to `None`. -#### name: `str` +##### name: `str` The name of the agent to retrieve. Defaults to `None`. -### Returns +#### Returns - Success: A list of `Agent` objects. - Failure: `Exception`. -### Examples +#### Examples ```python from ragflow_sdk import RAGFlow rag_object = RAGFlow(api_key="", base_url="http://:9380") for agent in rag_object.list_agents(): print(agent) -``` \ No newline at end of file +``` + +--- \ No newline at end of file