Agent 放在了 tools 里面

This commit is contained in:
Wenjie Zhang 2025-03-28 00:48:33 +08:00
parent 623e2e69da
commit 06c3352eaa
8 changed files with 67 additions and 31 deletions

View File

@ -13,7 +13,7 @@ class Tool(BaseModel):
title: str title: str
description: str description: str
url: str url: str
method: str method: Optional[str] = "POST"
params: Optional[Dict[str, Any]] = None params: Optional[Dict[str, Any]] = None
@tool.get("/", response_model=List[Tool]) @tool.get("/", response_model=List[Tool])
@ -32,6 +32,12 @@ async def route_index():
description="将PDF文件转换为文本文件。", description="将PDF文件转换为文本文件。",
url="/tools/pdf2txt", url="/tools/pdf2txt",
method="POST", method="POST",
),
Tool(
name="agent",
title="智能体Dev",
description="智能体演练平台",
url="/tools/agent",
) )
] ]
@ -48,3 +54,4 @@ async def handle_pdf2txt(file: str = Body(...)):
from src.plugins import ocr from src.plugins import ocr
text = ocr.process_pdf(file) text = ocr.process_pdf(file)
return {"text": text} return {"text": text}

View File

@ -15,4 +15,29 @@
h2 { h2 {
margin: 20px 0 10px 0; margin: 20px 0 10px 0;
} }
}
.iconfont {
max-width: 100%;
max-height: 100%;
&.icon-10 {
width: 10px;
height: 10px;
}
&.icon-16 {
width: 16px;
height: 16px;
}
&.icon-20 {
width: 20px;
height: 20px;
}
&.icon-24 {
width: 24px;
height: 24px;
}
} }

View File

@ -7,8 +7,8 @@
class="close nav-btn" class="close nav-btn"
@click="state.isSidebarOpen = true" @click="state.isSidebarOpen = true"
> >
<MenuOutlined /> <img src="@/assets/icons/sidebar_left.svg" class="iconfont icon-24" alt="设置" />
</div> </div>
<a-tooltip :title="configStore.config?.model_name" placement="rightTop"> <a-tooltip :title="configStore.config?.model_name" placement="rightTop">
<div class="newchat nav-btn" @click="$emit('newconv')"> <div class="newchat nav-btn" @click="$emit('newconv')">
<PlusCircleOutlined /> <span class="text">新对话</span> <PlusCircleOutlined /> <span class="text">新对话</span>

View File

@ -82,11 +82,6 @@ const mainList = [{
path: '/chat', path: '/chat',
icon: MessageOutlined, icon: MessageOutlined,
activeIcon: MessageFilled, activeIcon: MessageFilled,
}, {
name: '智能体',
path: '/agent',
icon: RobotOutlined,
activeIcon: RobotFilled,
}, { }, {
name: '图谱', name: '图谱',
path: '/graph', path: '/graph',

View File

@ -30,19 +30,19 @@ const router = createRouter({
} }
] ]
}, },
{ // {
path: '/agent', // path: '/agent',
name: 'agent', // name: 'agent',
component: AppLayout, // component: AppLayout,
children: [ // children: [
{ // {
path: '', // path: '',
name: 'AgentComp', // name: 'AgentComp',
component: () => import('../views/AgentView.vue'), // component: () => import('../views/AgentView.vue'),
meta: { keepAlive: true } // meta: { keepAlive: true }
} // }
] // ]
}, // },
{ {
path: '/graph', path: '/graph',
name: 'graph', name: 'graph',
@ -109,6 +109,12 @@ const router = createRouter({
name: 'PDF_to_TXT', name: 'PDF_to_TXT',
component: () => import('../components/tools/ConvertToTxtComponent.vue'), component: () => import('../components/tools/ConvertToTxtComponent.vue'),
}, },
{
path: 'agent',
name: 'Agent',
component: () => import('../views/AgentView.vue'),
meta: { keepAlive: true }
}
] ]
}, },
{ {

View File

@ -48,7 +48,7 @@
<div v-if="toolCall" class="tool-call-display" :class="{ 'is-collapsed': !expandedToolCalls.has(toolCall.id) }"> <div v-if="toolCall" class="tool-call-display" :class="{ 'is-collapsed': !expandedToolCalls.has(toolCall.id) }">
<div class="tool-header" @click="toggleToolCall(toolCall.id)"> <div class="tool-header" @click="toggleToolCall(toolCall.id)">
<span v-if="!toolCall.toolResultMsg"> <span v-if="!toolCall.toolResultMsg">
<ThunderboltOutlined /> <ThunderboltOutlined /> &nbsp;
<span>正在调用工具: </span> <span>正在调用工具: </span>
<span class="tool-name">{{ toolCall.function.name }}</span> <span class="tool-name">{{ toolCall.function.name }}</span>
</span> </span>

View File

@ -4,7 +4,9 @@
<div class="actions"> <div class="actions">
<!-- <div class="action new" @click="addNewConv"><FormOutlined /></div> --> <!-- <div class="action new" @click="addNewConv"><FormOutlined /></div> -->
<span class="header-title">对话历史</span> <span class="header-title">对话历史</span>
<div class="action close" @click="state.isSidebarOpen = false"><MenuOutlined /></div> <div class="action close" @click="state.isSidebarOpen = false">
<img src="@/assets/icons/sidebar_left.svg" class="iconfont icon-24" alt="设置" />
</div>
</div> </div>
<div class="conversation-list"> <div class="conversation-list">
<div class="conversation" <div class="conversation"
@ -178,6 +180,11 @@ onMounted(() => {
&:hover { &:hover {
background-color: var(--main-light-3); background-color: var(--main-light-3);
} }
.nav-btn-icon {
width: 1.2rem;
height: 1.2rem;
}
} }
} }

View File

@ -5,13 +5,9 @@
description="这里展示了各种可用的工具,重点是为了测试部分功能的页面。(注:不是大模型的工具)" description="这里展示了各种可用的工具,重点是为了测试部分功能的页面。(注:不是大模型的工具)"
> >
</HeaderComponent> </HeaderComponent>
<div class="tools-grid"> <div class="tools-grid">
<div v-for="tool in tools" :key="tool.id" class="tool-card" @click="navigateToTool(tool.name)"> <div v-for="tool in tools" :key="tool.id" class="tool-card" @click="navigateToTool(tool.name)">
<div class="tool-header"> <div class="tool-header">
<!-- <div class="tool-icon">
<component :is="iconMap[tool.name]" />
</div> -->
<h3>{{ tool.title }}</h3> <h3>{{ tool.title }}</h3>
</div> </div>
<div class="tool-info"> <div class="tool-info">
@ -79,19 +75,19 @@ onMounted(() => {
border: 1px solid var(--gray-300); border: 1px solid var(--gray-300);
border-radius: 8px; border-radius: 8px;
padding: 20px; padding: 20px;
transition: transform 0.3s ease, box-shadow 0.3s ease; transition: transform 0.1s ease, box-shadow 0.1s ease;
cursor: pointer; cursor: pointer;
&:hover { &:hover {
transform: translateY(-1px); // transform: translateY(-1px);
box-shadow: 0 5px 15px rgba(0,0,0,0.1); box-shadow: 0 5px 15px rgba(0,0,0,0.05);
} }
.tool-header { .tool-header {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 15px; margin-bottom: 15px;
font-size: 1rem; font-size: 15px;
.tool-icon { .tool-icon {
margin-right: 10px; margin-right: 10px;