-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.go
73 lines (60 loc) · 1.56 KB
/
model.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
package main
import (
"net/http"
"time"
)
type TrackedResult struct {
Timestamp int64 `json:"timestamp"`
IP string `json:"ip"`
UserAgent string `json:"user_agent"`
Message string `json:"message"`
Header http.Header `json:"header"`
}
// TrackedRequest 存储请求的相关信息
type TrackedRequest struct {
Timestamp time.Time
Image []byte
Finished bool
Results []*TrackedResult
Response string
}
// OpenAIRequest 结构体用于构造发送到 OpenAI 的请求
type OpenAIRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens int `json:"max_tokens"`
Stream bool `json:"stream"`
}
type Message struct {
Role string `json:"role"`
Content []Content `json:"content"`
}
type Content struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageURL *ImageURL `json:"image_url,omitempty"`
}
type ImageURL struct {
URL string `json:"url"`
}
type StartRequest struct {
URL string `json:"url"`
Key string `json:"key"`
Model string `json:"model"`
}
type APIResponse[T any] struct {
Code int `json:"code"`
Message string `json:"message,omitempty"`
Data T `json:"data,omitempty"`
}
type StartInfo struct {
ID string `json:"id"`
Image string `json:"image"`
}
type StartResponse APIResponse[*StartInfo]
type DetectResult struct {
Finished bool `json:"finished"`
Results []*TrackedResult `json:"results"`
}
type ResultResponse APIResponse[*DetectResult]
type TargetResponse APIResponse[string]