website
website copied to clipboard
add info segment about json schema validation of default values
Type
- [ ] Refactor
- [ ] Feature
- [ ] Bug Fix
- [ ] Optimization
- [x] Documentation Update
Description
This really caught me off guard when using @effect/ai when adding a filter to my schema reduced the quality of my results by quite a bit because I unknowingly removed all examples values being sent to the LLM, especially since while this behaviour makes sense it differs from inspecting examples on the AST
import { JSONSchema, Schema } from "effect"
const schema = Schema.Trim.pipe(Schema.annotations({
description: "my custom description",
title: "my custom title",
default: "",
examples: ["a", " b", "c"]
}))
console.log(schema.ast.annotations)
/*
...
{
[Symbol(effect/annotation/Title)]: 'my custom title',
[Symbol(effect/annotation/Description)]: 'my custom description',
[Symbol(effect/annotation/Examples)]: [ 'a', ' b', 'c' ],
[Symbol(effect/annotation/Default)]: ''
}
...
*/
const jsonSchema = JSONSchema.make(schema)
console.log(jsonSchema)
/*
...
{
'$schema': 'http://json-schema.org/draft-07/schema#',
type: 'string',
description: 'my custom description',
title: 'my custom title',
default: '',
examples: [ 'a', 'c' ]
}
...
*/
Related
- Related Issue #
- Closes #
@janglad is attempting to deploy a commit to the Effect Team on Vercel.
A member of the Team first needs to authorize it.