feat: 服务网关添加接口地址和使用示例

- MCP: agentmcp.taijiaicloud.com
- A2A: agenta2a.taijiaicloud.com
- API: agentapi.taijiaicloud.com
- 将'查看文档'改为'查看接口'
- 添加接口详情对话框,包含使用示例和功能说明
This commit is contained in:
zhanggangyong
2026-01-13 12:51:04 +00:00
parent f620fa9c91
commit c57e05e636
+120 -2
View File
@@ -38,6 +38,8 @@ export default function ModelGatewayPage() {
const [gatewayAPIs, setGatewayAPIs] = useState<any[]>([])
const [monitoring, setMonitoring] = useState<any>(null)
const [stats, setStats] = useState({ availableGateways: 0, endpoints: 0, avgLatency: 0, requestsToday: 0 })
const [showGatewayDialog, setShowGatewayDialog] = useState(false)
const [selectedGateway, setSelectedGateway] = useState<any>(null)
useEffect(() => {
loadGatewayData()
@@ -123,18 +125,21 @@ export default function ModelGatewayPage() {
fullName: "Model Context Protocol",
icon: Code2,
description: "适用于需要上下文理解的复杂对话场景",
endpoint: "agentmcp.taijiaicloud.com",
},
{
name: "A2A",
fullName: "Agent-to-Agent Protocol",
icon: Boxes,
description: "适用于多Agent协同工作的场景",
endpoint: "agenta2a.taijiaicloud.com",
},
{
name: "API",
fullName: "Standard API Gateway",
icon: Workflow,
description: "标准REST API,适用于简单的请求响应场景",
endpoint: "agentapi.taijiaicloud.com",
},
]
@@ -288,11 +293,21 @@ export default function ModelGatewayPage() {
</div>
<p className="text-sm text-muted-foreground mb-1">{gateway.fullName}</p>
<p className="text-xs text-muted-foreground">{gateway.description}</p>
<p className="text-xs text-primary mt-1 font-mono">
{t("接口地址", "Endpoint")}: https://{gateway.endpoint}
</p>
</div>
</div>
<div className="flex items-center gap-6">
<Button variant="outline" size="sm">
{t("查看文档", "View Docs")}
<Button
variant="outline"
size="sm"
onClick={() => {
setSelectedGateway(gateway)
setShowGatewayDialog(true)
}}
>
{t("查看接口", "View API")}
</Button>
</div>
</div>
@@ -491,6 +506,109 @@ export default function ModelGatewayPage() {
</DialogFooter>
</DialogContent>
</Dialog>
{/* Gateway API Details Dialog */}
<Dialog open={showGatewayDialog} onOpenChange={setShowGatewayDialog}>
<DialogContent className="max-w-2xl">
<DialogHeader>
<DialogTitle>{selectedGateway?.name} {t("接口说明", "API Documentation")}</DialogTitle>
<DialogDescription>
{selectedGateway?.fullName} - {selectedGateway?.description}
</DialogDescription>
</DialogHeader>
<div className="space-y-4 py-4">
{/* 接口地址 */}
<div className="space-y-2">
<Label>{t("接口地址", "Endpoint URL")}</Label>
<div className="rounded-md bg-muted p-3 font-mono text-sm">
https://{selectedGateway?.endpoint}
</div>
</div>
{/* 使用示例 */}
<div className="space-y-2">
<Label>{t("使用示例", "Usage Example")}</Label>
<div className="rounded-md bg-muted p-3">
<code className="text-xs whitespace-pre-wrap">
{selectedGateway?.name === "MCP" && (
<>
{`curl -X POST https://${selectedGateway?.endpoint}/v1/context \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"model": "gpt-4",
"context": "Your context here",
"messages": [
{"role": "user", "content": "Hello"}
]
}'`}
</>
)}
{selectedGateway?.name === "A2A" && (
<>
{`curl -X POST https://${selectedGateway?.endpoint}/v1/agent/invoke \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"source_agent": "agent-001",
"target_agent": "agent-002",
"task": "process_data",
"payload": {"data": "example"}
}'`}
</>
)}
{selectedGateway?.name === "API" && (
<>
{`curl -X POST https://${selectedGateway?.endpoint}/v1/chat/completions \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "Hello"}
]
}'`}
</>
)}
</code>
</div>
</div>
{/* 功能说明 */}
<div className="space-y-2">
<Label>{t("功能说明", "Features")}</Label>
<div className="text-sm text-muted-foreground space-y-1">
{selectedGateway?.name === "MCP" && (
<ul className="list-disc list-inside space-y-1">
<li>{t("支持上下文管理和会话状态保持", "Supports context management and session state persistence")}</li>
<li>{t("适用于复杂对话场景", "Suitable for complex dialogue scenarios")}</li>
<li>{t("提供模型上下文协议标准接口", "Provides Model Context Protocol standard interface")}</li>
</ul>
)}
{selectedGateway?.name === "A2A" && (
<ul className="list-disc list-inside space-y-1">
<li>{t("支持Agent间通信和任务分发", "Supports inter-agent communication and task distribution")}</li>
<li>{t("适用于多Agent协同工作场景", "Suitable for multi-agent collaboration scenarios")}</li>
<li>{t("提供Agent到Agent协议标准接口", "Provides Agent-to-Agent Protocol standard interface")}</li>
</ul>
)}
{selectedGateway?.name === "API" && (
<ul className="list-disc list-inside space-y-1">
<li>{t("兼容OpenAI API格式", "Compatible with OpenAI API format")}</li>
<li>{t("适用于简单的请求响应场景", "Suitable for simple request-response scenarios")}</li>
<li>{t("提供标准REST API接口", "Provides standard REST API interface")}</li>
</ul>
)}
</div>
</div>
</div>
<DialogFooter>
<Button onClick={() => setShowGatewayDialog(false)}>{t("关闭", "Close")}</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</DashboardLayout>
</AuthGuard>
)