-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.go
67 lines (59 loc) · 1.72 KB
/
main.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
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/antgroup/aievo/agent"
"github.com/antgroup/aievo/llm"
"github.com/antgroup/aievo/llm/openai"
"github.com/antgroup/aievo/schema"
"github.com/antgroup/aievo/tool"
"github.com/antgroup/aievo/tool/bash"
"github.com/antgroup/aievo/tool/file"
)
const workspace = "/Users/linhaojun/WorkSpace/aievo/examples/engineer/workspace"
func main() {
client, err := openai.New(
openai.WithToken(os.Getenv("OPENAI_API_KEY")),
openai.WithModel(os.Getenv("OPENAI_MODEL")),
openai.WithBaseURL(os.Getenv("OPENAI_BASE_URL")))
if err != nil {
log.Fatal(err)
}
// 文件创建 文件读取 文件修改 文件删除 文件重命名
// 文件夹创建 文件夹读取 文件夹删除 文件夹重命名
fileTools, _ := file.GetFileRelatedTools(workspace)
// 命令执行
bashTool, _ := bash.New()
callbackHandler := &CallbackHandler{}
engineerTools := make([]tool.Tool, 0)
engineerTools = append(engineerTools, fileTools...)
engineerTools = append(engineerTools, bashTool)
engineer, err := agent.NewBaseAgent(
agent.WithName("engineer"),
agent.WithDesc(EngineerDescription),
agent.WithPrompt(EngineerPrompt),
agent.WithInstruction(SingleAgentInstructions),
agent.WithVars("sop", Workflow),
agent.WithVars("workspace", workspace),
agent.WithTools(engineerTools),
agent.WithLLM(client),
agent.WithCallback(callbackHandler),
)
if err != nil {
log.Fatal(err)
}
gen, err := engineer.Run(context.Background(), []schema.Message{
{
Type: schema.MsgTypeMsg,
Content: "使用pyqt写一个贪吃蛇",
Sender: "User",
Receiver: "engineer",
},
}, llm.WithTemperature(0.1))
if err != nil {
log.Fatal(err)
}
fmt.Println(gen.Messages[0].Content)
}