|
@@ -1069,7 +1069,39 @@ export const transferFamilyAdmin = (newAdminId) => {
|
|
|
|
|
|
|
|
// ===== AI 鑱婂ぉ =====
|
|
// ===== AI 鑱婂ぉ =====
|
|
|
export const aiSendMessage = (data) => {
|
|
export const aiSendMessage = (data) => {
|
|
|
- return request('/api/ai/chat/send', 'POST', data)
|
|
|
|
|
|
|
+ var query = data && data.query ? data.query : ''
|
|
|
|
|
+ var conversationId = data && data.conversationId ? data.conversationId : ''
|
|
|
|
|
+ var userId = uni.getStorageSync('userId') || ''
|
|
|
|
|
+ var langgraphBody = {
|
|
|
|
|
+ query: query,
|
|
|
|
|
+ user: userId,
|
|
|
|
|
+ user_id: userId,
|
|
|
|
|
+ conversation_id: conversationId,
|
|
|
|
|
+ response_mode: 'blocking',
|
|
|
|
|
+ bot_name: 'AI管家'
|
|
|
|
|
+ }
|
|
|
|
|
+ if (data && data.reportId) {
|
|
|
|
|
+ langgraphBody.inputs = { report_id: data.reportId }
|
|
|
|
|
+ }
|
|
|
|
|
+ return langgraphRequest({
|
|
|
|
|
+ langgraphPath: '/api/v1/chat/completion',
|
|
|
|
|
+ langgraphBody: langgraphBody,
|
|
|
|
|
+ difyFallbackPath: '/api/ai/chat/send',
|
|
|
|
|
+ difyFallbackData: data,
|
|
|
|
|
+ transform: function(lgRes) {
|
|
|
|
|
+ var content = ''
|
|
|
|
|
+ if (lgRes && lgRes.choices && lgRes.choices.length > 0) {
|
|
|
|
|
+ var msg = lgRes.choices[0].message
|
|
|
|
|
+ if (msg && msg.content) { content = msg.content }
|
|
|
|
|
+ }
|
|
|
|
|
+ return {
|
|
|
|
|
+ answer: content,
|
|
|
|
|
+ conversationId: conversationId,
|
|
|
|
|
+ recommendations: [],
|
|
|
|
|
+ tasks: []
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export const aiGetConversations = () => {
|
|
export const aiGetConversations = () => {
|
|
@@ -1086,7 +1118,40 @@ export const aiDeleteConversation = (id) => {
|
|
|
|
|
|
|
|
// 精准营养助手(基于体检报告)
|
|
// 精准营养助手(基于体检报告)
|
|
|
export const aiSendNutritionMessage = (data) => {
|
|
export const aiSendNutritionMessage = (data) => {
|
|
|
- return request('/api/ai/nutrition/send', 'POST', data)
|
|
|
|
|
|
|
+ var query = data && data.query ? data.query : ''
|
|
|
|
|
+ var conversationId = data && data.conversationId ? data.conversationId : ''
|
|
|
|
|
+ var reportId = data && data.reportId ? data.reportId : null
|
|
|
|
|
+ var userId = uni.getStorageSync('userId') || ''
|
|
|
|
|
+ var langgraphBody = {
|
|
|
|
|
+ query: query,
|
|
|
|
|
+ user: userId,
|
|
|
|
|
+ user_id: userId,
|
|
|
|
|
+ conversation_id: conversationId,
|
|
|
|
|
+ response_mode: 'blocking',
|
|
|
|
|
+ bot_name: '精准营养助手'
|
|
|
|
|
+ }
|
|
|
|
|
+ if (reportId) {
|
|
|
|
|
+ langgraphBody.inputs = { report_id: reportId }
|
|
|
|
|
+ }
|
|
|
|
|
+ return langgraphRequest({
|
|
|
|
|
+ langgraphPath: '/api/v1/analysis/run',
|
|
|
|
|
+ langgraphBody: langgraphBody,
|
|
|
|
|
+ difyFallbackPath: '/api/ai/nutrition/send',
|
|
|
|
|
+ difyFallbackData: data,
|
|
|
|
|
+ transform: function(lgRes) {
|
|
|
|
|
+ var content = ''
|
|
|
|
|
+ if (lgRes && lgRes.choices && lgRes.choices.length > 0) {
|
|
|
|
|
+ var msg = lgRes.choices[0].message
|
|
|
|
|
+ if (msg && msg.content) { content = msg.content }
|
|
|
|
|
+ }
|
|
|
|
|
+ return {
|
|
|
|
|
+ answer: content,
|
|
|
|
|
+ conversationId: conversationId,
|
|
|
|
|
+ recommendations: [],
|
|
|
|
|
+ tasks: []
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ===================== 幸福邻里部落 - 服务商模块 =====================
|
|
// ===================== 幸福邻里部落 - 服务商模块 =====================
|