Skip to content

gorse-io/gorse-js

Repository files navigation

gorse.js

TypeScript SDK for Gorse recommender system.

CI npm

Install

  • Install with npm:
npm install gorsejs
  • Install with yarn:
yarn add gorsejs

Usage

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 } });

About

TypeScript SDK for gorse recommender system

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 8