blob: 34d91642035af1a9928454754437c2780f8c784e [file] [log] [blame]
// RHJ 深度推荐接口
import { getAuthToken } from '../utils/auth'
const RHJ_BASE_URL = 'http://10.126.59.25:8082' // 端口已修正
export async function deepRecommend(userId, topk = 10) {
const token = getAuthToken()
const headers = {
'Content-Type': 'application/json',
...(token ? { 'Authorization': `Bearer ${token}` } : {})
}
const res = await fetch(`${RHJ_BASE_URL}/recommend`, {
method: 'POST',
headers,
body: JSON.stringify({ user_id: userId, topk })
})
if (!res.ok) throw new Error('深度推荐接口调用失败')
const data = await res.json()
// 兼容接口返回格式
return data.data?.recommendations || []
}