-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprotocol.go
More file actions
89 lines (73 loc) · 2.13 KB
/
Copy pathprotocol.go
File metadata and controls
89 lines (73 loc) · 2.13 KB
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
package main
import (
"context"
"net/http"
)
const qoderProtocolVersion = "1.1.34"
type credentialCodec interface {
Encrypt(context.Context, string, string) (string, error)
Decrypt(context.Context, string, string) (string, error)
}
type runtimeFieldInput struct {
UID string `json:"uid"`
OrganizationID string `json:"organization_id"`
OrganizationTags []string `json:"organization_tags"`
DataPolicyAgreed bool `json:"data_policy_agreed"`
}
type runtimeFieldOutput struct {
EncryptUserInfo string `json:"encrypt_user_info"`
Key string `json:"key"`
}
type runtimeFieldGenerator interface {
Generate(context.Context, runtimeFieldInput) (runtimeFieldOutput, error)
}
type modelCacheDecryptor interface {
Decrypt(context.Context, string, string) ([]byte, error)
}
type protocolUserInfo struct {
UID string `json:"uid"`
EncryptUserInfo string `json:"encrypt_user_info"`
Key string `json:"key"`
OrganizationID string `json:"organization_id"`
OrganizationTags []string `json:"organization_tags"`
DataPolicyAgreed bool `json:"data_policy_agreed"`
}
type protocolScene struct {
ClientType string `json:"client_type"`
BusinessProduct string `json:"business_product"`
BusinessType string `json:"business_type"`
Scene string `json:"scene"`
}
type protocolContextConfig struct {
MachineID string
Version string
User protocolUserInfo
Scene protocolScene
}
type inferRequestInput struct {
Endpoint string
Body []byte
ModelKey string
ModelSource string
}
type preparedRequest struct {
URL string
Header http.Header
Body []byte
}
type protocolContextFactory interface {
New(context.Context, protocolContextConfig) (protocolContext, error)
}
type protocolContext interface {
PrepareInferRequest(context.Context, inferRequestInput) (*preparedRequest, error)
Close() error
}
func defaultProtocolScene() protocolScene {
return protocolScene{
ClientType: "5",
BusinessProduct: "cli",
BusinessType: "agent",
Scene: "assistant",
}
}
func qoderUserAgent() string { return "qoder/" + qoderProtocolVersion }