0.0.2 • Published 6 months ago

@crosshatch/ai-provider v0.0.2

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
6 months ago

Vercel AI SDK - Crosshatch Provider

The Crosshatch provider for the Vercel AI SDK contains language model support for the Crosshatch API.

Currently supports the following Crosshatch providers and models:

  • Anthropic
    • claude-3.5-sonnet
    • claude-3-haiku
    • claude-3-sonnet
  • OpenAI
    • gpt-4o
    • gpt-4o mini

Models and providers can be added by request at support@crosshatch.io

Setup

The Crosshatch provider is available in the @crosshatch/ai-provider module. You can install it with

npm i @crosshatch/ai-provider

Provider Instance

You can import the default provider instance crosshatch from @crosshatch/ai-provider:

import { crosshatch } from "@crosshatch/ai-provider";

Examples

Basic

import { crosshatch } from "@crosshatch/ai-provider";
import { generateText } from "ai";

const { text } = await generateText({
  model: crosshatch.languageModel("gpt-4o", {
    token: "YOUR-TOKEN-HERE",
    replace: {
      "{{userInfo}}": {
        select: ["originalTimestamp", "entity_vibe"],
        from: "personalTimeline",
        where: [{ field: "event", op: "=", value: "purchased" }],
        orderBy: [{ field: "originalTimestamp", dir: "desc" }],
        limit: 5,
      },
    },
  }),
  prompt: "What kind of mood is this user in? Heres some info: {{userInfo}}",
});

Using Crosshatch Link

import { crosshatch } from "@crosshatch/ai-provider";
import { link } from "@crosshatch/link";
import { generateText } from "ai";

const { getToken } = await link({ clientId: "YOUR-CLIENT-ID" });

const { text } = await generateText({
  model: crosshatch.languageModel("gpt-4o", {
    token: getToken(),
    replace: {
      "{{userInfo}}": {
        select: ["originalTimestamp", "entity_vibe"],
        from: "personalTimeline",
        where: [{ field: "event", op: "=", value: "purchased" }],
        orderBy: [{ field: "originalTimestamp", dir: "desc" }],
        limit: 5,
      },
    },
  }),
  prompt: "What kind of mood is this user in? Heres some info: {{userInfo}}",
});

Documentation

Please check out our main documentation for more information.