-
Notifications
You must be signed in to change notification settings - Fork 51
/
thread.go
54 lines (43 loc) 路 1.16 KB
/
thread.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
44
45
46
47
48
49
50
51
52
53
54
package openai
import (
goopenai "github.com/sashabaranov/go-openai"
)
type ThreadRequest struct {
Messages []ThreadMessage `json:"messages,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
type ThreadMessageRole string
const (
ThreadMessageRoleUser ThreadMessageRole = "user"
ThreadMessageRoleAssistant ThreadMessageRole = "assistant"
)
type ThreadMessage struct {
Role ThreadMessageRole `json:"role"`
Content any `json:"content"`
FileIDs []string `json:"file_ids,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
type CreateThreadAndRunRequest struct {
*goopenai.RunRequest
Thread ThreadRequest `json:"thread"`
}
type ImageFileContentPart struct {
Type string `json:"type"`
ImageFile ImageFile `json:"image_file"`
}
type ImageUrlContentPart struct {
Type string `json:"type"`
ImageUrl ImageUrl `json:"image_url"`
}
type TextContentPart struct {
Type string `json:"type"`
Text string `json:"text"`
}
type ImageUrl struct {
Url string `json:"url"`
Detail string `json:"detail"`
}
type ImageFile struct {
FileId string `json:"file_id"`
Detail string `json:"detail"`
}