@@ -32,7 +32,7 @@ D SELECT open_prompt('Write a one-line poem about ducks') AS response;
3232```
3333
3434#### JSON Structured Output
35- For supported models you can request structured JSON output by providing a schema.
35+ For supported models you can request structured JSON output by providing a schema
3636
3737``` sql
3838SET VARIABLE openprompt_api_url = ' http://localhost:11434/v1/chat/completions' ;
@@ -50,32 +50,24 @@ SELECT open_prompt('I want ice cream', json_schema := '{
5050 }' );
5151```
5252
53- For smaller models, the ` system_prompt ` can be used to request JSON in _ best-effort_ mode
53+ For smaller models the ` system_prompt ` can be used to request JSON schema in _ best-effort_ mode
5454
5555``` sql
56- SELECT open_prompt(' I want ice cream' , system_prompt := ' {
57- "type": "object",
58- "properties": {
59- "summary": { "type": "string" },
60- "favourite_animals": { "type": "array" },
61- "favourite_activity": { "type": "aray" },
62- "star_rating": { "type": "number" }
63- },
64- "struct_descr": {"star_rating": "rating on a scale from 1 (bad) to 5 (best)"}
65- ' );
66-
67- D SELECT open_prompt(' My zoo visit was fun and I loved the bears and tigers. i also had icecream' ) AS response;
68- ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
69- │ response │
70- │ varchar │
71- ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
72- │ {" summary" : " A short summary of your recent zoo visit activity." , " favourite_animals" : [" bears" , " tigers" ], " favourite_activity" : [" icecream" ], " star … │
73- └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
74-
56+ SET VARIABLE openprompt_api_url = ' http://localhost:11434/v1/chat/completions' ;
57+ SET VARIABLE openprompt_api_token = ' your_api_key_here' ;
58+ SET VARIABLE openprompt_model_name = ' qwen2.5:1.5b' ;
59+ SELECT open_prompt(' I want ice cream.' , system_prompt:= ' The respose MUST be a JSON with the following schema: {
60+ "type": "object",
61+ "properties": {
62+ "summary": { "type": "string" },
63+ "sentiment": { "type": "string", "enum": ["pos", "neg", "neutral"] }
64+ },
65+ "required": ["summary", "sentiment"],
66+ "additionalProperties": false
67+ }' );
7568```
7669
7770
78-
7971<br >
8072
8173<img src =" https://github.com/user-attachments/assets/824bfab2-aca6-4bd9-8a4a-bc01901fcd5b " width =100 />
0 commit comments