Commit 899f6fd
committed
Implement structured responses for guardrails requests
This moves the guardrail response from being a string to being a structured
response. We want to keep non-structured responses in place for Sonnet 4,
but all other models will use them.
There was some discussion about where the schema should live for the structured
response. I initially put it in the private repo, but it's so simple
that we've decided to add it here instead.
It does have a description which described the expected content of the response,
but our code shows that anyway so I don't think it's a problem to have it here.
If we do care about it, then we can transition the response to use the
guardrail names as the enums and then map them using that instead of
integers. But that changes the implementation quite a bit so i'm
leaving it for now.
I've used the system_prompt_structured key to get the system prompt
for the guardrails. This will allow us to:
1. Merge the private repo PR to get access to the structured prompt.
2. Merge this PR.
3. Update the system prompt key for Haiku 4.5 guardrails to use the
structured system prompt.
4. Update Chat to use the system prompt key instead of the structured
system prompt key for non-Sonnet 4.0 requests.
5. Pull out the duplicate structured system prompt since it'll now be
using the system_prompt key.1 parent 2b35fa4 commit 899f6fd
7 files changed
Lines changed: 293 additions & 126 deletions
File tree
- lib/answer_composition/multiple_guardrail
- spec
- lib/answer_composition/multiple_guardrail
- support
- system
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
38 | 60 | | |
39 | 61 | | |
40 | 62 | | |
| |||
67 | 89 | | |
68 | 90 | | |
69 | 91 | | |
70 | | - | |
| 92 | + | |
| 93 | + | |
71 | 94 | | |
72 | 95 | | |
73 | 96 | | |
| |||
96 | 119 | | |
97 | 120 | | |
98 | 121 | | |
99 | | - | |
100 | | - | |
101 | | - | |
| 122 | + | |
102 | 123 | | |
103 | 124 | | |
104 | 125 | | |
105 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
106 | 139 | | |
107 | 140 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
| |||
0 commit comments