refactor: 优化代码格式
This commit is contained in:
parent
3c75b0acb3
commit
1033b63450
12
Makefile
12
Makefile
@ -24,14 +24,14 @@ logs:
|
||||
######################
|
||||
|
||||
lint:
|
||||
uv run python -m ruff check backend/package
|
||||
uv run python -m ruff format --check backend/package
|
||||
uv run python -m ruff check --select I backend/package
|
||||
cd backend && uv run ruff check package
|
||||
cd backend && uv run ruff format --check package
|
||||
cd backend && uv run ruff check --select I package
|
||||
|
||||
format:
|
||||
uv run python -m ruff format backend/package
|
||||
uv run python -m ruff check backend/package --fix
|
||||
uv run python -m ruff check --select I backend/package --fix
|
||||
cd backend && uv run ruff format package
|
||||
cd backend && uv run ruff check package --fix
|
||||
cd backend && uv run ruff check --select I package --fix
|
||||
docker compose exec -T web pnpm run format
|
||||
|
||||
router-tests:
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
"""SubAgent 服务层"""
|
||||
|
||||
import asyncio
|
||||
from copy import deepcopy
|
||||
from contextlib import asynccontextmanager
|
||||
from copy import deepcopy
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from yuxi.repositories.subagent_repository import SubAgentRepository
|
||||
from yuxi.services.mcp_service import get_tools_from_all_servers
|
||||
from yuxi.storage.postgres.manager import pg_manager
|
||||
@ -25,6 +24,7 @@ async def _get_session(db: AsyncSession | None = None):
|
||||
async with pg_manager.get_async_session_context() as session:
|
||||
yield session
|
||||
|
||||
|
||||
# 内置 SubAgent 配置
|
||||
_DEFAULT_SUBAGENTS = [
|
||||
{
|
||||
@ -130,6 +130,7 @@ async def _get_available_tools() -> list[Any]:
|
||||
tools.extend(mcp_tools)
|
||||
return tools
|
||||
|
||||
|
||||
async def get_all_subagents(db: AsyncSession | None = None) -> list[dict[str, Any]]:
|
||||
"""获取所有 SubAgent(含禁用的)"""
|
||||
async with _get_session(db) as session:
|
||||
|
||||
@ -16,7 +16,7 @@ const BASE_URL = '/api/system/subagents'
|
||||
* @returns {Promise} - SubAgent 列表
|
||||
*/
|
||||
export const getSubAgents = async () => {
|
||||
return apiAdminGet(BASE_URL)
|
||||
return apiAdminGet(BASE_URL)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -25,7 +25,7 @@ export const getSubAgents = async () => {
|
||||
* @returns {Promise} - SubAgent 配置
|
||||
*/
|
||||
export const getSubAgent = async (name) => {
|
||||
return apiAdminGet(`${BASE_URL}/${encodeURIComponent(name)}`)
|
||||
return apiAdminGet(`${BASE_URL}/${encodeURIComponent(name)}`)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,7 +34,7 @@ export const getSubAgent = async (name) => {
|
||||
* @returns {Promise} - 创建结果
|
||||
*/
|
||||
export const createSubAgent = async (data) => {
|
||||
return apiAdminPost(BASE_URL, data)
|
||||
return apiAdminPost(BASE_URL, data)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,7 +44,7 @@ export const createSubAgent = async (data) => {
|
||||
* @returns {Promise} - 更新结果
|
||||
*/
|
||||
export const updateSubAgent = async (name, data) => {
|
||||
return apiAdminPut(`${BASE_URL}/${encodeURIComponent(name)}`, data)
|
||||
return apiAdminPut(`${BASE_URL}/${encodeURIComponent(name)}`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ export const updateSubAgent = async (name, data) => {
|
||||
* @returns {Promise} - 删除结果
|
||||
*/
|
||||
export const deleteSubAgent = async (name) => {
|
||||
return apiAdminDelete(`${BASE_URL}/${encodeURIComponent(name)}`)
|
||||
return apiAdminDelete(`${BASE_URL}/${encodeURIComponent(name)}`)
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
@ -61,11 +61,11 @@ export const deleteSubAgent = async (name) => {
|
||||
// =============================================================================
|
||||
|
||||
export const subagentApi = {
|
||||
getSubAgents,
|
||||
getSubAgent,
|
||||
createSubAgent,
|
||||
updateSubAgent,
|
||||
deleteSubAgent,
|
||||
getSubAgents,
|
||||
getSubAgent,
|
||||
createSubAgent,
|
||||
updateSubAgent,
|
||||
deleteSubAgent
|
||||
}
|
||||
|
||||
export default subagentApi
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,11 @@
|
||||
<Plus :size="14" />
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
<a-button @click="handleSubagentRefresh" :disabled="subagentsLoading" class="lucide-icon-btn">
|
||||
<a-button
|
||||
@click="handleSubagentRefresh"
|
||||
:disabled="subagentsLoading"
|
||||
class="lucide-icon-btn"
|
||||
>
|
||||
<RotateCw :size="14" />
|
||||
<span>刷新</span>
|
||||
</a-button>
|
||||
@ -73,7 +77,11 @@
|
||||
<McpServersComponent ref="mcpRef" @add="handleMcpAdd" @refresh="handleMcpRefresh" />
|
||||
</div>
|
||||
<div v-show="activeTab === 'subagents'" class="tab-panel">
|
||||
<SubAgentsComponent ref="subagentsRef" @add="handleSubagentAdd" @refresh="handleSubagentRefresh" />
|
||||
<SubAgentsComponent
|
||||
ref="subagentsRef"
|
||||
@add="handleSubagentAdd"
|
||||
@refresh="handleSubagentRefresh"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user