Skip to content

Commit ede87ab

Browse files
committed
feat(chat): agent remove default prompot
1 parent bd170ab commit ede87ab

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

chat/agent.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import (
2525
"github.com/wdvxdr1123/ZeroBot/message"
2626
)
2727

28-
// agentChar 将 char.yaml 内容嵌入为默认 agent 性格
28+
// agentchar 将 char.yaml 内容嵌入为默认 agent 性格
2929
//
3030
//go:embed char.yaml
31-
var agentChar []byte
31+
var agentchar []byte
3232

3333
var agentcharcfg charcfg
3434

@@ -38,13 +38,12 @@ var AgentCharConfig *goba.Config
3838
var ags = syncx.Map[int64, *goba.Agent]{}
3939

4040
type charcfg struct {
41-
Sex string `yaml:"sex"`
42-
Char string `yaml:"char"`
43-
Default string `yaml:"default"`
41+
Sex string `yaml:"sex"`
42+
Char string `yaml:"char"`
4443
}
4544

4645
func init() {
47-
err := yaml.NewDecoder(bytes.NewReader(agentChar)).Decode(&agentcharcfg)
46+
err := yaml.NewDecoder(bytes.NewReader(agentchar)).Decode(&agentcharcfg)
4847
if err != nil {
4948
panic(err)
5049
}
@@ -60,12 +59,11 @@ func AgentOf(id int64, service string) *goba.Agent {
6059
if ag, ok := ags.Load(id); ok {
6160
return ag
6261
}
63-
6462
mem, err := atomicgetmemstorage(service)
6563
if err != nil {
6664
panic(err)
6765
}
68-
ag := goba.NewAgent(AgentCharConfig, 16, 8, time.Hour*24, agentcharcfg.Default, mem, true, false)
66+
ag := goba.NewAgent(AgentCharConfig, 16, 8, time.Hour*24, "", mem, true, false)
6967
ags.Store(id, &ag)
7068
return &ag
7169
}

chat/cfg.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ type AgentConfig struct {
101101
TopP float32
102102
SystemP string
103103
AgentChar string
104+
AgentSex string
104105
API string
105106
ImageAPI string
106107
AgentAPI string
@@ -132,6 +133,7 @@ func (c *AgentConfig) String() string {
132133
sb.WriteString(fmt.Sprintf("• TopP:%.1f\n", topp))
133134
sb.WriteString(fmt.Sprintf("• 系统提示词:%s\n", c.SystemP))
134135
sb.WriteString(fmt.Sprintf("• Agent性格:%s\n", c.AgentChar))
136+
sb.WriteString(fmt.Sprintf("• Agent性别:%s\n", c.AgentSex))
135137
sb.WriteString(fmt.Sprintf("• 接口地址:%s\n", c.API))
136138
sb.WriteString(fmt.Sprintf("• 图像接口地址:%s\n", c.ImageAPI))
137139
sb.WriteString(fmt.Sprintf("• Agent接口地址:%s\n", c.AgentAPI))
@@ -180,6 +182,12 @@ func EnsureConfig(ctx *zero.Ctx) bool {
180182
AC = newconfig()
181183
}
182184
}
185+
if AgentCharConfig.Sex != AC.AgentSex {
186+
AC.AgentSex = AgentCharConfig.Sex
187+
}
188+
if AgentCharConfig.Chars != AC.AgentChar {
189+
AC.AgentChar = AgentCharConfig.Chars
190+
}
183191
return true
184192
}
185193

chat/char.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ char: |
88
- 外貌: 粉蓝渐变单马尾
99
- 性格: 青春可爱,甜美傲娇
1010
- 着装: JK制服、白色花边短袜和黑色厚底玛丽珍鞋。
11-
default: ""

0 commit comments

Comments
 (0)