update score api client
This commit is contained in:
@ -42,6 +42,7 @@ export const scoreLibraryItem = async (
|
||||
|
||||
const itemFeatures = {
|
||||
[libraryItem.id]: {
|
||||
library_item_id: libraryItem.id,
|
||||
title: libraryItem.title,
|
||||
has_thumbnail: !!libraryItem.thumbnail,
|
||||
has_site_icon: !!libraryItem.siteIcon,
|
||||
@ -59,7 +60,7 @@ export const scoreLibraryItem = async (
|
||||
|
||||
const scores = await getScores({
|
||||
user_id: userId,
|
||||
item_features: itemFeatures,
|
||||
items: itemFeatures,
|
||||
})
|
||||
|
||||
logger.info('Scores', scores)
|
||||
|
||||
@ -166,8 +166,9 @@ const rankCandidates = async (
|
||||
|
||||
const data = {
|
||||
user_id: userId,
|
||||
item_features: unscoredCandidates.reduce((acc, item) => {
|
||||
items: unscoredCandidates.reduce((acc, item) => {
|
||||
acc[item.id] = {
|
||||
library_item_id: item.id,
|
||||
title: item.title,
|
||||
has_thumbnail: !!item.thumbnail,
|
||||
has_site_icon: !!item.siteIcon,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
export interface Feature {
|
||||
library_item_id?: string
|
||||
title: string
|
||||
has_thumbnail: boolean
|
||||
has_site_icon: boolean
|
||||
@ -15,7 +16,7 @@ export interface Feature {
|
||||
|
||||
export interface ScoreApiRequestBody {
|
||||
user_id: string
|
||||
item_features: Record<string, Feature> // item_id -> feature
|
||||
items: Record<string, Feature> // item_id -> feature
|
||||
}
|
||||
|
||||
export type ScoreApiResponse = Record<string, number> // item_id -> score
|
||||
@ -23,7 +24,7 @@ export type ScoreApiResponse = Record<string, number> // item_id -> score
|
||||
export const getScores = async (
|
||||
data: ScoreApiRequestBody
|
||||
): Promise<ScoreApiResponse> => {
|
||||
const API_URL = 'http://127.0.0.1:5000/predictions'
|
||||
const API_URL = 'http://digest-score/batch'
|
||||
// const token = process.env.SCORE_API_TOKEN
|
||||
|
||||
// if (!token) {
|
||||
|
||||
Reference in New Issue
Block a user