forked from sashabaranov/go-openai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
messagesv2.go
43 lines (35 loc) · 1.03 KB
/
messagesv2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package openai
import (
"context"
"fmt"
"net/http"
)
type ImageFileV2 struct {
FileID string `json:"file_id"`
Detail string `json:"detail,omitempty"`
}
type ImageURLV2 struct {
URL string `json:"url"`
Detail string `json:"detail,omitempty"`
}
type MessageContentV2 struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageFile *ImageFileV2 `json:"image_file,omitempty"`
ImageURL *ImageURLV2 `json:"image_url,omitempty"`
}
type MessageRequestV2 struct {
Role string `json:"role"`
Content []MessageContentV2 `json:"content"`
}
// CreateMessageV2 creates a new message.
func (c *Client) CreateMessageV2(ctx context.Context, threadID string, request MessageRequestV2) (msg Message, err error) {
urlSuffix := fmt.Sprintf("/threads/%s/%s", threadID, messagesSuffix)
req, err := c.newRequest(ctx, http.MethodPost, c.fullURL(urlSuffix), withBody(request),
withBetaAssistantVersion(c.config.AssistantVersion))
if err != nil {
return
}
err = c.sendRequest(req, &msg)
return
}