-
-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
llm prompt --schema X option and model.prompt(..., schema=) parameter #777
Conversation
I'm going to save schemas in the DB and refer to them from a new That I'm going to try blake2b for this, available in Python since Python 3.6. I can use it to get the same length of ID as MD5 but it's more cryptographically secure (not that it matters here, but I do like avoiding hash functions which trigger security audits like that FIPS thing). >>> hashlib.blake2b(content.encode(), digest_size=16).hexdigest()
'6bc5ba84cec9e6ceff3b65c8828b82b2' |
For the Markdown output I'm going to spot if a prompt had a schema AND the response appears to be valid JSON and pretty-print and fenced-code-block that response. |
Here's example output from
|
When replying to an existing thread with llm -c 'invent three more'
As opposed to: llm -c 'invent three more' --schema "$(cat dogs.schema.json)" {
"dogs": [
{
"bio": "A tiny chihuahua with an enormous ego. Thinks he's a Rottweiler and isn't afraid to take on dogs ten times his size. Has a surprisingly loud bark.",
"name": "Napoleon"
},
{
"bio": "A golden retriever who is obsessed with fetch. Will retrieve anything, anytime, anywhere. Exceptionally friendly and loves children.",
"name": "Buddy"
},
{
"bio": "An old, wise beagle who has seen it all. Spends most of his day sleeping in a sunbeam, but occasionally perks up to share his wisdom (in the form of soulful howls).",
"name": "Socrates"
}
]
} I'm OK with this. |
I think this is good enough to ship as an alpha. I'll add minimal docs and do that. |
Refs:
TODO:
llm logs --json
llm logs
Markdownprompt(..., schema=)
to work (or cancel that feature)