add: more tools, fix prompt
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"os/signal"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
@@ -21,6 +20,7 @@ import (
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/logs"
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/rcon"
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/tools"
|
||||
timetool "tipsy.codes/charles/mc-god/v2/internal/pkg/tools/time"
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/tools/weather"
|
||||
"tipsy.codes/charles/mc-god/v2/internal/pkg/tools/zombie"
|
||||
)
|
||||
@@ -66,7 +66,7 @@ func (c *chatContext) AddTool(msg string) {
|
||||
func (c *chatContext) truncate() {
|
||||
for c.maxSize != 0 && c.totalSize > c.maxSize && len(c.chatRequest.Messages) > 1 {
|
||||
t := c.chatRequest.Messages[1]
|
||||
c.chatRequest.Messages = c.chatRequest.Messages[2:]
|
||||
c.chatRequest.Messages = append(c.chatRequest.Messages[:1], c.chatRequest.Messages[2:]...)
|
||||
c.totalSize -= len(t.Content)
|
||||
}
|
||||
}
|
||||
@@ -137,11 +137,12 @@ func main() {
|
||||
tools := tools.New(
|
||||
weather.Get(),
|
||||
zombie.Get(),
|
||||
timetool.Get(),
|
||||
)
|
||||
|
||||
// Start goroutines to do the things
|
||||
chatRequest := &api.ChatRequest{
|
||||
Model: "qwen3-coder",
|
||||
Model: "charles1:latest",
|
||||
Stream: proto.Bool(false),
|
||||
KeepAlive: &api.Duration{Duration: time.Hour},
|
||||
Tools: tools.AsAPI(),
|
||||
@@ -151,16 +152,19 @@ func main() {
|
||||
api.Message{
|
||||
Role: "system",
|
||||
Content: `
|
||||
You are Minecraft server admin with a god complex. You are a benevolent god.
|
||||
You are Minecraft server admin with a god complex. You are an impish god.
|
||||
Refer to yourself as Eve. Feel free to flirt with the players.
|
||||
|
||||
We are having fun with the players, but not trying to kill them.
|
||||
Spawn zombies very sparingly, and only in response to direct challenge.
|
||||
|
||||
When a user talks, you will see this in the logs:
|
||||
You are being fed logs from the server so you can see what the players are saying.
|
||||
|
||||
When a player talks, you will see this in the logs:
|
||||
|
||||
[18:45:10] [Server thread/INFO]: <SomePlayer> hello world.
|
||||
|
||||
The user here is SomePlayer, who said "hello world."
|
||||
The player here is SomePlayer, who said "hello world."
|
||||
|
||||
A log message like:
|
||||
|
||||
@@ -181,14 +185,23 @@ func main() {
|
||||
|
||||
[05:21:51] [Server thread/INFO]: OrangeYouSad was slain by Zombie
|
||||
|
||||
You will see messages in the log that represent what you said or did.
|
||||
Ignore these logs. Some samples of the logs that are caused by you are:
|
||||
|
||||
[23:40:44] [Server thread/INFO]: [Not Secure] [Rcon] A name, darling? Don't keep me waiting!
|
||||
[23:35:20] [Server thread/INFO]: [Rcon: Set the weather to rain & thunder]
|
||||
|
||||
If a player dies, mock them.
|
||||
|
||||
If a player talks, talk back.
|
||||
If a player talks, respond to them. Don't let the conversation end.
|
||||
|
||||
When a player joins the game, greet them. Include their name.
|
||||
|
||||
Responses should be short; one sentence. Only write messages
|
||||
in response to the situations described above.
|
||||
If a player asks you to summon a zombie. do it.
|
||||
|
||||
Responses should be short; one or two sentences.
|
||||
You are sending chat messages; do not annotate them with time or
|
||||
make it look like a log entry.
|
||||
If there is nothing interesting to say, say "SKIP".
|
||||
`,
|
||||
},
|
||||
@@ -204,13 +217,13 @@ func main() {
|
||||
doneWg := sync.WaitGroup{}
|
||||
doneWg.Go(handleOllama(ctx, ollamaClient, chat, rClient, tools, events))
|
||||
|
||||
rconRegex := regexp.MustCompile(`^\[\d\d:\d\d:\d\d\] \[Server thread\/INFO\]: (\[Not Secure\] \[Rcon\]|\[Rcon: ) .*`)
|
||||
//rconRegex := regexp.MustCompile(`^\[\d\d:\d\d:\d\d\] \[Server thread\/INFO\]: (\[Not Secure\] \[Rcon\]|\[Rcon: ) .*`)
|
||||
//allowedMessages := regexp.MustCompile(`^\[\d\d:\d\d:\d\d\] \[Server thread/INFO\]: (<.*>|.* has lost connection|.*left the game|.*joined the game)`)
|
||||
for line := range tailer.NextLine() {
|
||||
if rconRegex.Match([]byte(line)) {
|
||||
slog.Info("Skipping line; RCON")
|
||||
continue
|
||||
}
|
||||
/*if rconRegex.Match([]byte(line)) {
|
||||
slog.Info("Skipping line; RCON")
|
||||
continue
|
||||
}*/
|
||||
//if allowedMessages.Match([]byte(line)) {
|
||||
slog.Info("mc log", "msg", line)
|
||||
chat.AddLog(line)
|
||||
|
||||
Reference in New Issue
Block a user