mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-13 04:18:59 +08:00
Turn resource to plural form (#3061)
### What problem does this PR solve? Turn resource to plural form ### Type of change - [x] Refactoring Co-authored-by: liuhua <10215101452@stu.ecun.edu.cn>
This commit is contained in:
parent
396feadd4b
commit
07bb2a6fd6
@ -22,7 +22,7 @@ from api.settings import retrievaler, kg_retrievaler, RetCode
|
|||||||
from api.utils.api_utils import validate_request, build_error_result, apikey_required
|
from api.utils.api_utils import validate_request, build_error_result, apikey_required
|
||||||
|
|
||||||
|
|
||||||
@manager.route('/dify/retrievals', methods=['POST'])
|
@manager.route('/dify/retrieval', methods=['POST'])
|
||||||
@apikey_required
|
@apikey_required
|
||||||
@validate_request("knowledge_id", "query")
|
@validate_request("knowledge_id", "query")
|
||||||
def retrieval(tenant_id):
|
def retrieval(tenant_id):
|
||||||
|
@ -574,7 +574,7 @@ def update_chunk(tenant_id,dataset_id,document_id,chunk_id):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@manager.route('/retrievals', methods=['POST'])
|
@manager.route('/retrieval', methods=['POST'])
|
||||||
@token_required
|
@token_required
|
||||||
def retrieval_test(tenant_id):
|
def retrieval_test(tenant_id):
|
||||||
req = request.json
|
req = request.json
|
||||||
|
@ -1169,14 +1169,14 @@ Failure:
|
|||||||
|
|
||||||
## Retrieve chunks
|
## Retrieve chunks
|
||||||
|
|
||||||
**GET** `/api/v1/retrievals`
|
**GET** `/api/v1/retrieval`
|
||||||
|
|
||||||
Retrieves chunks from specified datasets.
|
Retrieves chunks from specified datasets.
|
||||||
|
|
||||||
### Request
|
### Request
|
||||||
|
|
||||||
- Method: POST
|
- Method: POST
|
||||||
- URL: `/api/v1/retrievals`
|
- URL: `/api/v1/retrieval`
|
||||||
- Headers:
|
- Headers:
|
||||||
- `'content-Type: application/json'`
|
- `'content-Type: application/json'`
|
||||||
- `'Authorization: Bearer {YOUR_API_KEY}'`
|
- `'Authorization: Bearer {YOUR_API_KEY}'`
|
||||||
@ -1197,7 +1197,7 @@ Retrieves chunks from specified datasets.
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl --request POST \
|
curl --request POST \
|
||||||
--url http://{address}/api/v1/retrievals \
|
--url http://{address}/api/v1/retrieval \
|
||||||
--header 'Content-Type: application/json' \
|
--header 'Content-Type: application/json' \
|
||||||
--header 'Authorization: {YOUR_API_KEY}' \
|
--header 'Authorization: {YOUR_API_KEY}' \
|
||||||
--data '
|
--data '
|
||||||
|
@ -43,7 +43,7 @@ class Chat(Base):
|
|||||||
super().__init__(rag, res_dict)
|
super().__init__(rag, res_dict)
|
||||||
|
|
||||||
def update(self, update_message: dict):
|
def update(self, update_message: dict):
|
||||||
res = self.put(f'/chat/{self.id}',
|
res = self.put(f'/chats/{self.id}',
|
||||||
update_message)
|
update_message)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") != 0:
|
if res.get("code") != 0:
|
||||||
@ -51,7 +51,7 @@ class Chat(Base):
|
|||||||
|
|
||||||
|
|
||||||
def create_session(self, name: str = "New session") -> Session:
|
def create_session(self, name: str = "New session") -> Session:
|
||||||
res = self.post(f"/chat/{self.id}/session", {"name": name})
|
res = self.post(f"/chats/{self.id}/sessions", {"name": name})
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") == 0:
|
if res.get("code") == 0:
|
||||||
return Session(self.rag, res['data'])
|
return Session(self.rag, res['data'])
|
||||||
@ -59,7 +59,7 @@ class Chat(Base):
|
|||||||
|
|
||||||
def list_sessions(self,page: int = 1, page_size: int = 1024, orderby: str = "create_time", desc: bool = True,
|
def list_sessions(self,page: int = 1, page_size: int = 1024, orderby: str = "create_time", desc: bool = True,
|
||||||
id: str = None, name: str = None) -> List[Session]:
|
id: str = None, name: str = None) -> List[Session]:
|
||||||
res = self.get(f'/chat/{self.id}/session',{"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id, "name": name} )
|
res = self.get(f'/chats/{self.id}/sessions',{"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id, "name": name} )
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") == 0:
|
if res.get("code") == 0:
|
||||||
result_list = []
|
result_list = []
|
||||||
@ -69,7 +69,7 @@ class Chat(Base):
|
|||||||
raise Exception(res["message"])
|
raise Exception(res["message"])
|
||||||
|
|
||||||
def delete_sessions(self,ids):
|
def delete_sessions(self,ids):
|
||||||
res = self.rm(f"/chat/{self.id}/session", {"ids": ids})
|
res = self.rm(f"/chats/{self.id}/sessions", {"ids": ids})
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") != 0:
|
if res.get("code") != 0:
|
||||||
raise Exception(res.get("message"))
|
raise Exception(res.get("message"))
|
||||||
|
@ -19,7 +19,7 @@ class Chunk(Base):
|
|||||||
|
|
||||||
|
|
||||||
def update(self,update_message:dict):
|
def update(self,update_message:dict):
|
||||||
res = self.put(f"/dataset/{self.dataset_id}/document/{self.document_id}/chunk/{self.id}",update_message)
|
res = self.put(f"/datasets/{self.dataset_id}/documents/{self.document_id}/chunks/{self.id}",update_message)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") != 0 :
|
if res.get("code") != 0 :
|
||||||
raise Exception(res["message"])
|
raise Exception(res["message"])
|
||||||
|
@ -31,14 +31,14 @@ class DataSet(Base):
|
|||||||
super().__init__(rag, res_dict)
|
super().__init__(rag, res_dict)
|
||||||
|
|
||||||
def update(self, update_message: dict):
|
def update(self, update_message: dict):
|
||||||
res = self.put(f'/dataset/{self.id}',
|
res = self.put(f'/datasets/{self.id}',
|
||||||
update_message)
|
update_message)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") != 0:
|
if res.get("code") != 0:
|
||||||
raise Exception(res["message"])
|
raise Exception(res["message"])
|
||||||
|
|
||||||
def upload_documents(self,document_list: List[dict]):
|
def upload_documents(self,document_list: List[dict]):
|
||||||
url = f"/dataset/{self.id}/document"
|
url = f"/datasets/{self.id}/documents"
|
||||||
files = [("file",(ele["displayed_name"],ele["blob"])) for ele in document_list]
|
files = [("file",(ele["displayed_name"],ele["blob"])) for ele in document_list]
|
||||||
res = self.post(path=url,json=None,files=files)
|
res = self.post(path=url,json=None,files=files)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
@ -51,7 +51,7 @@ class DataSet(Base):
|
|||||||
raise Exception(res.get("message"))
|
raise Exception(res.get("message"))
|
||||||
|
|
||||||
def list_documents(self, id: str = None, keywords: str = None, offset: int =1, limit: int = 1024, orderby: str = "create_time", desc: bool = True):
|
def list_documents(self, id: str = None, keywords: str = None, offset: int =1, limit: int = 1024, orderby: str = "create_time", desc: bool = True):
|
||||||
res = self.get(f"/dataset/{self.id}/info",params={"id": id,"keywords": keywords,"offset": offset,"limit": limit,"orderby": orderby,"desc": desc})
|
res = self.get(f"/datasets/{self.id}/documents",params={"id": id,"keywords": keywords,"offset": offset,"limit": limit,"orderby": orderby,"desc": desc})
|
||||||
res = res.json()
|
res = res.json()
|
||||||
documents = []
|
documents = []
|
||||||
if res.get("code") == 0:
|
if res.get("code") == 0:
|
||||||
@ -61,19 +61,19 @@ class DataSet(Base):
|
|||||||
raise Exception(res["message"])
|
raise Exception(res["message"])
|
||||||
|
|
||||||
def delete_documents(self,ids: List[str] = None):
|
def delete_documents(self,ids: List[str] = None):
|
||||||
res = self.rm(f"/dataset/{self.id}/document",{"ids":ids})
|
res = self.rm(f"/datasets/{self.id}/documents",{"ids":ids})
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") != 0:
|
if res.get("code") != 0:
|
||||||
raise Exception(res["message"])
|
raise Exception(res["message"])
|
||||||
|
|
||||||
def async_parse_documents(self,document_ids):
|
def async_parse_documents(self,document_ids):
|
||||||
res = self.post(f"/dataset/{self.id}/chunk",{"document_ids":document_ids})
|
res = self.post(f"/datasets/{self.id}/chunks",{"document_ids":document_ids})
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") != 0:
|
if res.get("code") != 0:
|
||||||
raise Exception(res.get("message"))
|
raise Exception(res.get("message"))
|
||||||
|
|
||||||
def async_cancel_parse_documents(self,document_ids):
|
def async_cancel_parse_documents(self,document_ids):
|
||||||
res = self.rm(f"/dataset/{self.id}/chunk",{"document_ids":document_ids})
|
res = self.rm(f"/datasets/{self.id}/chunks",{"document_ids":document_ids})
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") != 0:
|
if res.get("code") != 0:
|
||||||
raise Exception(res.get("message"))
|
raise Exception(res.get("message"))
|
||||||
|
@ -35,14 +35,14 @@ class Document(Base):
|
|||||||
|
|
||||||
|
|
||||||
def update(self, update_message: dict):
|
def update(self, update_message: dict):
|
||||||
res = self.put(f'/dataset/{self.dataset_id}/info/{self.id}',
|
res = self.put(f'/datasets/{self.dataset_id}/documents/{self.id}',
|
||||||
update_message)
|
update_message)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") != 0:
|
if res.get("code") != 0:
|
||||||
raise Exception(res["message"])
|
raise Exception(res["message"])
|
||||||
|
|
||||||
def download(self):
|
def download(self):
|
||||||
res = self.get(f"/dataset/{self.dataset_id}/document/{self.id}")
|
res = self.get(f"/datasets/{self.dataset_id}/documents/{self.id}")
|
||||||
try:
|
try:
|
||||||
res = res.json()
|
res = res.json()
|
||||||
raise Exception(res.get("message"))
|
raise Exception(res.get("message"))
|
||||||
@ -52,7 +52,7 @@ class Document(Base):
|
|||||||
|
|
||||||
def list_chunks(self,offset=0, limit=30, keywords="", id:str=None):
|
def list_chunks(self,offset=0, limit=30, keywords="", id:str=None):
|
||||||
data={"document_id": self.id,"keywords": keywords,"offset":offset,"limit":limit,"id":id}
|
data={"document_id": self.id,"keywords": keywords,"offset":offset,"limit":limit,"id":id}
|
||||||
res = self.get(f'/dataset/{self.dataset_id}/document/{self.id}/chunk', data)
|
res = self.get(f'/datasets/{self.dataset_id}/documents/{self.id}/chunks', data)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") == 0:
|
if res.get("code") == 0:
|
||||||
chunks=[]
|
chunks=[]
|
||||||
@ -64,14 +64,14 @@ class Document(Base):
|
|||||||
|
|
||||||
|
|
||||||
def add_chunk(self, content: str,important_keywords:List[str]=[]):
|
def add_chunk(self, content: str,important_keywords:List[str]=[]):
|
||||||
res = self.post(f'/dataset/{self.dataset_id}/document/{self.id}/chunk', {"content":content,"important_keywords":important_keywords})
|
res = self.post(f'/datasets/{self.dataset_id}/documents/{self.id}/chunks', {"content":content,"important_keywords":important_keywords})
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") == 0:
|
if res.get("code") == 0:
|
||||||
return Chunk(self.rag,res["data"].get("chunk"))
|
return Chunk(self.rag,res["data"].get("chunk"))
|
||||||
raise Exception(res.get("message"))
|
raise Exception(res.get("message"))
|
||||||
|
|
||||||
def delete_chunks(self,ids:List[str] = None):
|
def delete_chunks(self,ids:List[str] = None):
|
||||||
res = self.rm(f"dataset/{self.dataset_id}/document/{self.id}/chunk",{"ids":ids})
|
res = self.rm(f"datasets/{self.dataset_id}/documents/{self.id}/chunks",{"ids":ids})
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code")!=0:
|
if res.get("code")!=0:
|
||||||
raise Exception(res.get("message"))
|
raise Exception(res.get("message"))
|
@ -15,7 +15,7 @@ class Session(Base):
|
|||||||
for message in self.messages:
|
for message in self.messages:
|
||||||
if "reference" in message:
|
if "reference" in message:
|
||||||
message.pop("reference")
|
message.pop("reference")
|
||||||
res = self.post(f"/chat/{self.chat_id}/completion",
|
res = self.post(f"/chats/{self.chat_id}/completions",
|
||||||
{"question": question, "stream": True,"session_id":self.id}, stream=stream)
|
{"question": question, "stream": True,"session_id":self.id}, stream=stream)
|
||||||
for line in res.iter_lines():
|
for line in res.iter_lines():
|
||||||
line = line.decode("utf-8")
|
line = line.decode("utf-8")
|
||||||
@ -53,7 +53,7 @@ class Session(Base):
|
|||||||
yield message
|
yield message
|
||||||
|
|
||||||
def update(self,update_message):
|
def update(self,update_message):
|
||||||
res = self.put(f"/chat/{self.chat_id}/session/{self.id}",
|
res = self.put(f"/chats/{self.chat_id}/sessions/{self.id}",
|
||||||
update_message)
|
update_message)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") != 0:
|
if res.get("code") != 0:
|
||||||
|
@ -53,7 +53,7 @@ class RAGFlow:
|
|||||||
parser_config: DataSet.ParserConfig = None) -> DataSet:
|
parser_config: DataSet.ParserConfig = None) -> DataSet:
|
||||||
if parser_config:
|
if parser_config:
|
||||||
parser_config = parser_config.to_json()
|
parser_config = parser_config.to_json()
|
||||||
res = self.post("/dataset",
|
res = self.post("/datasets",
|
||||||
{"name": name, "avatar": avatar, "description": description, "language": language,
|
{"name": name, "avatar": avatar, "description": description, "language": language,
|
||||||
"permission": permission, "chunk_method": chunk_method,
|
"permission": permission, "chunk_method": chunk_method,
|
||||||
"parser_config": parser_config
|
"parser_config": parser_config
|
||||||
@ -65,7 +65,7 @@ class RAGFlow:
|
|||||||
raise Exception(res["message"])
|
raise Exception(res["message"])
|
||||||
|
|
||||||
def delete_datasets(self, ids: List[str]):
|
def delete_datasets(self, ids: List[str]):
|
||||||
res = self.delete("/dataset",{"ids": ids})
|
res = self.delete("/datasets",{"ids": ids})
|
||||||
res=res.json()
|
res=res.json()
|
||||||
if res.get("code") != 0:
|
if res.get("code") != 0:
|
||||||
raise Exception(res["message"])
|
raise Exception(res["message"])
|
||||||
@ -79,7 +79,7 @@ class RAGFlow:
|
|||||||
def list_datasets(self, page: int = 1, page_size: int = 1024, orderby: str = "create_time", desc: bool = True,
|
def list_datasets(self, page: int = 1, page_size: int = 1024, orderby: str = "create_time", desc: bool = True,
|
||||||
id: str = None, name: str = None) -> \
|
id: str = None, name: str = None) -> \
|
||||||
List[DataSet]:
|
List[DataSet]:
|
||||||
res = self.get("/dataset",
|
res = self.get("/datasets",
|
||||||
{"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id, "name": name})
|
{"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id, "name": name})
|
||||||
res = res.json()
|
res = res.json()
|
||||||
result_list = []
|
result_list = []
|
||||||
@ -129,14 +129,14 @@ class RAGFlow:
|
|||||||
"dataset_ids": dataset_list,
|
"dataset_ids": dataset_list,
|
||||||
"llm": llm.to_json(),
|
"llm": llm.to_json(),
|
||||||
"prompt": prompt.to_json()}
|
"prompt": prompt.to_json()}
|
||||||
res = self.post("/chat", temp_dict)
|
res = self.post("/chats", temp_dict)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") == 0:
|
if res.get("code") == 0:
|
||||||
return Chat(self, res["data"])
|
return Chat(self, res["data"])
|
||||||
raise Exception(res["message"])
|
raise Exception(res["message"])
|
||||||
|
|
||||||
def delete_chats(self,ids: List[str] = None,names: List[str] = None ) -> bool:
|
def delete_chats(self,ids: List[str] = None,names: List[str] = None ) -> bool:
|
||||||
res = self.delete('/chat',
|
res = self.delete('/chats',
|
||||||
{"ids":ids, "names":names})
|
{"ids":ids, "names":names})
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res.get("code") != 0:
|
if res.get("code") != 0:
|
||||||
@ -144,7 +144,7 @@ class RAGFlow:
|
|||||||
|
|
||||||
def list_chats(self, page: int = 1, page_size: int = 1024, orderby: str = "create_time", desc: bool = True,
|
def list_chats(self, page: int = 1, page_size: int = 1024, orderby: str = "create_time", desc: bool = True,
|
||||||
id: str = None, name: str = None) -> List[Chat]:
|
id: str = None, name: str = None) -> List[Chat]:
|
||||||
res = self.get("/chat",{"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id, "name": name})
|
res = self.get("/chats",{"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id, "name": name})
|
||||||
res = res.json()
|
res = res.json()
|
||||||
result_list = []
|
result_list = []
|
||||||
if res.get("code") == 0:
|
if res.get("code") == 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user