diff options
| author | Grail Finder <wohilas@gmail.com> | 2025-12-10 12:32:14 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2025-12-10 12:32:14 +0300 |
| commit | 0fc70ae44134b7771d37796f680df359dde72112 (patch) | |
| tree | ce5fbd946f325b19bd481a032624d57355bcaef3 /tools.go | |
| parent | 1cd8317f5186634d2e28bd827f113788714f1999 (diff) | |
Feat: new tool to read from url
Diffstat (limited to 'tools.go')
| -rw-r--r-- | tools.go | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -171,6 +171,30 @@ func websearch(args map[string]string) []byte { return data } +// retrieves url content (text) +func readURL(args map[string]string) []byte { + // make http request return bytes + link, ok := args["url"] + if !ok || link == "" { + msg := "linknot provided to read_url tool" + logger.Error(msg) + return []byte(msg) + } + resp, err := extra.WebSearcher.RetrieveFromLink(context.Background(), link) + if err != nil { + msg := "search tool failed; error: " + err.Error() + logger.Error(msg) + return []byte(msg) + } + data, err := json.Marshal(resp) + if err != nil { + msg := "failed to marshal search result; error: " + err.Error() + logger.Error(msg) + return []byte(msg) + } + return data +} + /* consider cases: - append mode (treat it like a journal appendix) @@ -811,6 +835,7 @@ var fnMap = map[string]fnSig{ "recall_topics": recallTopics, "memorise": memorise, "websearch": websearch, + "read_url": readURL, "file_create": fileCreate, "file_read": fileRead, "file_write": fileWrite, @@ -849,6 +874,24 @@ var baseTools = []models.Tool{ }, }, }, + // read_url + models.Tool{ + Type: "function", + Function: models.ToolFunc{ + Name: "read_url", + Description: "Retrieves text content of given link.", + Parameters: models.ToolFuncParams{ + Type: "object", + Required: []string{"url"}, + Properties: map[string]models.ToolArgProps{ + "url": models.ToolArgProps{ + Type: "string", + Description: "link to the webpage to read text from", + }, + }, + }, + }, + }, // memorise models.Tool{ Type: "function", |
