-
Notifications
You must be signed in to change notification settings - Fork 0
/
ai.go
57 lines (44 loc) · 843 Bytes
/
ai.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
package ai
import (
"context"
"errors"
)
var ErrAIClosed = errors.New("AI client is nil or already closed")
type AI interface {
LLMs() LLMs
Model(context.Context) (string, error)
Limiter
SetModel(string)
Model
Chatbot
ChatSession() ChatSession
Close() error
}
type Model interface {
SetCount(x int64)
SetMaxTokens(x int64)
SetTemperature(x float64)
SetTopP(x float64)
SetJSONResponse(b bool)
}
type Chatbot interface {
Chat(context.Context, ...Part) (ChatResponse, error)
ChatStream(context.Context, ...Part) (ChatStream, error)
}
type ChatSession interface {
Chatbot
History() []Content
}
type ChatStream interface {
Next() (ChatResponse, error)
Close() error
}
type TokenCount struct {
Prompt int64
Result int64
Total int64
}
type ChatResponse interface {
Results() []string
TokenCount() TokenCount
}