Skip to content

Commit 33166e4

Browse files
authored
Prefer toSchema<>() over a literal JSONSchema (commontoolsinc#1797)
1 parent 1232e76 commit 33166e4

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

packages/patterns/chatbot-note.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
recipe,
2222
str,
2323
Stream,
24+
toSchema,
2425
UI,
2526
} from "commontools";
2627

@@ -165,19 +166,13 @@ export default recipe<LLMTestInput, LLMTestResult>(
165166

166167
const mentioned = cell<MentionableCharm[]>([]);
167168

168-
// Must use JSONSchema here, CTS doesn't work correctly. See CT-901
169+
// why does MentionableCharm behave differently than any here?
170+
// perhaps optional properties?
169171
const computeBacklinks = lift(
170-
{
171-
type: "object",
172-
properties: {
173-
allCharms: { type: "array", items: { type: "object" }, asCell: true },
174-
content: { type: "string", asCell: true },
175-
},
176-
} as JSONSchema,
177-
{
178-
type: "array",
179-
items: { type: "object" },
180-
} as JSONSchema,
172+
toSchema<
173+
{ allCharms: Cell<any[]>; content: Cell<string> }
174+
>(),
175+
toSchema<any[]>(),
181176
({ allCharms, content }) => {
182177
const cs: MentionableCharm[] = allCharms.get();
183178
if (!cs) return [];

0 commit comments

Comments
 (0)