mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 05:02:57 +00:00
- 新增代码生成模块路由支持 - 重构 MCP 服务器API,支持增删改查接口和分页查询 - 实现 MCP 智能对话的流式响应和 WebSocket 通信 - 优化 MCP 数据模型,支持环境变量等配置项 - 改进 MCP CRUD 层,集成权限控制和统一操作方法 - 优化异常处理,提升接口错误信息准确性 - 修正依赖导入和数据校验,增强代码健壮性
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Optional, List
|
|
from fastapi import Query
|
|
from pydantic import Field
|
|
|
|
from app.core.base_schema import BaseSchema
|
|
from app.common.enums import McpLLMProvider
|
|
|
|
|
|
class McpQueryParam:
|
|
"""MCP 服务器查询参数"""
|
|
|
|
def __init__(
|
|
self,
|
|
name: Optional[str] = Query(None, description="MCP 名称"),
|
|
type: Optional[int] = Query(None, description="MCP 类型"),
|
|
) -> None:
|
|
super().__init__()
|
|
|
|
# 模糊查询字段
|
|
self.name = ("like", name) if name else None
|
|
|
|
# 精确查询字段
|
|
self.type = type
|
|
|
|
|
|
class McpChatParam(BaseSchema):
|
|
"""MCP 聊天参数"""
|
|
pk: List[int] = Field(..., description='MCP ID 列表')
|
|
provider: McpLLMProvider = Field(McpLLMProvider.openai, description='LLM 供应商')
|
|
model: str = Field(..., description='LLM 名称')
|
|
key: str = Field(..., description='LLM API Key')
|
|
base_url: Optional[str] = Field(None, description='自定义 LLM API 地址,必须兼容 openai 供应商')
|
|
prompt: str = Field(..., description='用户提示词') |