-
Notifications
You must be signed in to change notification settings - Fork 5
/
plugin.go
43 lines (31 loc) · 898 Bytes
/
plugin.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
package llmplugin
import "context"
type Plugin interface {
Do(ctx context.Context, query string) (answer string, err error)
GetName() string
GetInputExample() string
GetDesc() string
}
var _ Plugin = (*SimplePlugin)(nil)
type SimplePlugin struct {
// Name of plugin.
Name string
// InputExample is the example of input.
InputExample string
// Desc is the description of plugin for LLM to understand what is the plugin and what for.
Desc string
// DoFunc is the handle function of plugin.
DoFunc func(ctx context.Context, query string) (answer string, err error)
}
func (p SimplePlugin) GetName() string {
return p.Name
}
func (p SimplePlugin) GetInputExample() string {
return p.InputExample
}
func (p SimplePlugin) GetDesc() string {
return p.Desc
}
func (p SimplePlugin) Do(ctx context.Context, query string) (answer string, err error) {
return p.DoFunc(ctx, query)
}