This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
claude.go
118 lines (103 loc) · 3.04 KB
/
claude.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package model
import "time"
type ChatMessageRequest struct {
Completion *Completion `json:"completion"`
OrganizationUuid string `json:"organization_uuid"`
ConversationUuid string `json:"conversation_uuid"`
Text string `json:"text"`
Attachments []Attachments `json:"attachments"`
}
type ChatMessageResponse struct {
Completion string `json:"completion"`
StopReason string `json:"stop_reason"`
Model string `json:"model"`
Stop string `json:"stop"`
LogId string `json:"log_id"`
MessageLimit MessageLimit `json:"messageLimit"`
}
type MessageLimit struct {
Type string `json:"type"`
}
func NewChatMessageRequest(text, history string) *ChatMessageRequest {
var attachments []Attachments
if history != "" {
attachments = append(attachments, Attachments{
FileName: "paste.txt",
FileType: "txt",
FileSize: uint(len(history)),
ExtractedContent: history,
})
}
return &ChatMessageRequest{
Completion: NewCompletion(text),
OrganizationUuid: "",
ConversationUuid: "",
Text: text,
Attachments: attachments,
}
}
type Completion struct {
Prompt string `json:"prompt"`
Timezone string `json:"timezone"`
Model string `json:"model"`
Incremental bool `json:"incremental"`
}
func NewCompletion(prompt string) *Completion {
return &Completion{
Prompt: prompt,
Timezone: "Asia/Shanghai",
Model: "claude-2",
Incremental: true,
}
}
type Attachments struct {
FileName string `json:"file_name"`
FileType string `json:"file_type"`
FileSize uint `json:"file_size"`
ExtractedContent string `json:"extracted_content"`
}
type ChatConversationRequest struct {
Uuid string `json:"uuid"`
Name string `json:"name"`
}
func NewChatConversationRequest(uuid, name string) *ChatConversationRequest {
return &ChatConversationRequest{
uuid,
name,
}
}
type ChatConversationResponse struct {
Uuid string `json:"uuid"`
Name string `json:"name"`
Summary string `json:"summary"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
type OrganizationsResponse struct {
Uuid string `json:"uuid"`
Name string `json:"name"`
Settings Settings `json:"settings"`
Capabilities []string `json:"capabilities"`
JoinToken string `json:"join_token"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ActiveFlags []ActiveFlag `json:"active_flags"`
}
type ActiveFlag struct {
Id string `json:"id"`
Type string `json:"type"`
CreatedAt time.Time `json:"created_at"`
DismissedAt time.Time `json:"dismissed_at"`
ExpiresAt time.Time `json:"expires_at"`
}
type Settings struct {
ClaudeConsolePrivacy string `json:"claude_console_privacy"`
}
type ErrorResponse struct {
Error Error `json:"error"`
Detail string `json:"detail"`
}
type Error struct {
Type string `json:"type"`
Message string `json:"message"`
}