File tree 2 files changed +26
-2
lines changed
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -59,15 +59,33 @@ func TestAPI(t *testing.T) {
59
59
Model : GPT3Dot5Turbo ,
60
60
Messages : []ChatCompletionMessage {
61
61
{
62
- Role : "user" ,
62
+ Role : ChatMessageRoleUser ,
63
63
Content : "Hello!" ,
64
64
},
65
65
},
66
66
},
67
67
)
68
68
69
69
if err != nil {
70
- t .Errorf ("CreateChatCompletion returned error: %v" , err )
70
+ t .Errorf ("CreateChatCompletion (without name) returned error: %v" , err )
71
+ }
72
+
73
+ _ , err = c .CreateChatCompletion (
74
+ ctx ,
75
+ ChatCompletionRequest {
76
+ Model : GPT3Dot5Turbo ,
77
+ Messages : []ChatCompletionMessage {
78
+ {
79
+ Role : ChatMessageRoleUser ,
80
+ Name : "John_Doe" ,
81
+ Content : "Hello!" ,
82
+ },
83
+ },
84
+ },
85
+ )
86
+
87
+ if err != nil {
88
+ t .Errorf ("CreateChatCompletion (with name) returned error: %v" , err )
71
89
}
72
90
73
91
stream , err := c .CreateCompletionStream (ctx , CompletionRequest {
Original file line number Diff line number Diff line change 22
22
type ChatCompletionMessage struct {
23
23
Role string `json:"role"`
24
24
Content string `json:"content"`
25
+
26
+ // This property isn't in the official documentation, but it's in
27
+ // the documentation for the official library for python:
28
+ // - https://github.com/openai/openai-python/blob/main/chatml.md
29
+ // - https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb
30
+ Name string `json:"name,omitempty"`
25
31
}
26
32
27
33
// ChatCompletionRequest represents a request structure for chat completion API.
You can’t perform that action at this time.
0 commit comments