diff --git a/conf/mapping.json b/conf/mapping.json index 7f8c4e27e9c..f32acb02bc3 100644 --- a/conf/mapping.json +++ b/conf/mapping.json @@ -140,13 +140,21 @@ } }, { - "string": { + "rank_feature": { "match": "*_fea", "mapping": { "type": "rank_feature" } } }, + { + "rank_features": { + "match": "*_feas", + "mapping": { + "type": "rank_features" + } + } + }, { "dense_vector": { "match": "*_512_vec", diff --git a/docs/references/http_api_reference.md b/docs/references/http_api_reference.md index a904e14c286..261df429334 100644 --- a/docs/references/http_api_reference.md +++ b/docs/references/http_api_reference.md @@ -2364,4 +2364,1162 @@ Failure: } ``` ---- \ No newline at end of file +--- + +## 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 + +- 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 + +```bash +curl --request GET \ + --url http://{address}/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id} \ + --header 'Authorization: Bearer ' +``` + +#### Request Parameters + +- `agent_id`: (*Path parameter*) + The ID of the associated agent. +- `page`: (*Filter parameter*), `integer` + Specifies the page on which the sessions will be displayed. Defaults to `1`. +- `page_size`: (*Filter parameter*), `integer` + The number of sessions on each page. Defaults to `30`. +- `orderby`: (*Filter parameter*), `string` + The field by which sessions should be sorted. Available options: + - `create_time` (default) + - `update_time` +- `desc`: (*Filter parameter*), `boolean` + Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `true`. +- `id`: (*Filter parameter*), `string` + The ID of the agent session to retrieve. + +### Response + +Success: + +```json +{ + "code": 0, + "data": [ + { + "agent_id": "ccd2f856b12311ef94ca0242ac120005", + "create_date": "Tue, 03 Dec 2024 18:28:02 GMT", + "create_time": 1733221682994, + "dsl": { + "answer": [], + "components": { + "Answer:SilentNeedlesDouble": { + "downstream": [ + "Categorize:TameDodosLove" + ], + "obj": { + "component_name": "Answer", + "inputs": [], + "output": null, + "params": { + "inputs": [], + "message_history_window_size": 22, + "output": null, + "output_var_name": "output", + "post_answers": [], + "query": [] + } + }, + "upstream": [ + "Generate:RealCatsJudge" + ] + }, + "Answer:ThickBeesTap": { + "downstream": [ + "Categorize:TameDodosLove" + ], + "obj": { + "component_name": "Answer", + "inputs": [], + "output": { + "content": "Hi! I'm your smart assistant. What can I do for you?" + }, + "params": { + "inputs": [], + "message_history_window_size": 22, + "output": { + "content": "Hi! I'm your smart assistant. What can I do for you?" + }, + "output_var_name": "output", + "post_answers": [], + "query": [] + } + }, + "upstream": [ + "begin" + ] + }, + "Baidu:TrueBananasPay": { + "downstream": [], + "obj": { + "component_name": "Baidu", + "inputs": [], + "output": null, + "params": { + "inputs": [], + "message_history_window_size": 22, + "output": null, + "output_var_name": "output", + "query": [], + "top_n": 10 + } + }, + "upstream": [] + }, + "Categorize:TameDodosLove": { + "downstream": [ + "Retrieval:KindMammalsBeg" + ], + "obj": { + "component_name": "Categorize", + "inputs": [], + "output": null, + "params": { + "category_description": { + "百度搜索": { + "description": "接收用户的问题", + "examples": "who are you\n今天天气如何", + "index": 0, + "to": "Retrieval:KindMammalsBeg" + } + }, + "cite": true, + "frequency_penalty": 0.7, + "inputs": [], + "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible", + "max_tokens": 256, + "message_history_window_size": 1, + "output": null, + "output_var_name": "output", + "parameters": [], + "presence_penalty": 0.4, + "prompt": "", + "query": [], + "temperature": 0.1, + "top_p": 0.3 + } + }, + "upstream": [ + "Answer:ThickBeesTap", + "Answer:SilentNeedlesDouble" + ] + }, + "Generate:RealCatsJudge": { + "downstream": [ + "Answer:SilentNeedlesDouble" + ], + "obj": { + "component_name": "Generate", + "inputs": [], + "output": null, + "params": { + "cite": true, + "frequency_penalty": 0.7, + "inputs": [], + "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible", + "max_tokens": 256, + "message_history_window_size": 12, + "output": null, + "output_var_name": "output", + "parameters": [ + { + "component_id": "Retrieval:KindMammalsBeg", + "id": "1cc92398-2306-42ee-b401-6bfb49e1084e", + "key": "input" + } + ], + "presence_penalty": 0.4, + "prompt": "Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:\n {input}\n The above is the content you need to summarize.", + "query": [], + "temperature": 0.1, + "top_p": 0.3 + } + }, + "upstream": [ + "Retrieval:KindMammalsBeg" + ] + }, + "Retrieval:KindMammalsBeg": { + "downstream": [ + "Generate:RealCatsJudge" + ], + "obj": { + "component_name": "Retrieval", + "inputs": [], + "output": null, + "params": { + "empty_response": "", + "inputs": [], + "kb_ids": [ + "0f8fe876ab1a11efa22c0242ac120006" + ], + "keywords_similarity_weight": 0.3, + "message_history_window_size": 22, + "output": null, + "output_var_name": "output", + "query": [], + "rerank_id": "", + "similarity_threshold": 0.2, + "top_k": 1024, + "top_n": 8 + } + }, + "upstream": [ + "Categorize:TameDodosLove" + ] + }, + "begin": { + "downstream": [ + "Answer:ThickBeesTap" + ], + "obj": { + "component_name": "Begin", + "inputs": [], + "output": { + "content": "Hi! I'm your smart assistant. What can I do for you?" + }, + "params": { + "inputs": [], + "message_history_window_size": 22, + "output": { + "content": "Hi! I'm your smart assistant. What can I do for you?" + }, + "output_var_name": "output", + "prologue": "Hi! I'm your smart assistant. What can I do for you?", + "query": [] + } + }, + "upstream": [] + } + }, + "embed_id": "", + "graph": { + "edges": [ + { + "id": "reactflow__edge-begin-Answer:ThickBeesTapc", + "markerEnd": "logo", + "source": "begin", + "sourceHandle": null, + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Answer:ThickBeesTap", + "targetHandle": "c", + "type": "buttonEdge" + }, + { + "id": "reactflow__edge-Answer:ThickBeesTapb-Categorize:TameDodosLovea", + "markerEnd": "logo", + "source": "Answer:ThickBeesTap", + "sourceHandle": "b", + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Categorize:TameDodosLove", + "targetHandle": "a", + "type": "buttonEdge" + }, + { + "id": "reactflow__edge-Generate:RealCatsJudgec-Answer:SilentNeedlesDoubleb", + "markerEnd": "logo", + "selected": false, + "source": "Generate:RealCatsJudge", + "sourceHandle": "c", + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Answer:SilentNeedlesDouble", + "targetHandle": "b", + "type": "buttonEdge" + }, + { + "id": "reactflow__edge-Answer:SilentNeedlesDoublec-Categorize:TameDodosLovea", + "markerEnd": "logo", + "source": "Answer:SilentNeedlesDouble", + "sourceHandle": "c", + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Categorize:TameDodosLove", + "targetHandle": "a", + "type": "buttonEdge" + }, + { + "id": "reactflow__edge-Categorize:TameDodosLove百度搜索-Retrieval:KindMammalsBegc", + "markerEnd": "logo", + "source": "Categorize:TameDodosLove", + "sourceHandle": "百度搜索", + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Retrieval:KindMammalsBeg", + "targetHandle": "c", + "type": "buttonEdge" + }, + { + "id": "reactflow__edge-Retrieval:KindMammalsBegb-Generate:RealCatsJudgeb", + "markerEnd": "logo", + "source": "Retrieval:KindMammalsBeg", + "sourceHandle": "b", + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Generate:RealCatsJudge", + "targetHandle": "b", + "type": "buttonEdge" + } + ], + "nodes": [ + { + "data": { + "label": "Begin", + "name": "begin" + }, + "height": 44, + "id": "begin", + "position": { + "x": 50, + "y": 200 + }, + "sourcePosition": "left", + "targetPosition": "right", + "type": "beginNode", + "width": 200 + }, + { + "data": { + "form": {}, + "label": "Answer", + "name": "对话_0" + }, + "dragging": false, + "height": 44, + "id": "Answer:ThickBeesTap", + "position": { + "x": 297.6576850283112, + "y": 203.86553837720618 + }, + "positionAbsolute": { + "x": 297.6576850283112, + "y": 203.86553837720618 + }, + "selected": false, + "sourcePosition": "right", + "targetPosition": "left", + "type": "logicNode", + "width": 200 + }, + { + "data": { + "form": { + "category_description": { + "百度搜索": { + "description": "接收用户的问题", + "examples": "who are you\n今天天气如何", + "index": 0, + "to": "Retrieval:KindMammalsBeg" + } + }, + "frequencyPenaltyEnabled": true, + "frequency_penalty": 0.7, + "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible", + "maxTokensEnabled": true, + "max_tokens": 256, + "message_history_window_size": 1, + "presencePenaltyEnabled": true, + "presence_penalty": 0.4, + "query": [], + "temperature": 0.1, + "temperatureEnabled": true, + "topPEnabled": true, + "top_p": 0.3 + }, + "label": "Categorize", + "name": "问题分类_0" + }, + "dragging": false, + "height": 136, + "id": "Categorize:TameDodosLove", + "position": { + "x": 621.0820384684355, + "y": 220.11059722579682 + }, + "positionAbsolute": { + "x": 621.0820384684355, + "y": 220.11059722579682 + }, + "selected": false, + "sourcePosition": "right", + "targetPosition": "left", + "type": "categorizeNode", + "width": 200 + }, + { + "data": { + "form": { + "query": [], + "top_n": 10 + }, + "label": "Baidu", + "name": "百度_0" + }, + "dragging": false, + "height": 64, + "id": "Baidu:TrueBananasPay", + "position": { + "x": 1090.4399996938341, + "y": -10.899556912399987 + }, + "positionAbsolute": { + "x": 1090.4399996938341, + "y": -10.899556912399987 + }, + "selected": false, + "sourcePosition": "right", + "targetPosition": "left", + "type": "ragNode", + "width": 200 + }, + { + "data": { + "form": { + "cite": true, + "frequencyPenaltyEnabled": true, + "frequency_penalty": 0.7, + "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible", + "maxTokensEnabled": true, + "max_tokens": 256, + "message_history_window_size": 12, + "parameters": [ + { + "component_id": "Retrieval:KindMammalsBeg", + "id": "1cc92398-2306-42ee-b401-6bfb49e1084e", + "key": "input" + } + ], + "presencePenaltyEnabled": true, + "presence_penalty": 0.4, + "prompt": "Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:\n {input}\n The above is the content you need to summarize.", + "temperature": 0.1, + "temperatureEnabled": true, + "topPEnabled": true, + "top_p": 0.3 + }, + "label": "Generate", + "name": "生成回答_0" + }, + "dragging": false, + "height": 147, + "id": "Generate:RealCatsJudge", + "position": { + "x": 816.022744651524, + "y": 585.3018986039125 + }, + "positionAbsolute": { + "x": 816.022744651524, + "y": 585.3018986039125 + }, + "selected": true, + "sourcePosition": "right", + "targetPosition": "left", + "type": "generateNode", + "width": 200 + }, + { + "data": { + "form": {}, + "label": "Answer", + "name": "对话_1" + }, + "height": 44, + "id": "Answer:SilentNeedlesDouble", + "position": { + "x": 402.5121557783059, + "y": 676.449068518027 + }, + "sourcePosition": "right", + "targetPosition": "left", + "type": "logicNode", + "width": 200 + }, + { + "data": { + "form": { + "kb_ids": [ + "0f8fe876ab1a11efa22c0242ac120006" + ], + "keywords_similarity_weight": 0.3, + "query": [], + "similarity_threshold": 0.2, + "top_n": 8 + }, + "label": "Retrieval", + "name": "知识检索_0" + }, + "dragging": false, + "height": 106, + "id": "Retrieval:KindMammalsBeg", + "position": { + "x": 975.4304422274787, + "y": 341.7370543002002 + }, + "positionAbsolute": { + "x": 975.4304422274787, + "y": 341.7370543002002 + }, + "selected": false, + "sourcePosition": "right", + "targetPosition": "left", + "type": "retrievalNode", + "width": 200 + } + ] + }, + "history": [ + [ + "assistant", + "Hi! I'm your smart assistant. What can I do for you?" + ] + ], + "messages": [ + { + "content": "Hi! I'm your smart assistant. What can I do for you?", + "id": "472be0d2b15f11ef92df0242ac120005", + "role": "assistant" + } + ], + "path": [ + [ + "begin" + ], + [ + "Answer:ThickBeesTap" + ] + ], + "reference": [] + }, + "duration": 0.0, + "id": "46d2cbeeb16111efb2c10242ac120005", + "messages": [ + { + "content": "Hi! I'm your smart assistant. What can I do for you?", + "role": "assistant" + } + ], + "round": 0, + "source": "agent", + "thumb_up": 0, + "tokens": 0, + "update_date": "Tue, 03 Dec 2024 18:28:02 GMT", + "update_time": 1733221682994, + "user_id": "69736c5e723611efb51b0242ac120007" + } + ] +} +``` + +Failure: + +```json +{ + "code": 102, + "message": "You don't own the agent ccd2f856b12311ef94ca0242ac1200052." +} +``` +--- +## 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 + +- 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 + +```bash +curl --request GET \ + --url http://{address}/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id} \ + --header 'Authorization: Bearer ' +``` + +#### Request parameters + +- `page`: (*Filter parameter*), `integer` + Specifies the page on which the agents will be displayed. Defaults to `1`. +- `page_size`: (*Filter parameter*), `integer` + The number of agents on each page. Defaults to `30`. +- `orderby`: (*Filter parameter*), `string` + The attribute by which the results are sorted. Available options: + - `create_time` (default) + - `update_time` +- `desc`: (*Filter parameter*), `boolean` + Indicates whether the retrieved agents should be sorted in descending order. Defaults to `true`. +- `id`: (*Filter parameter*), `string` + The ID of the agent to retrieve. +- `name`: (*Filter parameter*), `string` + The name of the agent to retrieve. + +### Response + +Success: + +```json +{ + "code": 0, + "data": [ + { + "avatar": null, + "canvas_type": null, + "create_date": "Tue, 03 Dec 2024 11:07:59 GMT", + "create_time": 1733195279013, + "description": null, + "dsl": { + "answer": [], + "components": { + "Answer:SilentNeedlesDouble": { + "downstream": [ + "Categorize:TameDodosLove" + ], + "obj": { + "component_name": "Answer", + "inputs": [], + "output": null, + "params": { + "inputs": [], + "message_history_window_size": 22, + "output": null, + "output_var_name": "output", + "post_answers": [], + "query": [] + } + }, + "upstream": [ + "Generate:RealCatsJudge" + ] + }, + "Answer:ThickBeesTap": { + "downstream": [ + "Categorize:TameDodosLove" + ], + "obj": { + "component_name": "Answer", + "inputs": [], + "output": { + "content": "Hi! I'm your smart assistant. What can I do for you?" + }, + "params": { + "inputs": [], + "message_history_window_size": 22, + "output": { + "content": "Hi! I'm your smart assistant. What can I do for you?" + }, + "output_var_name": "output", + "post_answers": [], + "query": [] + } + }, + "upstream": [ + "begin" + ] + }, + "Baidu:TrueBananasPay": { + "downstream": [], + "obj": { + "component_name": "Baidu", + "inputs": [], + "output": null, + "params": { + "inputs": [], + "message_history_window_size": 22, + "output": null, + "output_var_name": "output", + "query": [], + "top_n": 10 + } + }, + "upstream": [] + }, + "Categorize:TameDodosLove": { + "downstream": [ + "Retrieval:KindMammalsBeg" + ], + "obj": { + "component_name": "Categorize", + "inputs": [], + "output": null, + "params": { + "category_description": { + "百度搜索": { + "description": "接收用户的问题", + "examples": "who are you\n今天天气如何", + "index": 0, + "to": "Retrieval:KindMammalsBeg" + } + }, + "cite": true, + "frequency_penalty": 0.7, + "inputs": [], + "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible", + "max_tokens": 256, + "message_history_window_size": 1, + "output": null, + "output_var_name": "output", + "parameters": [], + "presence_penalty": 0.4, + "prompt": "", + "query": [], + "temperature": 0.1, + "top_p": 0.3 + } + }, + "upstream": [ + "Answer:ThickBeesTap", + "Answer:SilentNeedlesDouble" + ] + }, + "Generate:RealCatsJudge": { + "downstream": [ + "Answer:SilentNeedlesDouble" + ], + "obj": { + "component_name": "Generate", + "inputs": [], + "output": null, + "params": { + "cite": true, + "frequency_penalty": 0.7, + "inputs": [], + "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible", + "max_tokens": 256, + "message_history_window_size": 12, + "output": null, + "output_var_name": "output", + "parameters": [ + { + "component_id": "Retrieval:KindMammalsBeg", + "id": "1cc92398-2306-42ee-b401-6bfb49e1084e", + "key": "input" + } + ], + "presence_penalty": 0.4, + "prompt": "Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:\n {input}\n The above is the content you need to summarize.", + "query": [], + "temperature": 0.1, + "top_p": 0.3 + } + }, + "upstream": [ + "Retrieval:KindMammalsBeg" + ] + }, + "Retrieval:KindMammalsBeg": { + "downstream": [ + "Generate:RealCatsJudge" + ], + "obj": { + "component_name": "Retrieval", + "inputs": [], + "output": null, + "params": { + "empty_response": "", + "inputs": [], + "kb_ids": [ + "0f8fe876ab1a11efa22c0242ac120006" + ], + "keywords_similarity_weight": 0.3, + "message_history_window_size": 22, + "output": null, + "output_var_name": "output", + "query": [], + "rerank_id": "", + "similarity_threshold": 0.2, + "top_k": 1024, + "top_n": 8 + } + }, + "upstream": [ + "Categorize:TameDodosLove" + ] + }, + "begin": { + "downstream": [ + "Answer:ThickBeesTap" + ], + "obj": { + "component_name": "Begin", + "inputs": [], + "output": { + "content": "Hi! I'm your smart assistant. What can I do for you?" + }, + "params": { + "inputs": [], + "message_history_window_size": 22, + "output": { + "content": "Hi! I'm your smart assistant. What can I do for you?" + }, + "output_var_name": "output", + "prologue": "Hi! I'm your smart assistant. What can I do for you?", + "query": [] + } + }, + "upstream": [] + } + }, + "embed_id": "", + "graph": { + "edges": [ + { + "id": "reactflow__edge-begin-Answer:ThickBeesTapc", + "markerEnd": "logo", + "source": "begin", + "sourceHandle": null, + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Answer:ThickBeesTap", + "targetHandle": "c", + "type": "buttonEdge" + }, + { + "id": "reactflow__edge-Answer:ThickBeesTapb-Categorize:TameDodosLovea", + "markerEnd": "logo", + "source": "Answer:ThickBeesTap", + "sourceHandle": "b", + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Categorize:TameDodosLove", + "targetHandle": "a", + "type": "buttonEdge" + }, + { + "id": "reactflow__edge-Generate:RealCatsJudgec-Answer:SilentNeedlesDoubleb", + "markerEnd": "logo", + "selected": false, + "source": "Generate:RealCatsJudge", + "sourceHandle": "c", + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Answer:SilentNeedlesDouble", + "targetHandle": "b", + "type": "buttonEdge" + }, + { + "id": "reactflow__edge-Answer:SilentNeedlesDoublec-Categorize:TameDodosLovea", + "markerEnd": "logo", + "source": "Answer:SilentNeedlesDouble", + "sourceHandle": "c", + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Categorize:TameDodosLove", + "targetHandle": "a", + "type": "buttonEdge" + }, + { + "id": "reactflow__edge-Categorize:TameDodosLove百度搜索-Retrieval:KindMammalsBegc", + "markerEnd": "logo", + "source": "Categorize:TameDodosLove", + "sourceHandle": "百度搜索", + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Retrieval:KindMammalsBeg", + "targetHandle": "c", + "type": "buttonEdge" + }, + { + "id": "reactflow__edge-Retrieval:KindMammalsBegb-Generate:RealCatsJudgeb", + "markerEnd": "logo", + "source": "Retrieval:KindMammalsBeg", + "sourceHandle": "b", + "style": { + "stroke": "rgb(202 197 245)", + "strokeWidth": 2 + }, + "target": "Generate:RealCatsJudge", + "targetHandle": "b", + "type": "buttonEdge" + } + ], + "nodes": [ + { + "data": { + "label": "Begin", + "name": "begin" + }, + "height": 44, + "id": "begin", + "position": { + "x": 50, + "y": 200 + }, + "sourcePosition": "left", + "targetPosition": "right", + "type": "beginNode", + "width": 200 + }, + { + "data": { + "form": {}, + "label": "Answer", + "name": "对话_0" + }, + "dragging": false, + "height": 44, + "id": "Answer:ThickBeesTap", + "position": { + "x": 297.6576850283112, + "y": 203.86553837720618 + }, + "positionAbsolute": { + "x": 297.6576850283112, + "y": 203.86553837720618 + }, + "selected": false, + "sourcePosition": "right", + "targetPosition": "left", + "type": "logicNode", + "width": 200 + }, + { + "data": { + "form": { + "category_description": { + "百度搜索": { + "description": "接收用户的问题", + "examples": "who are you\n今天天气如何", + "index": 0, + "to": "Retrieval:KindMammalsBeg" + } + }, + "frequencyPenaltyEnabled": true, + "frequency_penalty": 0.7, + "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible", + "maxTokensEnabled": true, + "max_tokens": 256, + "message_history_window_size": 1, + "presencePenaltyEnabled": true, + "presence_penalty": 0.4, + "query": [], + "temperature": 0.1, + "temperatureEnabled": true, + "topPEnabled": true, + "top_p": 0.3 + }, + "label": "Categorize", + "name": "问题分类_0" + }, + "dragging": false, + "height": 136, + "id": "Categorize:TameDodosLove", + "position": { + "x": 621.0820384684355, + "y": 220.11059722579682 + }, + "positionAbsolute": { + "x": 621.0820384684355, + "y": 220.11059722579682 + }, + "selected": false, + "sourcePosition": "right", + "targetPosition": "left", + "type": "categorizeNode", + "width": 200 + }, + { + "data": { + "form": { + "query": [], + "top_n": 10 + }, + "label": "Baidu", + "name": "百度_0" + }, + "dragging": false, + "height": 64, + "id": "Baidu:TrueBananasPay", + "position": { + "x": 1090.4399996938341, + "y": -10.899556912399987 + }, + "positionAbsolute": { + "x": 1090.4399996938341, + "y": -10.899556912399987 + }, + "selected": false, + "sourcePosition": "right", + "targetPosition": "left", + "type": "ragNode", + "width": 200 + }, + { + "data": { + "form": { + "cite": true, + "frequencyPenaltyEnabled": true, + "frequency_penalty": 0.7, + "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible", + "maxTokensEnabled": true, + "max_tokens": 256, + "message_history_window_size": 12, + "parameters": [ + { + "component_id": "Retrieval:KindMammalsBeg", + "id": "1cc92398-2306-42ee-b401-6bfb49e1084e", + "key": "input" + } + ], + "presencePenaltyEnabled": true, + "presence_penalty": 0.4, + "prompt": "Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:\n {input}\n The above is the content you need to summarize.", + "temperature": 0.1, + "temperatureEnabled": true, + "topPEnabled": true, + "top_p": 0.3 + }, + "label": "Generate", + "name": "生成回答_0" + }, + "dragging": false, + "height": 147, + "id": "Generate:RealCatsJudge", + "position": { + "x": 816.022744651524, + "y": 585.3018986039125 + }, + "positionAbsolute": { + "x": 816.022744651524, + "y": 585.3018986039125 + }, + "selected": true, + "sourcePosition": "right", + "targetPosition": "left", + "type": "generateNode", + "width": 200 + }, + { + "data": { + "form": {}, + "label": "Answer", + "name": "对话_1" + }, + "height": 44, + "id": "Answer:SilentNeedlesDouble", + "position": { + "x": 402.5121557783059, + "y": 676.449068518027 + }, + "sourcePosition": "right", + "targetPosition": "left", + "type": "logicNode", + "width": 200 + }, + { + "data": { + "form": { + "kb_ids": [ + "0f8fe876ab1a11efa22c0242ac120006" + ], + "keywords_similarity_weight": 0.3, + "query": [], + "similarity_threshold": 0.2, + "top_n": 8 + }, + "label": "Retrieval", + "name": "知识检索_0" + }, + "dragging": false, + "height": 106, + "id": "Retrieval:KindMammalsBeg", + "position": { + "x": 975.4304422274787, + "y": 341.7370543002002 + }, + "positionAbsolute": { + "x": 975.4304422274787, + "y": 341.7370543002002 + }, + "selected": false, + "sourcePosition": "right", + "targetPosition": "left", + "type": "retrievalNode", + "width": 200 + } + ] + }, + "history": [ + [ + "assistant", + "Hi! I'm your smart assistant. What can I do for you?" + ] + ], + "messages": [ + { + "content": "Hi! I'm your smart assistant. What can I do for you?", + "id": "472be0d2b15f11ef92df0242ac120005", + "role": "assistant" + } + ], + "path": [ + [ + "begin" + ], + [ + "Answer:ThickBeesTap" + ] + ], + "reference": [] + }, + "id": "ccd2f856b12311ef94ca0242ac120005", + "title": "test2", + "update_date": "Tue, 03 Dec 2024 18:13:44 GMT", + "update_time": 1733220824599, + "user_id": "69736c5e723611efb51b0242ac120007" + } + ] +} +``` + +Failure: + +```json +{ + "code": 102, + "message": "The agent doesn't exist." +} +``` \ No newline at end of file diff --git a/docs/references/python_api_reference.md b/docs/references/python_api_reference.md index 1126188c657..4ca703f60ee 100644 --- a/docs/references/python_api_reference.md +++ b/docs/references/python_api_reference.md @@ -1,4 +1,4 @@ ---- +from sdk.python.ragflow_sdk import Agentfrom docutils.nodes import titlefrom sdk.python.ragflow_sdk import Agent--- sidebar_position: 2 slug: /python_api_reference --- @@ -1513,4 +1513,123 @@ while True: for ans in session.ask(question, stream=True): print(ans.content[len(cont):], end='', flush=True) cont = ans.content +``` +--- + +## List agent sessions + +```python +Agent.list_sessions( + agent_id, + rag + page: int = 1, + page_size: int = 30, + orderby: str = "update_time", + desc: bool = True, + id: str = None +) -> List[Session] +``` + +Lists sessions associated with the current agent. + +### Parameters + +#### page: `int` + +Specifies the page on which the sessions will be displayed. Defaults to `1`. + +#### page_size: `int` + +The number of sessions on each page. Defaults to `30`. + +#### orderby: `str` + +The field by which sessions should be sorted. Available options: + +- `"create_time"` +- `"update_time"`(default) + +#### desc: `bool` + +Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `True`. + +#### id: `str` + +The ID of the agent session to retrieve. Defaults to `None`. + + +### Returns + +- Success: A list of `Session` objects associated with the current agent. +- Failure: `Exception`. + +### Examples + +```python +from ragflow_sdk import RAGFlow + +rag_object = RAGFlow(api_key="", base_url="http://:9380") +agent_id = "2710f2269b4611ef8fdf0242ac120006" +sessions=Agent.list_sessions(agent_id,rag_object) +for session in sessions: + print(session) +``` + +--- +## List agents + +```python +RAGFlow.list_agents( + page: int = 1, + page_size: int = 30, + orderby: str = "create_time", + desc: bool = True, + id: str = None, + title: str = None +) -> List[Agent] +``` + +Lists agents. + +### Parameters + +#### page: `int` + +Specifies the page on which the agents will be displayed. Defaults to `1`. + +#### page_size: `int` + +The number of agents on each page. Defaults to `30`. + +#### orderby: `str` + +The attribute by which the results are sorted. Available options: + +- `"create_time"` (default) +- `"update_time"` + +#### desc: `bool` + +Indicates whether the retrieved agents should be sorted in descending order. Defaults to `True`. + +#### id: `str` + +The ID of the agent to retrieve. Defaults to `None`. + +#### name: `str` + +The name of the agent to retrieve. Defaults to `None`. + +### Returns + +- Success: A list of `Agent` objects. +- Failure: `Exception`. + +### 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 diff --git a/rag/nlp/query.py b/rag/nlp/query.py index 9a0ceafae73..3243d2a80e5 100644 --- a/rag/nlp/query.py +++ b/rag/nlp/query.py @@ -120,7 +120,7 @@ def need_fine_grained_tokenize(tk): keywords.append(tt) twts = self.tw.weights([tt]) syns = self.syn.lookup(tt) - if syns: keywords.extend(syns) + if syns and len(keywords) < 32: keywords.extend(syns) logging.debug(json.dumps(twts, ensure_ascii=False)) tms = [] for tk, w in sorted(twts, key=lambda x: x[1] * -1): @@ -140,17 +140,24 @@ def need_fine_grained_tokenize(tk): sm = [FulltextQueryer.subSpecialChar(m) for m in sm if len(m) > 1] sm = [m for m in sm if len(m) > 1] - keywords.append(re.sub(r"[ \\\"']+", "", tk)) - keywords.extend(sm) - if len(keywords) >= 12: - break + if len(keywords) < 32: + keywords.append(re.sub(r"[ \\\"']+", "", tk)) + keywords.extend(sm) tk_syns = self.syn.lookup(tk) + tk_syns = [FulltextQueryer.subSpecialChar(s) for s in tk_syns] + if len(keywords) < 32: keywords.extend([s for s in tk_syns if s]) + tk_syns = [rag_tokenizer.fine_grained_tokenize(s) for s in tk_syns if s] + tk_syns = [f"\"{s}\"" if s.find(" ")>0 else s for s in tk_syns] + + if len(keywords) >= 32: + break + tk = FulltextQueryer.subSpecialChar(tk) if tk.find(" ") > 0: tk = '"%s"' % tk if tk_syns: - tk = f"({tk} %s)" % " ".join(tk_syns) + tk = f"({tk} OR (%s)^0.2)" % " ".join(tk_syns) if sm: tk = f'{tk} OR "%s" OR ("%s"~2)^0.5' % (" ".join(sm), " ".join(sm)) if tk.strip(): @@ -159,14 +166,14 @@ def need_fine_grained_tokenize(tk): tms = " ".join([f"({t})^{w}" for t, w in tms]) if len(twts) > 1: - tms += ' ("%s"~4)^1.5' % (" ".join([t for t, _ in twts])) + tms += ' ("%s"~2)^1.5' % rag_tokenizer.tokenize(tt) if re.match(r"[0-9a-z ]+$", tt): tms = f'("{tt}" OR "%s")' % rag_tokenizer.tokenize(tt) syns = " OR ".join( [ - '"%s"^0.7' - % FulltextQueryer.subSpecialChar(rag_tokenizer.tokenize(s)) + '"%s"' + % rag_tokenizer.tokenize(FulltextQueryer.subSpecialChar(s)) for s in syns ] ) diff --git a/sdk/python/ragflow_sdk/modules/agent.py b/sdk/python/ragflow_sdk/modules/agent.py index a6b52e2c222..3818bef6e2a 100644 --- a/sdk/python/ragflow_sdk/modules/agent.py +++ b/sdk/python/ragflow_sdk/modules/agent.py @@ -1,6 +1,7 @@ from .base import Base from .session import Session import requests +from typing import List class Agent(Base): def __init__(self,rag,res_dict): @@ -57,3 +58,18 @@ def create_session(id,rag) -> Session: return Session(rag,res.get("data")) raise Exception(res.get("message")) + @staticmethod + def list_sessions(agent_id,rag,page: int = 1, page_size: int = 30, orderby: str = "create_time", desc: bool = True, + id: str = None) -> List[Session]: + url = f"{rag.api_url}/agents/{agent_id}/sessions" + headers = {"Authorization": f"Bearer {rag.user_key}"} + params = {"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id} + res = requests.get(url=url,headers=headers,params=params) + res = res.json() + if res.get("code") == 0: + result_list = [] + for data in res.get("data"): + temp_agent = Session(rag,data) + result_list.append(temp_agent) + return result_list + raise Exception(res.get("message")) diff --git a/sdk/python/ragflow_sdk/modules/session.py b/sdk/python/ragflow_sdk/modules/session.py index a619411b5e6..f5c2072ee5f 100644 --- a/sdk/python/ragflow_sdk/modules/session.py +++ b/sdk/python/ragflow_sdk/modules/session.py @@ -8,12 +8,12 @@ def __init__(self, rag, res_dict): self.id = None self.name = "New session" self.messages = [{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}] - self.chat_id = None - self.agent_id = None for key,value in res_dict.items(): if key =="chat_id" and value is not None: + self.chat_id = None self.__session_type = "chat" if key == "agent_id" and value is not None: + self.agent_id = None self.__session_type = "agent" super().__init__(rag, res_dict) diff --git a/sdk/python/ragflow_sdk/ragflow.py b/sdk/python/ragflow_sdk/ragflow.py index 1ee1fdc7fe7..472cec49384 100644 --- a/sdk/python/ragflow_sdk/ragflow.py +++ b/sdk/python/ragflow_sdk/ragflow.py @@ -18,6 +18,7 @@ from .modules.chat import Chat from .modules.chunk import Chunk from .modules.dataset import DataSet +from .modules.agent import Agent class RAGFlow: @@ -86,8 +87,10 @@ def list_datasets(self, page: int = 1, page_size: int = 30, orderby: str = "crea return result_list raise Exception(res["message"]) - def create_chat(self, name: str, avatar: str = "", dataset_ids: list[str] = [], - llm: Chat.LLM | None = None, prompt: Chat.Prompt | None = None) -> Chat: + def create_chat(self, name: str, avatar: str = "", dataset_ids=None, + llm: Chat.LLM | None = None, prompt: Chat.Prompt | None = None) -> Chat: + if dataset_ids is None: + dataset_ids = [] dataset_list = [] for id in dataset_ids: dataset_list.append(id) @@ -176,3 +179,15 @@ def retrieve(self, dataset_ids, document_ids=None, question="", page=1, page_siz chunks.append(chunk) return chunks raise Exception(res.get("message")) + + + def list_agents(self, page: int = 1, page_size: int = 30, orderby: str = "update_time", desc: bool = True, + id: str | None = None, title: str | None = None) -> list[Agent]: + res = self.get("/agents",{"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id, "title": title}) + res = res.json() + result_list = [] + if res.get("code") == 0: + for data in res['data']: + result_list.append(Agent(self, data)) + return result_list + raise Exception(res["message"]) diff --git a/sdk/python/test/test_sdk_api/t_agent.py b/sdk/python/test/test_sdk_api/t_agent.py new file mode 100644 index 00000000000..2c092e85a1c --- /dev/null +++ b/sdk/python/test/test_sdk_api/t_agent.py @@ -0,0 +1,9 @@ +from ragflow_sdk import RAGFlow,Agent +from common import HOST_ADDRESS +import pytest + +@pytest.mark.skip(reason="") +def test_list_agents_with_success(get_api_key_fixture): + API_KEY=get_api_key_fixture + rag = RAGFlow(API_KEY,HOST_ADDRESS) + rag.list_agents() \ No newline at end of file diff --git a/sdk/python/test/test_sdk_api/t_dataset.py b/sdk/python/test/test_sdk_api/t_dataset.py index e69cb44622b..183904bc9cc 100644 --- a/sdk/python/test/test_sdk_api/t_dataset.py +++ b/sdk/python/test/test_sdk_api/t_dataset.py @@ -51,4 +51,5 @@ def test_delete_datasets_with_success(get_api_key_fixture): def test_list_datasets_with_success(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) + rag.create_dataset("test_list_datasets") rag.list_datasets() diff --git a/sdk/python/test/test_sdk_api/t_session.py b/sdk/python/test/test_sdk_api/t_session.py index 2e46669cfbe..d5f6a9244a1 100644 --- a/sdk/python/test/test_sdk_api/t_session.py +++ b/sdk/python/test/test_sdk_api/t_session.py @@ -107,4 +107,11 @@ def test_create_agent_conversation_with_success(get_api_key_fixture): API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm" rag = RAGFlow(API_KEY,HOST_ADDRESS) session = Agent.create_session("2e45b5209c1011efa3e90242ac120006", rag) - session.ask("What is this job") \ No newline at end of file + session.ask("What is this job") + +@pytest.mark.skip(reason="") +def test_list_agent_sessions_with_success(get_api_key_fixture): + API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm" + agent_id = "2710f2269b4611ef8fdf0242ac120006" + rag = RAGFlow(API_KEY,HOST_ADDRESS) + Agent.list_sessions(agent_id,rag) diff --git a/web/src/components/knowledge-base-item.tsx b/web/src/components/knowledge-base-item.tsx index 331da8e68c9..57fcfef3af2 100644 --- a/web/src/components/knowledge-base-item.tsx +++ b/web/src/components/knowledge-base-item.tsx @@ -1,12 +1,12 @@ import { useTranslate } from '@/hooks/common-hooks'; -import { useNextFetchKnowledgeList } from '@/hooks/knowledge-hooks'; +import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks'; import { UserOutlined } from '@ant-design/icons'; import { Avatar, Form, Select, Space } from 'antd'; const KnowledgeBaseItem = () => { const { t } = useTranslate('chat'); - const { list: knowledgeList } = useNextFetchKnowledgeList(true); + const { list: knowledgeList } = useFetchKnowledgeList(true); const knowledgeOptions = knowledgeList.map((x) => ({ label: ( diff --git a/web/src/components/ui/skeleton.tsx b/web/src/components/ui/skeleton.tsx new file mode 100644 index 00000000000..c896c7e46cc --- /dev/null +++ b/web/src/components/ui/skeleton.tsx @@ -0,0 +1,39 @@ +import { cn } from '@/lib/utils'; + +function Skeleton({ + className, + ...props +}: React.HTMLAttributes) { + return ( +
+ ); +} + +function ParagraphSkeleton() { + return ( +
+ +
+ + +
+
+ ); +} + +function CardSkeleton() { + return ( +
+ +
+ + +
+
+ ); +} + +export { CardSkeleton, ParagraphSkeleton, Skeleton }; diff --git a/web/src/hooks/knowledge-hooks.ts b/web/src/hooks/knowledge-hooks.ts index 1e00e8c0c0f..6f972f5b946 100644 --- a/web/src/hooks/knowledge-hooks.ts +++ b/web/src/hooks/knowledge-hooks.ts @@ -41,7 +41,7 @@ export const useFetchKnowledgeBaseConfiguration = () => { return { data, loading }; }; -export const useNextFetchKnowledgeList = ( +export const useFetchKnowledgeList = ( shouldFilterListWithoutDocument: boolean = false, ): { list: IKnowledge[]; diff --git a/web/src/hooks/logic-hooks/navigate-hooks.ts b/web/src/hooks/logic-hooks/navigate-hooks.ts new file mode 100644 index 00000000000..3ad02f081f5 --- /dev/null +++ b/web/src/hooks/logic-hooks/navigate-hooks.ts @@ -0,0 +1,21 @@ +import { Routes } from '@/routes'; +import { useCallback } from 'react'; +import { useNavigate } from 'umi'; + +export const useNavigatePage = () => { + const navigate = useNavigate(); + + const navigateToDatasetList = useCallback(() => { + navigate(Routes.Datasets); + }, [navigate]); + + const navigateToDataset = useCallback(() => { + navigate(Routes.Dataset); + }, [navigate]); + + const navigateToHome = useCallback(() => { + navigate(Routes.Home); + }, [navigate]); + + return { navigateToDatasetList, navigateToDataset, navigateToHome }; +}; diff --git a/web/src/layouts/next-header.tsx b/web/src/layouts/next-header.tsx index d65cc1160b0..3692d794b23 100644 --- a/web/src/layouts/next-header.tsx +++ b/web/src/layouts/next-header.tsx @@ -3,32 +3,37 @@ import { Button } from '@/components/ui/button'; import { Container } from '@/components/ui/container'; import { Segmented, SegmentedValue } from '@/components/ui/segmented '; import { useTranslate } from '@/hooks/common-hooks'; +import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks'; import { useNavigateWithFromState } from '@/hooks/route-hook'; +import { cn } from '@/lib/utils'; +import { Routes } from '@/routes'; import { ChevronDown, Cpu, Github, + House, Library, MessageSquareText, Search, Star, Zap, } from 'lucide-react'; -import { useCallback, useMemo, useState } from 'react'; +import { useCallback, useMemo } from 'react'; import { useLocation } from 'umi'; export function Header() { const { t } = useTranslate('header'); const { pathname } = useLocation(); const navigate = useNavigateWithFromState(); - const [currentPath, setCurrentPath] = useState('/home'); + // const [currentPath, setCurrentPath] = useState(Routes.Home); + const { navigateToHome } = useNavigatePage(); const tagsData = useMemo( () => [ - { path: '/home', name: t('knowledgeBase'), icon: Library }, - { path: '/chat', name: t('chat'), icon: MessageSquareText }, - { path: '/search', name: t('search'), icon: Search }, - { path: '/flow', name: t('flow'), icon: Cpu }, + { path: Routes.Datasets, name: t('knowledgeBase'), icon: Library }, + { path: Routes.Chat, name: t('chat'), icon: MessageSquareText }, + { path: Routes.Search, name: t('search'), icon: Search }, + { path: Routes.Agent, name: t('flow'), icon: Cpu }, // { path: '/file', name: t('fileManager'), icon: FileIcon }, ], [t], @@ -50,17 +55,21 @@ export function Header() { }); }, [tagsData]); - // const currentPath = useMemo(() => { - // return tagsData.find((x) => pathname.startsWith(x.path))?.name || 'home'; - // }, [pathname, tagsData]); + const currentPath = useMemo(() => { + return ( + tagsData.find((x) => pathname.startsWith(x.path))?.path || Routes.Home + ); + }, [pathname, tagsData]); + + const isHome = Routes.Home === currentPath; const handleChange = (path: SegmentedValue) => { - // navigate(path as string); - setCurrentPath(path as string); + navigate(path as Routes); + // setCurrentPath(path as Routes); }; const handleLogoClick = useCallback(() => { - navigate('/'); + navigate(Routes.Home); }, [navigate]); return ( @@ -81,7 +90,22 @@ export function Header() {
-
+
+ +
- + V 0.13.0
; +} diff --git a/web/src/pages/file-manager/connect-to-knowledge-modal/index.tsx b/web/src/pages/file-manager/connect-to-knowledge-modal/index.tsx index c06274a3863..d32df3596ba 100644 --- a/web/src/pages/file-manager/connect-to-knowledge-modal/index.tsx +++ b/web/src/pages/file-manager/connect-to-knowledge-modal/index.tsx @@ -1,5 +1,5 @@ import { useTranslate } from '@/hooks/common-hooks'; -import { useNextFetchKnowledgeList } from '@/hooks/knowledge-hooks'; +import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks'; import { IModalProps } from '@/interfaces/common'; import { filterOptionsByInput } from '@/utils/common-util'; import { Form, Modal, Select } from 'antd'; @@ -13,7 +13,7 @@ const ConnectToKnowledgeModal = ({ loading, }: IModalProps & { initialValue: string[] }) => { const [form] = Form.useForm(); - const { list } = useNextFetchKnowledgeList(); + const { list } = useFetchKnowledgeList(); const { t } = useTranslate('fileManager'); const options = list?.map((item) => ({ diff --git a/web/src/pages/flow/canvas/node/retrieval-node.tsx b/web/src/pages/flow/canvas/node/retrieval-node.tsx index 7be5f3ea5fb..325b39a4e6b 100644 --- a/web/src/pages/flow/canvas/node/retrieval-node.tsx +++ b/web/src/pages/flow/canvas/node/retrieval-node.tsx @@ -1,5 +1,5 @@ import { useTheme } from '@/components/theme-provider'; -import { useNextFetchKnowledgeList } from '@/hooks/knowledge-hooks'; +import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks'; import { UserOutlined } from '@ant-design/icons'; import { Avatar, Flex } from 'antd'; import classNames from 'classnames'; @@ -19,7 +19,7 @@ export function RetrievalNode({ }: NodeProps) { const knowledgeBaseIds: string[] = get(data, 'form.kb_ids', []); const { theme } = useTheme(); - const { list: knowledgeList } = useNextFetchKnowledgeList(true); + const { list: knowledgeList } = useFetchKnowledgeList(true); const knowledgeBases = useMemo(() => { return knowledgeBaseIds.map((x) => { const item = knowledgeList.find((y) => x === y.id); diff --git a/web/src/pages/home/datasets.tsx b/web/src/pages/home/datasets.tsx index c23cbfa5cdd..4d63d0a2d37 100644 --- a/web/src/pages/home/datasets.tsx +++ b/web/src/pages/home/datasets.tsx @@ -1,82 +1,78 @@ +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Button } from '@/components/ui/button'; import { Card, CardContent } from '@/components/ui/card'; -import { ChevronRight, MoreHorizontal } from 'lucide-react'; - -const datasets = [ - { - id: 1, - title: 'Legal knowledge base', - files: '1,242 files', - size: '152 MB', - created: '12.02.2024', - image: 'https://github.com/shadcn.png', - }, - { - id: 2, - title: 'HR knowledge base', - files: '1,242 files', - size: '152 MB', - created: '12.02.2024', - image: 'https://github.com/shadcn.png', - }, - { - id: 3, - title: 'IT knowledge base', - files: '1,242 files', - size: '152 MB', - created: '12.02.2024', - image: 'https://github.com/shadcn.png', - }, - { - id: 4, - title: 'Legal knowledge base', - files: '1,242 files', - size: '152 MB', - created: '12.02.2024', - image: 'https://github.com/shadcn.png', - }, -]; +import { CardSkeleton } from '@/components/ui/skeleton'; +import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks'; +import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks'; +import { formatDate } from '@/utils/date'; +import { ChevronRight, Trash2 } from 'lucide-react'; export function Datasets() { + const { navigateToDatasetList, navigateToDataset } = useNavigatePage(); + const { list, loading } = useFetchKnowledgeList(); + return (

Datasets

- {datasets.map((dataset) => ( - - -
-
- -
-
-
-

- {dataset.title} -

-

- {dataset.files} | {dataset.size} -

-

- Created {dataset.created} -

-
- -
- - - ))} - +
+
+
+

+ {dataset.name} +

+
+ {dataset.doc_num} files +
+

+ Created {formatDate(dataset.update_time)} +

+
+ +
+
+
+ ))} +
+ )} +
diff --git a/web/src/pages/next-chat/index.tsx b/web/src/pages/next-chat/index.tsx new file mode 100644 index 00000000000..1342c631e89 --- /dev/null +++ b/web/src/pages/next-chat/index.tsx @@ -0,0 +1,3 @@ +export default function Chat() { + return
chat
; +} diff --git a/web/src/pages/next-search/index.tsx b/web/src/pages/next-search/index.tsx new file mode 100644 index 00000000000..0d4f3a3f364 --- /dev/null +++ b/web/src/pages/next-search/index.tsx @@ -0,0 +1,3 @@ +export default function Search() { + return
Search
; +} diff --git a/web/src/pages/search/index.tsx b/web/src/pages/search/index.tsx index cfbb2c11e26..b9d12f7add6 100644 --- a/web/src/pages/search/index.tsx +++ b/web/src/pages/search/index.tsx @@ -6,7 +6,7 @@ import { useClickDrawer } from '@/components/pdf-drawer/hooks'; import RetrievalDocuments from '@/components/retrieval-documents'; import SvgIcon from '@/components/svg-icon'; import { - useNextFetchKnowledgeList, + useFetchKnowledgeList, useSelectTestingResult, } from '@/hooks/knowledge-hooks'; import { useGetPaginationWithRouter } from '@/hooks/logic-hooks'; @@ -45,7 +45,7 @@ const SearchPage = () => { const { t } = useTranslation(); const [checkedList, setCheckedList] = useState([]); const { chunks, total } = useSelectTestingResult(); - const { list: knowledgeList } = useNextFetchKnowledgeList(); + const { list: knowledgeList } = useFetchKnowledgeList(); const checkedWithoutEmbeddingIdList = useMemo(() => { return checkedList.filter((x) => knowledgeList.some((y) => y.id === x)); }, [checkedList, knowledgeList]); diff --git a/web/src/pages/search/sidebar.tsx b/web/src/pages/search/sidebar.tsx index 4641460e4c1..052f48443fa 100644 --- a/web/src/pages/search/sidebar.tsx +++ b/web/src/pages/search/sidebar.tsx @@ -1,4 +1,4 @@ -import { useNextFetchKnowledgeList } from '@/hooks/knowledge-hooks'; +import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks'; import { UserOutlined } from '@ant-design/icons'; import type { TreeDataNode, TreeProps } from 'antd'; import { Avatar, Layout, Space, Spin, Tree, Typography } from 'antd'; @@ -27,7 +27,7 @@ const SearchSidebar = ({ checkedList, setCheckedList, }: IProps) => { - const { list, loading } = useNextFetchKnowledgeList(); + const { list, loading } = useFetchKnowledgeList(); const groupedList = useMemo(() => { return list.reduce((pre: TreeDataNode[], cur) => { diff --git a/web/src/routes.ts b/web/src/routes.ts index ed631d27198..85ede80e109 100644 --- a/web/src/routes.ts +++ b/web/src/routes.ts @@ -1,3 +1,14 @@ +export enum Routes { + Login = '/login', + Home = '/home', + Datasets = '/datasets', + DatasetBase = '/dataset', + Dataset = `${Routes.DatasetBase}${Routes.DatasetBase}`, + Agent = '/agent', + Search = '/next-search', + Chat = '/next-chat', +} + const routes = [ { path: '/login', @@ -131,48 +142,81 @@ const routes = [ layout: false, }, { - path: '/home', + path: Routes.Home, + layout: false, + component: '@/layouts/next', + routes: [ + { + path: Routes.Home, + component: `@/pages${Routes.Home}`, + }, + ], + }, + { + path: Routes.Datasets, + layout: false, + component: '@/layouts/next', + routes: [ + { + path: Routes.Datasets, + component: `@/pages${Routes.Datasets}`, + }, + ], + }, + { + path: Routes.Chat, + layout: false, + component: '@/layouts/next', + routes: [ + { + path: Routes.Chat, + component: `@/pages${Routes.Chat}`, + }, + ], + }, + { + path: Routes.Search, layout: false, component: '@/layouts/next', routes: [ { - path: '/home', - component: '@/pages/home', + path: Routes.Search, + component: `@/pages${Routes.Search}`, }, ], }, { - path: '/datasets', + path: Routes.Agent, layout: false, component: '@/layouts/next', routes: [ { - path: '/datasets', - component: '@/pages/datasets', + path: Routes.Agent, + component: `@/pages${Routes.Agent}`, }, ], }, { - path: '/dataset', + path: Routes.DatasetBase, layout: false, component: '@/layouts/next', routes: [ - { path: '/dataset', redirect: '/dataset/dataset' }, + { path: Routes.DatasetBase, redirect: Routes.Dataset }, { - path: '/dataset', - component: '@/pages/dataset', + path: Routes.DatasetBase, + component: `@/pages${Routes.DatasetBase}`, routes: [ { - path: '/dataset/dataset', - component: '@/pages/dataset/dataset', + path: Routes.Dataset, + component: `@/pages${Routes.Dataset}`, }, { - path: '/dataset/configuration', - component: '@/pages/dataset/settings', + path: `${Routes.DatasetBase}/configuration`, + component: `@/pages${Routes.DatasetBase}/settings`, }, { - path: '/dataset/testing', - component: '@/pages/dataset/testing', + path: `${Routes.DatasetBase}/testing`, + component: `@/pages${Routes.DatasetBase}/testing`, }, ], },