Skip to content

Commit 1153eb2

Browse files
authored
Add support for azure openai new version API (2023-07-01-preview) (#451)
1 parent 1876e0c commit 1153eb2

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

chat.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,35 @@ var (
2121
ErrChatCompletionStreamNotSupported = errors.New("streaming is not supported with this method, please use CreateChatCompletionStream") //nolint:lll
2222
)
2323

24+
type Hate struct {
25+
Filtered bool `json:"filtered"`
26+
Severity string `json:"severity,omitempty"`
27+
}
28+
type SelfHarm struct {
29+
Filtered bool `json:"filtered"`
30+
Severity string `json:"severity,omitempty"`
31+
}
32+
type Sexual struct {
33+
Filtered bool `json:"filtered"`
34+
Severity string `json:"severity,omitempty"`
35+
}
36+
type Violence struct {
37+
Filtered bool `json:"filtered"`
38+
Severity string `json:"severity,omitempty"`
39+
}
40+
41+
type ContentFilterResults struct {
42+
Hate Hate `json:"hate,omitempty"`
43+
SelfHarm SelfHarm `json:"self_harm,omitempty"`
44+
Sexual Sexual `json:"sexual,omitempty"`
45+
Violence Violence `json:"violence,omitempty"`
46+
}
47+
48+
type PromptAnnotation struct {
49+
PromptIndex int `json:"prompt_index,omitempty"`
50+
ContentFilterResults ContentFilterResults `json:"content_filter_results,omitempty"`
51+
}
52+
2453
type ChatCompletionMessage struct {
2554
Role string `json:"role"`
2655
Content string `json:"content"`

chat_stream.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@ type ChatCompletionStreamChoiceDelta struct {
1212
}
1313

1414
type ChatCompletionStreamChoice struct {
15-
Index int `json:"index"`
16-
Delta ChatCompletionStreamChoiceDelta `json:"delta"`
17-
FinishReason FinishReason `json:"finish_reason"`
15+
Index int `json:"index"`
16+
Delta ChatCompletionStreamChoiceDelta `json:"delta"`
17+
FinishReason FinishReason `json:"finish_reason"`
18+
ContentFilterResults ContentFilterResults `json:"content_filter_results,omitempty"`
1819
}
1920

2021
type ChatCompletionStreamResponse struct {
21-
ID string `json:"id"`
22-
Object string `json:"object"`
23-
Created int64 `json:"created"`
24-
Model string `json:"model"`
25-
Choices []ChatCompletionStreamChoice `json:"choices"`
22+
ID string `json:"id"`
23+
Object string `json:"object"`
24+
Created int64 `json:"created"`
25+
Model string `json:"model"`
26+
Choices []ChatCompletionStreamChoice `json:"choices"`
27+
PromptAnnotations []PromptAnnotation `json:"prompt_annotations,omitempty"`
2628
}
2729

2830
// ChatCompletionStream

0 commit comments

Comments
 (0)