From 1f112259d2ff58bbe25f25f8c65694d5a7569e68 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sun, 1 Mar 2026 07:01:13 +0300 Subject: Enha(tools.todo): always provide whole todo list --- config.example.toml | 1 - config/config.go | 1 - docs/config.md | 3 --- tools.go | 61 +++++++++++++---------------------------------------- 4 files changed, 15 insertions(+), 51 deletions(-) diff --git a/config.example.toml b/config.example.toml index 0c4aa76..8893345 100644 --- a/config.example.toml +++ b/config.example.toml @@ -27,7 +27,6 @@ AutoCleanToolCallsFromCtx = false RAGEnabled = false RAGBatchSize = 1 RAGWordLimit = 80 -RAGWorkers = 2 RAGDir = "ragimport" # extra tts TTS_ENABLED = false diff --git a/config/config.go b/config/config.go index 40f6fca..427edd5 100644 --- a/config/config.go +++ b/config/config.go @@ -39,7 +39,6 @@ type Config struct { // rag settings RAGEnabled bool `toml:"RAGEnabled"` RAGDir string `toml:"RAGDir"` - RAGWorkers uint32 `toml:"RAGWorkers"` RAGBatchSize int `toml:"RAGBatchSize"` RAGWordLimit uint32 `toml:"RAGWordLimit"` // deepseek diff --git a/docs/config.md b/docs/config.md index 57198ea..8f8c497 100644 --- a/docs/config.md +++ b/docs/config.md @@ -80,9 +80,6 @@ This document explains how to set up and configure the application using the `co #### RAGWordLimit (`80`) - Maximum number of words in a batch to tokenize and store. -#### RAGWorkers (`2`) -- Number of concurrent workers for RAG processing. - #### RAGDir (`"ragimport"`) - Directory containing documents for RAG processing. diff --git a/tools.go b/tools.go index e6cabe5..3d98aa2 100644 --- a/tools.go +++ b/tools.go @@ -834,6 +834,14 @@ type TodoList struct { Items []TodoItem `json:"items"` } +func (t TodoList) ToString() string { + sb := strings.Builder{} + for i := range t.Items { + fmt.Fprintf(&sb, "\n[%s] %s. %s\n", t.Items[i].Status, t.Items[i].ID, t.Items[i].Task) + } + return sb.String() +} + // Global todo list storage var globalTodoList = TodoList{ Items: []TodoItem{}, @@ -860,6 +868,7 @@ func todoCreate(args map[string]string) []byte { "id": id, "task": task, "status": "pending", + "todos": globalTodoList.ToString(), } jsonResult, err := json.Marshal(result) if err != nil { @@ -871,38 +880,9 @@ func todoCreate(args map[string]string) []byte { } func todoRead(args map[string]string) []byte { - id, ok := args["id"] - if ok && id != "" { - // Find specific todo by ID - for _, item := range globalTodoList.Items { - if item.ID == id { - result := map[string]interface{}{ - "todo": item, - } - jsonResult, err := json.Marshal(result) - if err != nil { - msg := "failed to marshal result; error: " + err.Error() - logger.Error(msg) - return []byte(msg) - } - return jsonResult - } - } - // ID not found - result := map[string]string{ - "error": fmt.Sprintf("todo with id %s not found", id), - } - jsonResult, err := json.Marshal(result) - if err != nil { - msg := "failed to marshal result; error: " + err.Error() - logger.Error(msg) - return []byte(msg) - } - return jsonResult - } // Return all todos if no ID specified result := map[string]interface{}{ - "todos": globalTodoList.Items, + "todos": globalTodoList.ToString(), } jsonResult, err := json.Marshal(result) if err != nil { @@ -953,6 +933,7 @@ func todoUpdate(args map[string]string) []byte { result := map[string]string{ "message": "todo updated successfully", "id": id, + "todos": globalTodoList.ToString(), } jsonResult, err := json.Marshal(result) if err != nil { @@ -991,6 +972,7 @@ func todoDelete(args map[string]string) []byte { result := map[string]string{ "message": "todo deleted successfully", "id": id, + "todos": globalTodoList.ToString(), } jsonResult, err := json.Marshal(result) if err != nil { @@ -1539,22 +1521,9 @@ var baseTools = []models.Tool{ Name: "todo_update", Description: "Update a todo item by ID with new task or status. Status must be one of: pending, in_progress, completed.", Parameters: models.ToolFuncParams{ - Type: "object", - Required: []string{"id"}, - Properties: map[string]models.ToolArgProps{ - "id": models.ToolArgProps{ - Type: "string", - Description: "id of the todo item to update", - }, - "task": models.ToolArgProps{ - Type: "string", - Description: "new task description (optional)", - }, - "status": models.ToolArgProps{ - Type: "string", - Description: "new status for the todo: pending, in_progress, or completed (optional)", - }, - }, + Type: "object", + Required: []string{}, + Properties: map[string]models.ToolArgProps{}, }, }, }, -- cgit v1.2.3