Enha: /chat /completions tool calls to live in peace
This commit is contained in:
20
tools.go
20
tools.go
@@ -46,7 +46,7 @@ To make a function call return a json object within __tool_call__ tags;
|
||||
__tool_call__
|
||||
{
|
||||
"name":"recall",
|
||||
"args": ["Adam's number"]
|
||||
"args": {"topic": "Adam's number"}
|
||||
}
|
||||
__tool_call__
|
||||
</example_request>
|
||||
@@ -84,7 +84,7 @@ also:
|
||||
- some writing can be done without consideration of previous data;
|
||||
- others do;
|
||||
*/
|
||||
func memorise(args ...string) []byte {
|
||||
func memorise(args map[string]string) []byte {
|
||||
agent := cfg.AssistantRole
|
||||
if len(args) < 2 {
|
||||
msg := "not enough args to call memorise tool; need topic and data to remember"
|
||||
@@ -93,35 +93,35 @@ func memorise(args ...string) []byte {
|
||||
}
|
||||
memory := &models.Memory{
|
||||
Agent: agent,
|
||||
Topic: args[0],
|
||||
Mind: args[1],
|
||||
Topic: args["topic"],
|
||||
Mind: args["data"],
|
||||
UpdatedAt: time.Now(),
|
||||
}
|
||||
if _, err := store.Memorise(memory); err != nil {
|
||||
logger.Error("failed to save memory", "err", err, "memoory", memory)
|
||||
return []byte("failed to save info")
|
||||
}
|
||||
msg := "info saved under the topic:" + args[0]
|
||||
msg := "info saved under the topic:" + args["topic"]
|
||||
return []byte(msg)
|
||||
}
|
||||
|
||||
func recall(args ...string) []byte {
|
||||
func recall(args map[string]string) []byte {
|
||||
agent := cfg.AssistantRole
|
||||
if len(args) < 1 {
|
||||
logger.Warn("not enough args to call recall tool")
|
||||
return nil
|
||||
}
|
||||
mind, err := store.Recall(agent, args[0])
|
||||
mind, err := store.Recall(agent, args["topic"])
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("failed to recall; error: %v; args: %v", err, args)
|
||||
logger.Error(msg)
|
||||
return []byte(msg)
|
||||
}
|
||||
answer := fmt.Sprintf("under the topic: %s is stored:\n%s", args[0], mind)
|
||||
answer := fmt.Sprintf("under the topic: %s is stored:\n%s", args["topic"], mind)
|
||||
return []byte(answer)
|
||||
}
|
||||
|
||||
func recallTopics(args ...string) []byte {
|
||||
func recallTopics(args map[string]string) []byte {
|
||||
agent := cfg.AssistantRole
|
||||
topics, err := store.RecallTopics(agent)
|
||||
if err != nil {
|
||||
@@ -134,7 +134,7 @@ func recallTopics(args ...string) []byte {
|
||||
|
||||
// func fullMemoryLoad() {}
|
||||
|
||||
type fnSig func(...string) []byte
|
||||
type fnSig func(map[string]string) []byte
|
||||
|
||||
var fnMap = map[string]fnSig{
|
||||
"recall": recall,
|
||||
|
||||
Reference in New Issue
Block a user