@fastpaca/cria 0.0.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -106
- package/dist/ai-sdk/index.d.ts +43 -0
- package/dist/ai-sdk/index.d.ts.map +1 -0
- package/dist/ai-sdk/index.js +303 -0
- package/dist/ai-sdk/index.js.map +1 -0
- package/dist/ai-sdk/index.test.d.ts +2 -0
- package/dist/ai-sdk/index.test.d.ts.map +1 -0
- package/dist/ai-sdk/index.test.js +101 -0
- package/dist/ai-sdk/index.test.js.map +1 -0
- package/dist/anthropic/index.d.ts +74 -0
- package/dist/anthropic/index.d.ts.map +1 -0
- package/dist/anthropic/index.js +238 -0
- package/dist/anthropic/index.js.map +1 -0
- package/dist/anthropic/index.test.d.ts +2 -0
- package/dist/anthropic/index.test.d.ts.map +1 -0
- package/dist/anthropic/index.test.js +115 -0
- package/dist/anthropic/index.test.js.map +1 -0
- package/dist/components/additional.test.d.ts +2 -0
- package/dist/components/additional.test.d.ts.map +1 -0
- package/dist/components/additional.test.js +31 -0
- package/dist/components/additional.test.js.map +1 -0
- package/dist/components/index.d.ts +148 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +184 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/summary.d.ts +91 -0
- package/dist/components/summary.d.ts.map +1 -0
- package/dist/components/summary.js +118 -0
- package/dist/components/summary.js.map +1 -0
- package/dist/components/summary.test.d.ts +2 -0
- package/dist/components/summary.test.d.ts.map +1 -0
- package/dist/components/summary.test.js +101 -0
- package/dist/components/summary.test.js.map +1 -0
- package/dist/components/vector-search.d.ts +70 -0
- package/dist/components/vector-search.d.ts.map +1 -0
- package/dist/components/vector-search.js +110 -0
- package/dist/components/vector-search.js.map +1 -0
- package/dist/components/vector-search.test.d.ts +2 -0
- package/dist/components/vector-search.test.d.ts.map +1 -0
- package/dist/components/vector-search.test.js +113 -0
- package/dist/components/vector-search.test.js.map +1 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/instrumentation/otel.d.ts +19 -0
- package/dist/instrumentation/otel.d.ts.map +1 -0
- package/dist/instrumentation/otel.js +102 -0
- package/dist/instrumentation/otel.js.map +1 -0
- package/dist/instrumentation/otel.test.d.ts +2 -0
- package/dist/instrumentation/otel.test.d.ts.map +1 -0
- package/dist/instrumentation/otel.test.js +116 -0
- package/dist/instrumentation/otel.test.js.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +2 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.d.ts +30 -8
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js +13 -10
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/memory/chroma/index.d.ts +59 -0
- package/dist/memory/chroma/index.d.ts.map +1 -0
- package/dist/memory/chroma/index.js +172 -0
- package/dist/memory/chroma/index.js.map +1 -0
- package/dist/memory/index.d.ts +4 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +2 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/key-value.d.ts +71 -0
- package/dist/memory/key-value.d.ts.map +1 -0
- package/dist/memory/key-value.js +34 -0
- package/dist/memory/key-value.js.map +1 -0
- package/dist/memory/postgres.d.ts +71 -0
- package/dist/memory/postgres.d.ts.map +1 -0
- package/dist/memory/postgres.js +109 -0
- package/dist/memory/postgres.js.map +1 -0
- package/dist/memory/qdrant/index.d.ts +64 -0
- package/dist/memory/qdrant/index.d.ts.map +1 -0
- package/dist/memory/qdrant/index.js +136 -0
- package/dist/memory/qdrant/index.js.map +1 -0
- package/dist/memory/redis.d.ts +70 -0
- package/dist/memory/redis.d.ts.map +1 -0
- package/dist/memory/redis.js +100 -0
- package/dist/memory/redis.js.map +1 -0
- package/dist/memory/vector.d.ts +53 -0
- package/dist/memory/vector.d.ts.map +1 -0
- package/dist/memory/vector.js +2 -0
- package/dist/memory/vector.js.map +1 -0
- package/dist/openai/index.d.ts +46 -0
- package/dist/openai/index.d.ts.map +1 -0
- package/dist/openai/index.js +260 -0
- package/dist/openai/index.js.map +1 -0
- package/dist/openai/index.test.d.ts +2 -0
- package/dist/openai/index.test.d.ts.map +1 -0
- package/dist/openai/index.test.js +204 -0
- package/dist/openai/index.test.js.map +1 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +2 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/types.d.ts +2 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +2 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/render.d.ts +44 -40
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +162 -148
- package/dist/render.js.map +1 -1
- package/dist/render.test.js +146 -28
- package/dist/render.test.js.map +1 -1
- package/dist/renderers/markdown.d.ts +3 -0
- package/dist/renderers/markdown.d.ts.map +1 -0
- package/dist/renderers/markdown.js +43 -0
- package/dist/renderers/markdown.js.map +1 -0
- package/dist/renderers/shared.d.ts +82 -0
- package/dist/renderers/shared.d.ts.map +1 -0
- package/dist/renderers/shared.js +156 -0
- package/dist/renderers/shared.js.map +1 -0
- package/dist/snapshot.d.ts +47 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +140 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/snapshot.test.d.ts +2 -0
- package/dist/snapshot.test.d.ts.map +1 -0
- package/dist/snapshot.test.js +68 -0
- package/dist/snapshot.test.js.map +1 -0
- package/dist/tokenizers.d.ts +14 -0
- package/dist/tokenizers.d.ts.map +1 -0
- package/dist/tokenizers.js +45 -0
- package/dist/tokenizers.js.map +1 -0
- package/dist/types.d.ts +212 -84
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +109 -0
- package/dist/types.js.map +1 -1
- package/package.json +88 -3
- package/dist/components.d.ts +0 -78
- package/dist/components.d.ts.map +0 -1
- package/dist/components.js +0 -98
- package/dist/components.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<h1 align="center">Cria</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
|
|
4
|
+
<i>Your prompts deserve the same structure as your code.</i>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
<i>
|
|
8
|
+
<b><i>Cria turns prompts into composable components with explicit roles and strategies, and works with your existing environment & frameworks.</i></b>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
+
<a href="https://github.com/fastpaca/cria/actions/workflows/ci.yml"><img src="https://github.com/fastpaca/cria/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
12
13
|
<a href="https://www.npmjs.com/package/@fastpaca/cria"><img src="https://img.shields.io/npm/v/@fastpaca/cria?logo=npm&logoColor=white" alt="npm"></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/@fastpaca/cria"><img src="https://img.shields.io/npm/dm/@fastpaca/cria" alt="Downloads"></a>
|
|
13
15
|
<a href="https://opensource.org/license/mit"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License"></a>
|
|
14
16
|
</p>
|
|
15
17
|
|
|
@@ -19,147 +21,132 @@
|
|
|
19
21
|
</a>
|
|
20
22
|
</p>
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
Cria is a lightweight JSX prompt composition library for structured prompt engineering. Build prompts as components, keep behavior predictable, and reuse the same structure across providers. Runs on Node, Deno, Bun, and Edge; adapters require their SDKs.
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Cria treats memory layout as a first-class concern. You declare priorities upfront, and the library handles eviction when needed. Components let you test retrieval logic separately from system prompts, swap implementations without rewrites, and debug exactly which content got cut when quality degrades.
|
|
26
|
+
## Example
|
|
27
27
|
|
|
28
28
|
```tsx
|
|
29
|
+
import { Message, Omit, Region, Truncate, render } from "@fastpaca/cria";
|
|
30
|
+
|
|
29
31
|
const prompt = (
|
|
30
32
|
<Region priority={0}>
|
|
31
|
-
You are a helpful assistant
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
<
|
|
35
|
-
{conversationHistory}
|
|
36
|
-
</Truncate>
|
|
37
|
-
|
|
38
|
-
{/* Only preserve 20k tokens of tool calls. It gets dropped
|
|
39
|
-
first in case we need to. */}
|
|
40
|
-
<Truncate budget={20000} priority={3}>
|
|
41
|
-
{toolCalls}
|
|
42
|
-
</Truncate>
|
|
43
|
-
|
|
44
|
-
{/* Skip examples in case we are bad on budget */}
|
|
45
|
-
<Omit priority={3}>{examples}</Omit>
|
|
46
|
-
|
|
47
|
-
{userMessage}
|
|
33
|
+
<Message messageRole="system">You are a helpful assistant.</Message>
|
|
34
|
+
<Last N={12} priority={2}>{historyMessages}</Last>
|
|
35
|
+
<Omit priority={3}>{optionalExamples}</Omit>
|
|
36
|
+
<Message messageRole="user">{userQuestion}</Message>
|
|
48
37
|
</Region>
|
|
49
38
|
);
|
|
50
39
|
|
|
51
|
-
render(prompt, {
|
|
40
|
+
const output = await render(prompt, { budget: 8_000 });
|
|
52
41
|
```
|
|
53
42
|
|
|
54
|
-
|
|
55
|
-
## Features
|
|
56
|
-
|
|
57
|
-
- **Composable** — Build prompts from reusable components. Test and optimize each part independently.
|
|
58
|
-
- **Priority-based** — Declare what's sacred (priority 0) and what's expendable (priority 3). No more guessing what gets cut.
|
|
59
|
-
- **Flexible strategies** — Truncate content progressively, omit entire sections, or write custom eviction logic.
|
|
60
|
-
- **Tiny** — Zero dependencies.
|
|
43
|
+
See all **[-> Documentation](docs/README.md)** for more comprehensive overviews.
|
|
61
44
|
|
|
62
|
-
##
|
|
45
|
+
## Use Cria when you need...
|
|
63
46
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Add
|
|
69
|
-
|
|
70
|
-
```json
|
|
71
|
-
{
|
|
72
|
-
"compilerOptions": {
|
|
73
|
-
"jsx": "react-jsx",
|
|
74
|
-
"jsxImportSource": "@fastpaca/cria"
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
```
|
|
47
|
+
- **Need RAG?** Add `<VectorSearch>`!
|
|
48
|
+
- **Need a summary for long conversations?** Add `<Summary>`!
|
|
49
|
+
- **Need to cap history but keep structure?** Use `<Last>`.
|
|
50
|
+
- **Need to drop optional context when the context window is full?** Add `<Omit>`.
|
|
51
|
+
- **Need granular tool calling structure?** Add `<ToolCall>` and `<ToolResult>`.
|
|
52
|
+
- **Using AI SDK?** Plug and play with `@fastpaca/cria/ai-sdk`!
|
|
78
53
|
|
|
79
|
-
##
|
|
54
|
+
## Integrations
|
|
80
55
|
|
|
81
|
-
|
|
56
|
+
<details>
|
|
57
|
+
<summary><strong>OpenAI Chat Completions</strong></summary>
|
|
82
58
|
|
|
83
|
-
|
|
59
|
+
```tsx
|
|
60
|
+
import OpenAI from "openai";
|
|
61
|
+
import { chatCompletions } from "@fastpaca/cria/openai";
|
|
62
|
+
import { render } from "@fastpaca/cria";
|
|
84
63
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
<Region priority={2}>Retrieved context</Region>
|
|
89
|
-
</Region>
|
|
64
|
+
const client = new OpenAI();
|
|
65
|
+
const messages = await render(prompt, { budget, renderer: chatCompletions });
|
|
66
|
+
const response = await client.chat.completions.create({ model: "gpt-4o", messages });
|
|
90
67
|
```
|
|
68
|
+
</details>
|
|
91
69
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
```jsx
|
|
95
|
-
<Truncate budget={10000} from="start" priority={2}>
|
|
96
|
-
{longConversation}
|
|
97
|
-
</Truncate>
|
|
98
|
-
```
|
|
70
|
+
<details>
|
|
71
|
+
<summary><strong>OpenAI Responses</strong></summary>
|
|
99
72
|
|
|
100
|
-
|
|
73
|
+
```tsx
|
|
74
|
+
import OpenAI from "openai";
|
|
75
|
+
import { responses } from "@fastpaca/cria/openai";
|
|
76
|
+
import { render } from "@fastpaca/cria";
|
|
101
77
|
|
|
102
|
-
|
|
103
|
-
|
|
78
|
+
const client = new OpenAI();
|
|
79
|
+
const input = await render(prompt, { budget, renderer: responses });
|
|
80
|
+
const response = await client.responses.create({ model: "o3", input });
|
|
104
81
|
```
|
|
82
|
+
</details>
|
|
105
83
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Lower number = higher importance.
|
|
84
|
+
<details>
|
|
85
|
+
<summary><strong>Anthropic</strong></summary>
|
|
109
86
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
87
|
+
```tsx
|
|
88
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
89
|
+
import { anthropic } from "@fastpaca/cria/anthropic";
|
|
90
|
+
import { render } from "@fastpaca/cria";
|
|
91
|
+
|
|
92
|
+
const client = new Anthropic();
|
|
93
|
+
const { system, messages } = await render(prompt, {
|
|
94
|
+
budget,
|
|
95
|
+
renderer: anthropic,
|
|
96
|
+
});
|
|
97
|
+
const response = await client.messages.create({ model: "claude-sonnet-4-20250514", system, messages });
|
|
98
|
+
```
|
|
99
|
+
</details>
|
|
118
100
|
|
|
119
|
-
|
|
101
|
+
<details>
|
|
102
|
+
<summary><strong>Vercel AI SDK</strong></summary>
|
|
120
103
|
|
|
121
104
|
```tsx
|
|
122
|
-
import {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const tokenizer = (text: string) => enc.encode(text).length;
|
|
105
|
+
import { renderer } from "@fastpaca/cria/ai-sdk";
|
|
106
|
+
import { render } from "@fastpaca/cria";
|
|
107
|
+
import { generateText } from "ai";
|
|
126
108
|
|
|
127
|
-
render(prompt, {
|
|
109
|
+
const messages = await render(prompt, { budget, renderer });
|
|
110
|
+
const { text } = await generateText({ model, messages });
|
|
128
111
|
```
|
|
112
|
+
</details>
|
|
129
113
|
|
|
130
|
-
|
|
114
|
+
## Roadmap
|
|
131
115
|
|
|
132
|
-
|
|
116
|
+
**Done**
|
|
133
117
|
|
|
134
|
-
|
|
135
|
-
|
|
118
|
+
- [x] JSX runtime and priority-based eviction
|
|
119
|
+
- [x] Components: Region, Message, Truncate, Omit, Last, Summary, VectorSearch, ToolCall, ToolResult, Reasoning, Examples, CodeBlock, Separator
|
|
120
|
+
- [x] Renderers: OpenAI (Chat Completions + Responses), Anthropic, AI SDK
|
|
121
|
+
- [x] AI SDK helpers: Messages component, DEFAULT_PRIORITIES
|
|
122
|
+
- [x] Memory: InMemoryStore, Redis, Postgres, Chroma, Qdrant
|
|
123
|
+
- [x] Observability: render hooks, validation schemas, snapshots, OpenTelemetry
|
|
136
124
|
|
|
137
|
-
|
|
138
|
-
const summary = createSummary(target.content);
|
|
139
|
-
return [{ ...target, content: summary, tokens: tokenizer(summary) }];
|
|
140
|
-
};
|
|
125
|
+
**Planned**
|
|
141
126
|
|
|
142
|
-
|
|
143
|
-
|
|
127
|
+
- [ ] Message storage (conversation history management)
|
|
128
|
+
- [ ] Tokenizer helpers
|
|
129
|
+
- [ ] Next.js adapter
|
|
130
|
+
- [ ] GenAI semantic conventions for OpenTelemetry
|
|
131
|
+
- [ ] Visualization tool
|
|
144
132
|
|
|
145
|
-
|
|
133
|
+
## Contributing
|
|
146
134
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
try {
|
|
151
|
-
render(prompt, { tokenizer, budget: 1000 });
|
|
152
|
-
} catch (e) {
|
|
153
|
-
if (e instanceof FitError) {
|
|
154
|
-
console.log(`Over budget by ${e.overBudgetBy} tokens`);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
```
|
|
135
|
+
- Issues and PRs are welcome.
|
|
136
|
+
- Keep changes small and focused.
|
|
137
|
+
- If you add a feature, include a short example or doc note.
|
|
158
138
|
|
|
159
|
-
##
|
|
139
|
+
## Support
|
|
140
|
+
|
|
141
|
+
- Open a GitHub issue for bugs or feature requests.
|
|
142
|
+
- For quick questions, include a minimal repro or snippet.
|
|
143
|
+
|
|
144
|
+
## FAQ
|
|
160
145
|
|
|
161
|
-
|
|
146
|
+
- **Does this replace my LLM SDK?** No - Cria builds prompt structures. You still use your SDK to call the model.
|
|
147
|
+
- **How do I tune token budgets?** Pass `budget` to `render()` and set priorities on regions. Providers include tiktoken defaults; see [docs/tokenization.md](docs/tokenization.md) to bring your own.
|
|
148
|
+
- **Is this production-ready?** The core features are stable; see the docs for what's in progress.
|
|
162
149
|
|
|
163
150
|
## License
|
|
164
151
|
|
|
165
|
-
MIT
|
|
152
|
+
MIT
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { LanguageModel, ModelMessage, UIMessage } from "ai";
|
|
2
|
+
import type { Child } from "../jsx-runtime";
|
|
3
|
+
import type { MaybePromise, PromptElement, PromptRenderer, Tokenizer } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Priority configuration for message types when rendering prompts.
|
|
6
|
+
* Lower numbers = higher priority (less likely to be dropped).
|
|
7
|
+
*/
|
|
8
|
+
export interface Priorities {
|
|
9
|
+
system: number;
|
|
10
|
+
user: number;
|
|
11
|
+
assistant: number;
|
|
12
|
+
toolCall: number;
|
|
13
|
+
toolResult: number;
|
|
14
|
+
reasoning: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const DEFAULT_PRIORITIES: Priorities;
|
|
17
|
+
export interface MessagesProps {
|
|
18
|
+
messages: readonly UIMessage[];
|
|
19
|
+
includeReasoning?: boolean;
|
|
20
|
+
priorities?: Partial<Priorities>;
|
|
21
|
+
id?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Converts AI SDK UIMessages into Cria prompt elements.
|
|
25
|
+
* Use this to include conversation history in your prompts.
|
|
26
|
+
*/
|
|
27
|
+
export declare function Messages({ messages, includeReasoning, priorities, id, }: MessagesProps): MaybePromise<PromptElement>;
|
|
28
|
+
/**
|
|
29
|
+
* Renderer that outputs ModelMessage[] for use with the Vercel AI SDK.
|
|
30
|
+
* Pass this to render() to get messages compatible with generateText/streamText.
|
|
31
|
+
*/
|
|
32
|
+
export declare const renderer: PromptRenderer<ModelMessage[]>;
|
|
33
|
+
interface AISDKProviderProps {
|
|
34
|
+
/** The language model to use (e.g. openai("gpt-4o"), anthropic("claude-sonnet-4-20250514")) */
|
|
35
|
+
model: LanguageModel;
|
|
36
|
+
/** Optional tokenizer to use for budgeting; defaults to an approximate counter */
|
|
37
|
+
tokenizer?: Tokenizer;
|
|
38
|
+
/** Child components that will have access to this provider */
|
|
39
|
+
children?: Child;
|
|
40
|
+
}
|
|
41
|
+
export declare function AISDKProvider({ model, tokenizer, children, }: AISDKProviderProps): MaybePromise<PromptElement>;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai-sdk/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EAEZ,SAAS,EACV,MAAM,IAAI,CAAC;AASZ,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAW5C,OAAO,KAAK,EAGV,YAAY,EAGZ,aAAa,EACb,cAAc,EAEd,SAAS,EACV,MAAM,UAAU,CAAC;AAElB;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,kBAAkB,EAAE,UAOhC,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,SAAS,SAAS,EAAE,CAAC;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,gBAAwB,EACxB,UAAU,EACV,EAAE,GACH,EAAE,aAAa,GAAG,YAAY,CAAC,aAAa,CAAC,CAc7C;AA0LD;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,cAAc,CAAC,YAAY,EAAE,CAKnD,CAAC;AAoMF,UAAU,kBAAkB;IAC1B,+FAA+F;IAC/F,KAAK,EAAE,aAAa,CAAC;IACrB,kFAAkF;IAClF,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB;AA4BD,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,SAAS,EACT,QAAa,GACd,EAAE,kBAAkB,GAAG,YAAY,CAAC,aAAa,CAAC,CA+BlD"}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@fastpaca/cria/jsx-runtime";
|
|
2
|
+
import { generateText } from "ai";
|
|
3
|
+
import { Message, Reasoning, Region, ToolCall, ToolResult, } from "../components";
|
|
4
|
+
import { markdownRenderer } from "../renderers/markdown";
|
|
5
|
+
import { coalesceTextParts, collectMessageNodes, collectSemanticParts, partsToText, } from "../renderers/shared";
|
|
6
|
+
import { tiktokenTokenizer } from "../tokenizers";
|
|
7
|
+
export const DEFAULT_PRIORITIES = {
|
|
8
|
+
system: 0,
|
|
9
|
+
user: 1,
|
|
10
|
+
assistant: 1,
|
|
11
|
+
toolCall: 3,
|
|
12
|
+
toolResult: 2,
|
|
13
|
+
reasoning: 3,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Converts AI SDK UIMessages into Cria prompt elements.
|
|
17
|
+
* Use this to include conversation history in your prompts.
|
|
18
|
+
*/
|
|
19
|
+
export function Messages({ messages, includeReasoning = false, priorities, id, }) {
|
|
20
|
+
const resolvedPriorities = resolvePriorities(priorities);
|
|
21
|
+
return (_jsx(Region, { priority: 0, ...(id === undefined ? {} : { id }), children: messages.map((message) => (_jsx(UIMessageElement, { includeReasoning: includeReasoning, message: message, priorities: resolvedPriorities }))) }));
|
|
22
|
+
}
|
|
23
|
+
const omitStrategy = () => null;
|
|
24
|
+
function UIMessageElement({ message, priorities, includeReasoning, }) {
|
|
25
|
+
const messagePriority = rolePriority(message.role, priorities);
|
|
26
|
+
return (_jsx(Message, { id: `message:${message.id}`, messageRole: message.role, priority: messagePriority, children: message.parts.map((part) => {
|
|
27
|
+
if (part.type === "text") {
|
|
28
|
+
return part.text;
|
|
29
|
+
}
|
|
30
|
+
if (part.type === "reasoning") {
|
|
31
|
+
if (!includeReasoning) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return (_jsx(Reasoning, { priority: priorities.reasoning, strategy: omitStrategy, text: part.text }));
|
|
35
|
+
}
|
|
36
|
+
const toolInvocation = parseToolInvocationPart(part);
|
|
37
|
+
if (!toolInvocation) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const toolCall = (_jsx(ToolCall, { input: toolInvocation.input, priority: priorities.toolCall, strategy: omitStrategy, toolCallId: toolInvocation.toolCallId, toolName: toolInvocation.toolName }));
|
|
41
|
+
if (toolInvocation.output === undefined) {
|
|
42
|
+
return toolCall;
|
|
43
|
+
}
|
|
44
|
+
return [
|
|
45
|
+
toolCall,
|
|
46
|
+
_jsx(ToolResult, { output: toolInvocation.output, priority: priorities.toolResult, strategy: omitStrategy, toolCallId: toolInvocation.toolCallId, toolName: toolInvocation.toolName }),
|
|
47
|
+
];
|
|
48
|
+
}) }));
|
|
49
|
+
}
|
|
50
|
+
function resolvePriorities(priorities) {
|
|
51
|
+
return { ...DEFAULT_PRIORITIES, ...priorities };
|
|
52
|
+
}
|
|
53
|
+
const ROLE_PRIORITY_MAP = {
|
|
54
|
+
system: "system",
|
|
55
|
+
user: "user",
|
|
56
|
+
assistant: "assistant",
|
|
57
|
+
};
|
|
58
|
+
function rolePriority(role, priorities) {
|
|
59
|
+
return priorities[ROLE_PRIORITY_MAP[role]];
|
|
60
|
+
}
|
|
61
|
+
const TOOL_PART_PREFIX = "tool-";
|
|
62
|
+
function isRecord(value) {
|
|
63
|
+
return typeof value === "object" && value !== null;
|
|
64
|
+
}
|
|
65
|
+
function parseToolInvocationPart(part) {
|
|
66
|
+
if (part.type === "dynamic-tool") {
|
|
67
|
+
const output = toolOutputFromPart(part);
|
|
68
|
+
return {
|
|
69
|
+
toolCallId: part.toolCallId,
|
|
70
|
+
toolName: part.toolName,
|
|
71
|
+
input: part.input,
|
|
72
|
+
...(output === undefined ? {} : { output }),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (part.type.startsWith(TOOL_PART_PREFIX)) {
|
|
76
|
+
const toolName = part.type.slice(TOOL_PART_PREFIX.length);
|
|
77
|
+
if (!("toolCallId" in part)) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const toolCallId = part.toolCallId;
|
|
81
|
+
if (typeof toolCallId !== "string") {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const input = "input" in part ? part.input : undefined;
|
|
85
|
+
const output = toolOutputFromPart(part);
|
|
86
|
+
return {
|
|
87
|
+
toolCallId,
|
|
88
|
+
toolName,
|
|
89
|
+
input,
|
|
90
|
+
...(output === undefined ? {} : { output }),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function toolOutputFromPart(part) {
|
|
96
|
+
if (!("state" in part)) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
if (part.state === "output-available") {
|
|
100
|
+
if ("output" in part) {
|
|
101
|
+
return part.output;
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
if (part.state === "output-error") {
|
|
106
|
+
const errorText = "errorText" in part && typeof part.errorText === "string"
|
|
107
|
+
? part.errorText
|
|
108
|
+
: "Tool error";
|
|
109
|
+
return { type: "error-text", value: errorText };
|
|
110
|
+
}
|
|
111
|
+
if (part.state === "output-denied") {
|
|
112
|
+
const reason = deniedReasonFromPart(part);
|
|
113
|
+
return reason
|
|
114
|
+
? { type: "execution-denied", reason }
|
|
115
|
+
: { type: "execution-denied" };
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
function deniedReasonFromPart(part) {
|
|
120
|
+
if (!("approval" in part)) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
const approval = part.approval;
|
|
124
|
+
if (!isRecord(approval)) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
const reason = approval.reason;
|
|
128
|
+
if (typeof reason !== "string") {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
return reason.length === 0 ? undefined : reason;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Renderer that outputs ModelMessage[] for use with the Vercel AI SDK.
|
|
135
|
+
* Pass this to render() to get messages compatible with generateText/streamText.
|
|
136
|
+
*/
|
|
137
|
+
export const renderer = {
|
|
138
|
+
name: "ai-sdk",
|
|
139
|
+
tokenString: markdownRenderer.tokenString,
|
|
140
|
+
render: (element) => renderToModelMessages(element),
|
|
141
|
+
empty: () => [],
|
|
142
|
+
};
|
|
143
|
+
function renderToModelMessages(root) {
|
|
144
|
+
const messageNodes = collectMessageNodes(root);
|
|
145
|
+
const result = [];
|
|
146
|
+
for (const messageNode of messageNodes) {
|
|
147
|
+
result.push(...messageNodeToModelMessages(messageNode));
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
function messageNodeToModelMessages(messageNode) {
|
|
152
|
+
const parts = coalesceTextParts(collectSemanticParts(messageNode.children));
|
|
153
|
+
const groups = groupSemanticParts(parts);
|
|
154
|
+
const result = [];
|
|
155
|
+
for (const group of groups) {
|
|
156
|
+
if (group.kind === "tool-result") {
|
|
157
|
+
result.push(toToolModelMessage(group.parts));
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
result.push(toModelMessage(messageNode.role, group.parts));
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
function groupSemanticParts(parts) {
|
|
165
|
+
const groups = [];
|
|
166
|
+
for (const part of parts) {
|
|
167
|
+
const lastGroup = groups.at(-1);
|
|
168
|
+
if (part.type === "tool-result") {
|
|
169
|
+
if (lastGroup?.kind === "tool-result") {
|
|
170
|
+
lastGroup.parts.push(part);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
groups.push({ kind: "tool-result", parts: [part] });
|
|
174
|
+
}
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (lastGroup?.kind === "non-tool") {
|
|
178
|
+
lastGroup.parts.push(part);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
groups.push({ kind: "non-tool", parts: [part] });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return groups;
|
|
185
|
+
}
|
|
186
|
+
function toModelMessage(role, parts) {
|
|
187
|
+
if (role === "system") {
|
|
188
|
+
return { role: "system", content: partsToText(parts) };
|
|
189
|
+
}
|
|
190
|
+
if (role === "user") {
|
|
191
|
+
return { role: "user", content: partsToText(parts) };
|
|
192
|
+
}
|
|
193
|
+
const content = [];
|
|
194
|
+
for (const part of parts) {
|
|
195
|
+
if (part.type === "text") {
|
|
196
|
+
content.push({ type: "text", text: part.text });
|
|
197
|
+
}
|
|
198
|
+
else if (part.type === "reasoning") {
|
|
199
|
+
content.push({ type: "reasoning", text: part.text });
|
|
200
|
+
}
|
|
201
|
+
else if (part.type === "tool-call") {
|
|
202
|
+
content.push({
|
|
203
|
+
type: "tool-call",
|
|
204
|
+
toolCallId: part.toolCallId,
|
|
205
|
+
toolName: part.toolName,
|
|
206
|
+
input: part.input,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return { role: "assistant", content };
|
|
211
|
+
}
|
|
212
|
+
function toToolModelMessage(parts) {
|
|
213
|
+
const content = [];
|
|
214
|
+
for (const part of parts) {
|
|
215
|
+
content.push({
|
|
216
|
+
type: "tool-result",
|
|
217
|
+
toolCallId: part.toolCallId,
|
|
218
|
+
toolName: part.toolName,
|
|
219
|
+
output: coerceToolResultOutput(part.output),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return { role: "tool", content };
|
|
223
|
+
}
|
|
224
|
+
function coerceToolResultOutput(output) {
|
|
225
|
+
if (typeof output === "string") {
|
|
226
|
+
return { type: "text", value: output };
|
|
227
|
+
}
|
|
228
|
+
if (isToolResultOutput(output)) {
|
|
229
|
+
return output;
|
|
230
|
+
}
|
|
231
|
+
return { type: "json", value: safeJsonValue(output) };
|
|
232
|
+
}
|
|
233
|
+
function isToolResultOutput(value) {
|
|
234
|
+
if (typeof value !== "object" || value === null) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
const output = value;
|
|
238
|
+
if (typeof output.type !== "string") {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
switch (output.type) {
|
|
242
|
+
case "text":
|
|
243
|
+
case "error-text":
|
|
244
|
+
return typeof output.value === "string";
|
|
245
|
+
case "json":
|
|
246
|
+
case "error-json":
|
|
247
|
+
return output.value !== undefined;
|
|
248
|
+
case "execution-denied":
|
|
249
|
+
return output.reason === undefined || typeof output.reason === "string";
|
|
250
|
+
case "content":
|
|
251
|
+
return Array.isArray(output.value);
|
|
252
|
+
default:
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function safeJsonValue(value) {
|
|
257
|
+
if (value === null ||
|
|
258
|
+
typeof value === "string" ||
|
|
259
|
+
typeof value === "number" ||
|
|
260
|
+
typeof value === "boolean") {
|
|
261
|
+
return value;
|
|
262
|
+
}
|
|
263
|
+
if (Array.isArray(value)) {
|
|
264
|
+
return value.map(safeJsonValue);
|
|
265
|
+
}
|
|
266
|
+
if (typeof value === "object") {
|
|
267
|
+
const result = {};
|
|
268
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
269
|
+
result[key] = safeJsonValue(entry);
|
|
270
|
+
}
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
return String(value);
|
|
274
|
+
}
|
|
275
|
+
const VALID_AI_SDK_ROLES = new Set(["user", "assistant", "system"]);
|
|
276
|
+
export function AISDKProvider({ model, tokenizer, children = [], }) {
|
|
277
|
+
const provider = {
|
|
278
|
+
name: "ai-sdk",
|
|
279
|
+
tokenizer: tokenizer ??
|
|
280
|
+
tiktokenTokenizer(model.modelId),
|
|
281
|
+
async completion(request) {
|
|
282
|
+
const messages = request.system
|
|
283
|
+
? [{ role: "system", content: request.system }]
|
|
284
|
+
: [];
|
|
285
|
+
for (const msg of request.messages) {
|
|
286
|
+
if (VALID_AI_SDK_ROLES.has(msg.role)) {
|
|
287
|
+
messages.push({ role: msg.role, content: msg.content });
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
const { text } = await generateText({
|
|
291
|
+
model,
|
|
292
|
+
messages,
|
|
293
|
+
});
|
|
294
|
+
return { text };
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
return {
|
|
298
|
+
priority: 0,
|
|
299
|
+
children: children,
|
|
300
|
+
context: { provider },
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai-sdk/index.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EACL,OAAO,EACP,SAAS,EACT,MAAM,EACN,QAAQ,EACR,UAAU,GACX,MAAM,eAAe,CAAC;AAEv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