blob: 34d91642035af1a9928454754437c2780f8c784e [file] [log] [blame]
22301008b86c21c2025-06-20 19:17:00 +08001// RHJ 深度推荐接口
2import { getAuthToken } from '../utils/auth'
3const RHJ_BASE_URL = 'http://10.126.59.25:8082' // 端口已修正
4
5export 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}