实现查看ragflow数据集列表接口
This commit is contained in:
parent
a273bdfce8
commit
724516d5bf
@ -168,7 +168,7 @@ class RAGFlowSettings:
|
||||
"""
|
||||
RAGFlowSettings
|
||||
"""
|
||||
RAGFLOW_BASE_URL="http://10.0.0.202:82",
|
||||
RAGFLOW_BASE_URL="http://10.0.0.202:82"
|
||||
RAGFLOW_API_KEY="ragflow-hlMjRmNzE2ODNiNTExZjA4ZTNlMDI0Mm"
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
from datetime import datetime
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from pydantic_validation_decorator import ValidateFields
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from config.enums import BusinessType
|
||||
from config.get_db import get_db
|
||||
from module_admin.annotation.log_annotation import Log
|
||||
# from module_admin.aspect.interface_auth import CheckUserInterfaceAuth
|
||||
# from module_admin.entity.vo.notice_vo import DeleteNoticeModel, NoticeModel, NoticePageQueryModel
|
||||
# from module_admin.entity.vo.user_vo import CurrentUserModel
|
||||
from module_admin.service.login_service import LoginService
|
||||
from module_admin.service.ragflow_service import RAGFlowService
|
||||
from utils.log_util import logger
|
||||
from utils.page_util import PageResponseModel
|
||||
from utils.response_util import ResponseUtil
|
||||
from module_admin.entity.vo.ragflow_vo import RagflowListQueryModel
|
||||
# from config.env import RAGFlowConfig
|
||||
|
||||
|
||||
|
||||
ragflowController = APIRouter(prefix="/system/ragflow", dependencies=[Depends(LoginService.get_current_user)])
|
||||
|
||||
|
||||
|
||||
@ragflowController.post("/dataset_list", response_model=PageResponseModel
|
||||
# , dependencies=[Depends(CheckUserInterfaceAuth("system:ragflow:list"))]"
|
||||
)
|
||||
async def get_system_ragflow_list(
|
||||
request: Request,
|
||||
rage_flow_query: RagflowListQueryModel ,
|
||||
query_db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
|
||||
result = await RAGFlowService.get_ragflow_list_services(query_db, rage_flow_query)
|
||||
|
||||
return ResponseUtil.success(data = result)
|
||||
|
||||
# 获取分页数据
|
||||
# ragflow_list, total = await RagflowService.get_ragflow_list(query_db, ragflow_page_query)
|
||||
16
ruoyi-fastapi-backend/module_admin/entity/vo/ragflow_vo.py
Normal file
16
ruoyi-fastapi-backend/module_admin/entity/vo/ragflow_vo.py
Normal file
@ -0,0 +1,16 @@
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from pydantic.alias_generators import to_camel
|
||||
from typing import Optional
|
||||
from module_admin.annotation.pydantic_annotation import as_query
|
||||
|
||||
|
||||
|
||||
class RagflowListQueryModel(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)
|
||||
page: int = Field(default=1, description='当前页码')
|
||||
page_size: int = Field(default=10, description='每页数量')
|
||||
orderby: Optional[str] = Field(default='create_time', description='排序字段')
|
||||
desc: Optional[str] = Field(default='true', description='排序方式')
|
||||
name: Optional[str] = Field(default=None, description='名称')
|
||||
dataset_id: Optional[str] = Field(default=None, description='数据集ID')
|
||||
@ -0,0 +1,22 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from utils.ragflow_asy_util import AsyncRAGFlowClient
|
||||
from module_admin.entity.vo.ragflow_vo import RagflowListQueryModel
|
||||
from config.env import RAGFlowConfig
|
||||
|
||||
class RAGFlowService:
|
||||
"""
|
||||
RAGFlow服务
|
||||
"""
|
||||
|
||||
# 获取数据集列表
|
||||
@classmethod
|
||||
async def get_ragflow_list_services(cls, query_db: AsyncSession, rage_flow_query: RagflowListQueryModel):
|
||||
"""
|
||||
获取数据集列表
|
||||
"""
|
||||
|
||||
async with AsyncRAGFlowClient(RAGFlowConfig.RAGFLOW_BASE_URL, RAGFlowConfig.RAGFLOW_API_KEY) as client:
|
||||
result = await client.list_datasets(**(rage_flow_query.model_dump()))
|
||||
|
||||
# 获取分页数据
|
||||
return result.get('data', None)
|
||||
@ -32,6 +32,7 @@ from module_admin.controller.explanation_content_controller import explanationCo
|
||||
from module_admin.controller.explanation_style_robot_pair_controller import explanation_style_robot_pairController
|
||||
from module_admin.controller.sys_statistics_controller import sys_statisticsController
|
||||
from module_admin.controller.identify_record_controller import identify_recordController
|
||||
from module_admin.controller.ragflow_controller import ragflowController
|
||||
|
||||
from sub_applications.handle import handle_sub_applications
|
||||
from utils.common_util import worship
|
||||
@ -98,6 +99,7 @@ controller_list = [
|
||||
{'router': explanation_style_robot_pairController, 'tags': ['讲解风格管理']},
|
||||
{'router': sys_statisticsController, 'tags': ['系统统计数据管理']},
|
||||
{'router': identify_recordController, 'tags': ['识别记录管理']},
|
||||
{'router': ragflowController, 'tags': ['ragflow管理']},
|
||||
|
||||
]
|
||||
|
||||
|
||||
@ -26,7 +26,10 @@ class AsyncRAGFlowClient:
|
||||
api_key: API密钥
|
||||
timeout: 请求超时时间(秒)
|
||||
"""
|
||||
self.base_url = base_url.rstrip('/')
|
||||
try:
|
||||
self.base_url = base_url.rstrip('/')
|
||||
except:
|
||||
self.base_url = base_url
|
||||
self.api_key = api_key
|
||||
self.timeout = timeout
|
||||
self.headers = {
|
||||
@ -231,7 +234,7 @@ class AsyncRAGFlowClient:
|
||||
return await self._request('PUT', endpoint, json=data)
|
||||
|
||||
async def list_datasets(self, page: int = 1, page_size: int = 30, orderby: str = "create_time",
|
||||
desc: bool = True, name: Optional[str] = None,
|
||||
desc: str = "true", name: Optional[str] = None,
|
||||
dataset_id: Optional[str] = None) -> Dict[str, Any]:
|
||||
"""
|
||||
列出数据集
|
||||
@ -335,7 +338,7 @@ class AsyncRAGFlowClient:
|
||||
raise RAGFlowError(response.status, text)
|
||||
|
||||
async def list_documents(self, dataset_id: str, page: int = 1, page_size: int = 30,
|
||||
orderby: str = "create_time", desc: bool = True,
|
||||
orderby: str = "create_time", desc: str = "true",
|
||||
keywords: Optional[str] = None, document_id: Optional[str] = None,
|
||||
document_name: Optional[str] = None) -> Dict[str, Any]:
|
||||
"""
|
||||
@ -534,7 +537,7 @@ class AsyncRAGFlowClient:
|
||||
return await self._request('DELETE', endpoint, json=data)
|
||||
|
||||
async def list_chat_assistants(self, page: int = 1, page_size: int = 30,
|
||||
orderby: str = "create_time", desc: bool = True,
|
||||
orderby: str = "create_time", desc: str = "true",
|
||||
name: Optional[str] = None,
|
||||
chat_id: Optional[str] = None) -> Dict[str, Any]:
|
||||
"""
|
||||
@ -588,7 +591,7 @@ class AsyncRAGFlowClient:
|
||||
return await self._request('PUT', endpoint, json=data)
|
||||
|
||||
async def list_chat_sessions(self, chat_id: str, page: int = 1, page_size: int = 30,
|
||||
orderby: str = "create_time", desc: bool = True,
|
||||
orderby: str = "create_time", desc: str = "true",
|
||||
name: Optional[str] = None, session_id: Optional[str] = None,
|
||||
user_id: Optional[str] = None) -> Dict[str, Any]:
|
||||
"""
|
||||
@ -707,7 +710,7 @@ class AsyncRAGFlowClient:
|
||||
return await self._request('POST', endpoint, json=data)
|
||||
|
||||
async def list_agent_sessions(self, agent_id: str, page: int = 1, page_size: int = 30,
|
||||
orderby: str = "create_time", desc: bool = True,
|
||||
orderby: str = "create_time", desc: str = "true",
|
||||
session_id: Optional[str] = None, user_id: Optional[str] = None,
|
||||
dsl: bool = True) -> Dict[str, Any]:
|
||||
"""
|
||||
@ -751,7 +754,7 @@ class AsyncRAGFlowClient:
|
||||
return await self._request('POST', endpoint, headers=headers, json=data)
|
||||
|
||||
async def list_agents(self, page: int = 1, page_size: int = 30, orderby: str = "create_time",
|
||||
desc: bool = True, name: Optional[str] = None,
|
||||
desc: str = "true", name: Optional[str] = None,
|
||||
agent_id: Optional[str] = None) -> Dict[str, Any]:
|
||||
"""
|
||||
列出代理
|
||||
|
||||
Loading…
Reference in New Issue
Block a user