new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

crosshatch/setup

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Crosshatch provider package name

The Crosshatch provider is available via the @crosshatch/ai-provider module.

Crosshatch provider AI SDK 5 compatibility

The Crosshatch community provider is not yet compatible with AI SDK 5.

Crosshatch authentication method

The Crosshatch provider is authenticated by user-specific tokens that enable permissioned access to personalized inference. Synthetic and test user tokens can be obtained from the Crosshatch developer dashboard at https://platform.crosshatch.io/. Production user tokens are provisioned and accessed using the Link SDK with a Crosshatch developer client id.

Crosshatch provider instance creation

To create a Crosshatch provider instance, import and call the createCrosshatch function from @crosshatch/ai-provider.

Crosshatch language model creation

To create a Crosshatch model instance, call the provider instance as a function and specify the model name in the first argument (e.g., 'gpt-4o-mini'). In the second argument, provide an object containing token (user auth token), replace (context data), and model arguments.

Crosshatch generateText example with context

import { generateText } from 'ai'; import createCrosshatch from '@crosshatch/ai-provider'; const crosshatch = createCrosshatch(); const { text } = await generateText({ model: crosshatch.languageModel("gpt-4o-mini", { token: 'YOU••••••EN', replace: { restaurants: { select: ["entity_name", "entity_city", "entity_region"], from: "personalTimeline", where: [ { field: "event", op: "=", value: "confirmed" }, { field: "entity_subtype2", op: "=", value: "RESTAURANTS" } ], groupby: ["entity_name", "entity_city", "entity_region"], orderby: "count DESC", limit: 5 } } }), system: `The user recently ate at these restaurants: {restaurants}`, messages: [{role: "user", content: "Where should I stay in Paris?"}] }); This example shows how to use generateText with gpt-4o-mini to generate text based on permissioned user context, specifically querying restaurant data from the personalTimeline.

Crosshatch streamText example with structured output

import { streamText, Output } from 'ai'; import createCrosshatch from '@crosshatch/ai-provider'; const crosshatch = createCrosshatch(); const itemSummaries = [...]; // list of items const ids = (itemSummaries?.map(({ itemId }) => itemId) ?? []) as string[]; const { elementStream } = streamText({ output: Output.array({ element: jsonSchema<{ id: string; reason: string }>({ type: "object", properties: { id: { type: "string", enum: ids }, reason: { type: "string", description: "Explain your ranking." }, }, }), }), model: crosshatch.languageModel("gpt-4o-mini", { token, replace: { "orders": { select: ["originalTimestamp", "entity_name", "order_total", "order_summary"], from: "personalTimeline", where: [{ field: "event", op: "=", value: "purchased" }], orderBy: [{ field: "originalTimestamp", dir: "desc" }], limit: 5, }, }, }), system: `Rerank the following items based on alignment with users recent purchases {orders}`, messages: [{role: "user", content: "Heres a list of item: ${JSON.stringify(itemSummaries)}"}], }); This example shows how to use streamText with structured Output.array() to rerank items based on user purchase history stored in personalTimeline.

Give your agent this brain