summaryrefslogtreecommitdiff
path: root/tools.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-03-01 08:22:02 +0300
committerGrail Finder <wohilas@gmail.com>2026-03-01 08:22:02 +0300
commitcdfccf9a2440dc4d8094e7ae94aa85cb446e7cfb (patch)
tree43658a89dd2fbd89106cf58c6a4a48792f4f97ac /tools.go
parent1f112259d2ff58bbe25f25f8c65694d5a7569e68 (diff)
Enha (llama.cpp): show loaded model on startup
Diffstat (limited to 'tools.go')
-rw-r--r--tools.go8
1 files changed, 0 insertions, 8 deletions
diff --git a/tools.go b/tools.go
index 3d98aa2..6686f35 100644
--- a/tools.go
+++ b/tools.go
@@ -519,21 +519,17 @@ func fileEdit(args map[string]string) []byte {
return []byte(msg)
}
path = resolvePath(path)
-
oldString, ok := args["oldString"]
if !ok || oldString == "" {
msg := "oldString not provided to file_edit tool"
logger.Error(msg)
return []byte(msg)
}
-
newString, ok := args["newString"]
if !ok {
newString = ""
}
-
lineNumberStr, hasLineNumber := args["lineNumber"]
-
// Read file content
content, err := os.ReadFile(path)
if err != nil {
@@ -541,10 +537,8 @@ func fileEdit(args map[string]string) []byte {
logger.Error(msg)
return []byte(msg)
}
-
fileContent := string(content)
var replacementCount int
-
if hasLineNumber && lineNumberStr != "" {
// Line-number based edit
lineNum, err := strconv.Atoi(lineNumberStr)
@@ -579,13 +573,11 @@ func fileEdit(args map[string]string) []byte {
fileContent = strings.ReplaceAll(fileContent, oldString, newString)
replacementCount = strings.Count(fileContent, newString)
}
-
if err := os.WriteFile(path, []byte(fileContent), 0644); err != nil {
msg := "failed to write file: " + err.Error()
logger.Error(msg)
return []byte(msg)
}
-
msg := fmt.Sprintf("file edited successfully at %s (%d replacement(s))", path, replacementCount)
return []byte(msg)
}