Files
AIclinicalresearch/backend/src/routes/agents.ts
AI Clinical Dev Team 864a0b1906 feat: Day 10-11 - Agent Configuration System completed
Backend:
- Create agents.yaml config file with 12 agents definition
- Create Prompt templates for topic-evaluation agent
- Implement agentService.ts for loading and managing agent configs
- Create agentController.ts with CRUD operations
- Create agent routes (GET /agents, /agents/:id, etc.)
- Register agent routes in main server

Frontend:
- Create agentApi.ts service module
- Update AgentChatPage to dynamically load agent config from API
- Add loading state and error handling
- Display agent details (description, category, model)

Build: Both frontend and backend build successfully
2025-10-10 20:13:08 +08:00

57 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
import { agentController } from '../controllers/agentController.js';
interface AgentParams {
id: string;
}
export async function agentRoutes(fastify: FastifyInstance) {
// 获取所有智能体列表
fastify.get('/agents', async (request: FastifyRequest, reply: FastifyReply) => {
return agentController.getAllAgents(request, reply);
});
// 获取启用的智能体列表
fastify.get('/agents/enabled', async (request: FastifyRequest, reply: FastifyReply) => {
return agentController.getEnabledAgents(request, reply);
});
// 根据分类获取智能体
fastify.get<{ Querystring: { category: string } }>(
'/agents/by-category',
async (request: FastifyRequest<{ Querystring: { category: string } }>, reply: FastifyReply) => {
return agentController.getAgentsByCategory(request, reply);
}
);
// 获取单个智能体详情
fastify.get<{ Params: AgentParams }>(
'/agents/:id',
async (request: FastifyRequest<{ Params: AgentParams }>, reply: FastifyReply) => {
return agentController.getAgentById(request, reply);
}
);
// 获取智能体的系统Prompt
fastify.get<{ Params: AgentParams }>(
'/agents/:id/system-prompt',
async (request: FastifyRequest<{ Params: AgentParams }>, reply: FastifyReply) => {
return agentController.getSystemPrompt(request, reply);
}
);
// 渲染用户Prompt预览
fastify.post<{ Params: AgentParams }>(
'/agents/:id/render-prompt',
async (request: FastifyRequest<{ Params: AgentParams }>, reply: FastifyReply) => {
return agentController.renderPrompt(request, reply);
}
);
// 重新加载配置(管理员功能)
fastify.post('/agents/reload-config', async (request: FastifyRequest, reply: FastifyReply) => {
return agentController.reloadConfig(request, reply);
});
}