| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import axios from 'axios'
- // LangGraph 服务地址
- const LANGGRAPH_BASE = 'https://ai.etotem.com.cn'
- // 直接创建 axios 实例,不走通用拦截器(LangGraph 返回原始 JSON,不是 {code, data} 格式)
- const lgAxios = axios.create({
- baseURL: LANGGRAPH_BASE,
- timeout: 10000,
- withCredentials: true
- })
- /**
- * 获取 LangGraph 健康状态
- */
- export function getLangGraphHealth() {
- return new Promise((resolve) => {
- const img = new Image()
- img.onload = () => resolve({ status: 'healthy' })
- img.onerror = () => resolve({ status: 'unreachable' })
- img.src = LANGGRAPH_BASE + '/health?t=' + Date.now()
- })
- }
- /**
- * 获取 LangGraph OpenAPI 规范
- */
- export function getLangGraphSpec() {
- return lgAxios.get('/openapi.json')
- }
- /**
- * 获取详细健康检查
- */
- export function getLangGraphDetailedHealth() {
- return lgAxios.get('/api/v1/health')
- }
- /**
- * 获取 Prometheus metrics
- */
- export function getLangGraphMetrics() {
- return lgAxios.get('/metrics')
- }
- /**
- * 测试食材识别
- */
- export function testFoodRecognize(data) {
- return lgAxios.post('/api/v1/food/recognize', data, { timeout: 60000 })
- }
- /**
- * 测试菜单生成
- */
- export function testMenuGenerate(data) {
- return lgAxios.post('/api/v1/menu/generate', data, { timeout: 60000 })
- }
- /**
- * 测试对话
- */
- export function testChat(data) {
- return lgAxios.post('/api/v1/chat', data, { timeout: 60000 })
- }
- /**
- * 测试营养推荐
- */
- export function testRecommend(data) {
- return lgAxios.post('/api/v1/recommend', data, { timeout: 60000 })
- }
- /**
- * 测试问卷生成
- */
- export function testQuestionnaireGenerate(data) {
- return lgAxios.post('/api/v1/questionnaire/generate', data, { timeout: 60000 })
- }
|