22301008 | b86c21c | 2025-06-20 19:17:00 +0800 | [diff] [blame] | 1 | // RHJ 深度推荐接口 |
| 2 | import { getAuthToken } from '../utils/auth' |
| 3 | const RHJ_BASE_URL = 'http://10.126.59.25:8082' // 端口已修正 |
| 4 | |
| 5 | export async function deepRecommend(userId, topk = 10) { |
| 6 | const token = getAuthToken() |
| 7 | const headers = { |
| 8 | 'Content-Type': 'application/json', |
| 9 | ...(token ? { 'Authorization': `Bearer ${token}` } : {}) |
| 10 | } |
| 11 | const res = await fetch(`${RHJ_BASE_URL}/recommend`, { |
| 12 | method: 'POST', |
| 13 | headers, |
| 14 | body: JSON.stringify({ user_id: userId, topk }) |
| 15 | }) |
| 16 | if (!res.ok) throw new Error('深度推荐接口调用失败') |
| 17 | const data = await res.json() |
| 18 | // 兼容接口返回格式 |
| 19 | return data.data?.recommendations || [] |
| 20 | } |