-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/mimi: update tool logic, prepare for generic tool interface
Signed-off-by: Xe Iaso <[email protected]>
- Loading branch information
Showing
6 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
You are good at programming and a hacker. Your name is Mimi and you work for Techaro. You have brown hair and cat ears. Don't mention either your name, employer, or species unless you are asked directly. Be polite and bubbly. Do not reply in JSON. Don't end sentences in periods unless you are being serious and use lowercase when possible. | ||
You are good at programming and a hacker. Your name is Mimi and you work for Techaro. You have brown hair and cat ears. Don't mention either your name, employer, or species unless you are asked directly. Be polite and bubbly. Do not reply in JSON. Don't end sentences in periods unless you are being serious and use lowercase when possible. | ||
|
||
If you are asked to draw or illustrate something, use the draw_image tool. | ||
|
||
If you are asked to write python code, run it with code_interpreter. | ||
|
||
If you are asked to draw yourself, use this description: a brown-haired anime woman with a pixie cut, brown eyes, and cat ears |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package tools | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/bwmarrin/discordgo" | ||
"within.website/x/web/ollama" | ||
) | ||
|
||
type replyArgs struct { | ||
Message string `json:"message"` | ||
} | ||
|
||
func (ra replyArgs) Valid() error { | ||
if ra.Message == "" { | ||
return errors.New("tools: replyArgs is invalid: missing message") | ||
} | ||
|
||
return nil | ||
} | ||
|
||
type Reply struct{} | ||
|
||
func (Reply) Execute(ctx context.Context, sess *discordgo.Session, mc *discordgo.MessageCreate, conv []ollama.Message, tc ollama.ToolCall) error { | ||
var args replyArgs | ||
|
||
if err := json.Unmarshal(tc.Arguments, &args); err != nil { | ||
return fmt.Errorf("error parsing reply args: %w", err) | ||
} | ||
|
||
if err := args.Valid(); err != nil { | ||
return err | ||
} | ||
|
||
if _, err := sess.ChannelMessageSend(mc.ChannelID, args.Message, discordgo.WithContext(ctx)); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (Reply) Describe() ollama.Function { | ||
return ollama.Function{ | ||
Name: "reply", | ||
Description: "Reply to the message", | ||
Parameters: ollama.Param{ | ||
Type: "object", | ||
Properties: ollama.Properties{ | ||
"message": { | ||
Type: "string", | ||
Description: "The message to send", | ||
}, | ||
}, | ||
Required: []string{"message"}, | ||
}, | ||
} | ||
} | ||
|
||
var ( | ||
_ Impl = Reply{} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package tools | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/bwmarrin/discordgo" | ||
"within.website/x/web/ollama" | ||
) | ||
|
||
type Impl interface { | ||
Execute(ctx context.Context, sess *discordgo.Session, mc *discordgo.MessageCreate, conv []ollama.Message, tc ollama.ToolCall) error | ||
Describe() ollama.Function | ||
} |