@@ -32,7 +32,7 @@ D SELECT open_prompt('Write a one-line poem about ducks') AS response;
32
32
```
33
33
34
34
#### 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
36
36
37
37
``` sql
38
38
SET VARIABLE openprompt_api_url = ' http://localhost:11434/v1/chat/completions' ;
@@ -50,32 +50,24 @@ SELECT open_prompt('I want ice cream', json_schema := '{
50
50
}' );
51
51
```
52
52
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
54
54
55
55
``` 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
+ }' );
75
68
```
76
69
77
70
78
-
79
71
<br >
80
72
81
73
<img src =" https://github.com/user-attachments/assets/824bfab2-aca6-4bd9-8a4a-bc01901fcd5b " width =100 />
0 commit comments