File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 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) {
5959 Model : GPT3Dot5Turbo ,
6060 Messages : []ChatCompletionMessage {
6161 {
62- Role : "user" ,
62+ Role : ChatMessageRoleUser ,
6363 Content : "Hello!" ,
6464 },
6565 },
6666 },
6767 )
6868
6969 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 )
7189 }
7290
7391 stream , err := c .CreateCompletionStream (ctx , CompletionRequest {
Original file line number Diff line number Diff line change 2222type ChatCompletionMessage struct {
2323 Role string `json:"role"`
2424 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"`
2531}
2632
2733// ChatCompletionRequest represents a request structure for chat completion API.
You can’t perform that action at this time.
0 commit comments