Skip to content

Commit 7c145eb

Browse files
add jailbreak filter result, add ContentFilterResults on output (sashabaranov#864)
* add jailbreak filter result * add content filter results on completion output * add profanity content filter
1 parent bac7d59 commit 7c145eb

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

chat.go

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,23 @@ type Violence struct {
4141
Severity string `json:"severity,omitempty"`
4242
}
4343

44+
type JailBreak struct {
45+
Filtered bool `json:"filtered"`
46+
Detected bool `json:"detected"`
47+
}
48+
49+
type Profanity struct {
50+
Filtered bool `json:"filtered"`
51+
Detected bool `json:"detected"`
52+
}
53+
4454
type ContentFilterResults struct {
45-
Hate Hate `json:"hate,omitempty"`
46-
SelfHarm SelfHarm `json:"self_harm,omitempty"`
47-
Sexual Sexual `json:"sexual,omitempty"`
48-
Violence Violence `json:"violence,omitempty"`
55+
Hate Hate `json:"hate,omitempty"`
56+
SelfHarm SelfHarm `json:"self_harm,omitempty"`
57+
Sexual Sexual `json:"sexual,omitempty"`
58+
Violence Violence `json:"violence,omitempty"`
59+
JailBreak JailBreak `json:"jailbreak,omitempty"`
60+
Profanity Profanity `json:"profanity,omitempty"`
4961
}
5062

5163
type PromptAnnotation struct {
@@ -338,19 +350,21 @@ type ChatCompletionChoice struct {
338350
// function_call: The model decided to call a function
339351
// content_filter: Omitted content due to a flag from our content filters
340352
// null: API response still in progress or incomplete
341-
FinishReason FinishReason `json:"finish_reason"`
342-
LogProbs *LogProbs `json:"logprobs,omitempty"`
353+
FinishReason FinishReason `json:"finish_reason"`
354+
LogProbs *LogProbs `json:"logprobs,omitempty"`
355+
ContentFilterResults ContentFilterResults `json:"content_filter_results,omitempty"`
343356
}
344357

345358
// ChatCompletionResponse represents a response structure for chat completion API.
346359
type ChatCompletionResponse struct {
347-
ID string `json:"id"`
348-
Object string `json:"object"`
349-
Created int64 `json:"created"`
350-
Model string `json:"model"`
351-
Choices []ChatCompletionChoice `json:"choices"`
352-
Usage Usage `json:"usage"`
353-
SystemFingerprint string `json:"system_fingerprint"`
360+
ID string `json:"id"`
361+
Object string `json:"object"`
362+
Created int64 `json:"created"`
363+
Model string `json:"model"`
364+
Choices []ChatCompletionChoice `json:"choices"`
365+
Usage Usage `json:"usage"`
366+
SystemFingerprint string `json:"system_fingerprint"`
367+
PromptFilterResults []PromptFilterResult `json:"prompt_filter_results,omitempty"`
354368

355369
httpHeader
356370
}

0 commit comments

Comments
 (0)