@crosshatch/ai-provider
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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.

Package Sidebar

Install

npm i @crosshatch/ai-provider

Weekly Downloads

1

Version

0.0.1

License

Apache-2.0

Unpacked Size

934 kB

Total Files

9

Last publish

Collaborators

  • jessehalpern