-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e2876a
commit ace3205
Showing
9 changed files
with
313 additions
and
149 deletions.
There are no files selected for viewing
149 changes: 41 additions & 108 deletions
149
app/(playground)/p/[agentId]/beta-proto/artifact/schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,50 @@ | ||
import { jsonSchema } from "ai"; | ||
import type { GeneratedObject } from "./types"; | ||
|
||
export const schema = jsonSchema<GeneratedObject>( | ||
{ | ||
type: "object", | ||
properties: { | ||
thinking: { | ||
type: "string", | ||
description: | ||
"How you think about the content of the artefact (purpose, structure, essentials) and how you intend to output it", | ||
}, | ||
artifact: { | ||
type: "object", | ||
properties: { | ||
title: { type: "string", description: "The title of the artefact" }, | ||
content: { | ||
type: "string", | ||
description: "The content of the artefact formatted markdown", | ||
}, | ||
completed: { | ||
type: "boolean", | ||
description: "Whether the artefact is completed", | ||
export const schema = jsonSchema<GeneratedObject>({ | ||
type: "object", | ||
properties: { | ||
thinking: { | ||
type: "string", | ||
description: | ||
"How you think about the content of the artefact (purpose, structure, essentials) and how you intend to output it", | ||
}, | ||
artifact: { | ||
type: "object", | ||
properties: { | ||
title: { type: "string", description: "The title of the artefact" }, | ||
content: { | ||
type: "string", | ||
description: `The content of the artefact formatted markdown.`, | ||
}, | ||
citations: { | ||
type: "array", | ||
items: { | ||
type: "object", | ||
properties: { | ||
title: { | ||
type: "string", | ||
description: "The title of the citation page", | ||
}, | ||
url: { | ||
type: "string", | ||
description: "The URL of the citation page", | ||
}, | ||
}, | ||
}, | ||
}, | ||
required: ["title", "content", "completed"], | ||
}, | ||
description: { | ||
type: "string", | ||
description: | ||
"Explanation of the Artifact and what the intention was in creating this Artifact. Add any suggestions for making it even better.", | ||
completed: { | ||
type: "boolean", | ||
description: "Whether the artefact is completed", | ||
}, | ||
}, | ||
required: ["title", "citations", "content", "completed"], | ||
}, | ||
required: ["thinking", "artifact", "description"], | ||
}, | ||
{ | ||
validate: (value) => { | ||
if (!isObject(value)) { | ||
return { success: false, error: new Error("value must be an object") }; | ||
} | ||
|
||
const { thinking, artifact, description, completed } = value; | ||
|
||
if (!isString(thinking)) { | ||
return { | ||
success: false, | ||
error: new Error("thinking must be a string"), | ||
}; | ||
} | ||
|
||
if (!isObject(artifact)) { | ||
return { | ||
success: false, | ||
error: new Error("artifact must be an object"), | ||
}; | ||
} | ||
|
||
const { title, content } = artifact; | ||
|
||
if (!isString(title)) { | ||
return { | ||
success: false, | ||
error: new Error("artifact.title must be a string"), | ||
}; | ||
} | ||
|
||
if (!isString(content)) { | ||
return { | ||
success: false, | ||
error: new Error("artifact.content must be a string"), | ||
}; | ||
} | ||
|
||
if (!isString(content)) { | ||
return { | ||
success: false, | ||
error: new Error("artifact.content must be a string"), | ||
}; | ||
} | ||
|
||
if (!isBoolean(completed)) { | ||
return { | ||
success: false, | ||
error: new Error("artifact.completed must be a boolean"), | ||
}; | ||
} | ||
|
||
if (description === undefined) { | ||
return { | ||
success: false, | ||
error: new Error("description must be a string if provided"), | ||
}; | ||
} | ||
if (!isString(description)) { | ||
return { | ||
success: false, | ||
error: new Error("description must be a string if provided"), | ||
}; | ||
} | ||
if (!isBoolean(completed)) { | ||
return { | ||
success: false, | ||
error: new Error("artifact.completed must be a boolean"), | ||
}; | ||
} | ||
|
||
return { | ||
success: true, | ||
value: { | ||
thinking, | ||
artifact: { title, content, completed }, | ||
description, | ||
}, | ||
}; | ||
description: { | ||
type: "string", | ||
description: | ||
"Explanation of the Artifact and what the intention was in creating this Artifact. Add any suggestions for making it even better.", | ||
}, | ||
}, | ||
); | ||
required: ["thinking", "artifact", "description"], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.