gorsejs
v0.5.0
Published
TypeScript SDK for Gorse recommender system.
Downloads
1,466
Maintainers
Readme
gorse.js
TypeScript SDK for Gorse recommender system.
Install
- Install with npm:
npm install gorsejs- Install with yarn:
yarn add gorsejsUsage
import { Gorse } from "gorsejs";
const client = new Gorse({
endpoint: "http://127.0.0.1:8088",
secret: "gorse",
});
// Insert a user
await client.insertUser({
UserId: "bob",
Labels: { role: "dev", lang: "ts" },
Comment: "frontend developer"
});
// Insert an item
await client.upsertItem({
ItemId: "repo:vuejs/vue",
Categories: ["framework", "frontend"],
Labels: { stars: 100000 },
Timestamp: "2024-01-01T00:00:00Z",
Comment: "Vue.js repository"
});
// Insert feedback
await client.insertFeedbacks([
{ FeedbackType: "star", UserId: "bob", ItemId: "repo:vuejs/vue", Value: 1, Timestamp: "2024-01-02T00:00:00Z", Comment: "" },
{ FeedbackType: "star", UserId: "bob", ItemId: "repo:d3/d3", Value: 1, Timestamp: "2024-01-03T00:00:00Z", Comment: "" },
{ FeedbackType: "star", UserId: "bob", ItemId: "repo:moment/moment", Value: 1, Timestamp: "2024-01-04T00:00:00Z", Comment: "" }
]);
// Get recommendations
await client.getRecommend({ userId: "bob", cursorOptions: { n: 5 } });