mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
fix: path prompt
This commit is contained in:
@@ -51,6 +51,13 @@ class Ls(BaseTool):
|
|||||||
absolute_path = self._resolve_path(path)
|
absolute_path = self._resolve_path(path)
|
||||||
|
|
||||||
if not os.path.exists(absolute_path):
|
if not os.path.exists(absolute_path):
|
||||||
|
# Provide helpful hint if using relative path
|
||||||
|
if not os.path.isabs(path) and not path.startswith('~'):
|
||||||
|
return ToolResult.fail(
|
||||||
|
f"Error: Path not found: {path}\n"
|
||||||
|
f"Resolved to: {absolute_path}\n"
|
||||||
|
f"Hint: If accessing files outside workspace ({self.cwd}), use absolute path like ~/{path} or /full/path/{path}"
|
||||||
|
)
|
||||||
return ToolResult.fail(f"Error: Path not found: {path}")
|
return ToolResult.fail(f"Error: Path not found: {path}")
|
||||||
|
|
||||||
if not os.path.isdir(absolute_path):
|
if not os.path.isdir(absolute_path):
|
||||||
|
|||||||
@@ -63,6 +63,13 @@ class Read(BaseTool):
|
|||||||
|
|
||||||
# Check if file exists
|
# Check if file exists
|
||||||
if not os.path.exists(absolute_path):
|
if not os.path.exists(absolute_path):
|
||||||
|
# Provide helpful hint if using relative path
|
||||||
|
if not os.path.isabs(path) and not path.startswith('~'):
|
||||||
|
return ToolResult.fail(
|
||||||
|
f"Error: File not found: {path}\n"
|
||||||
|
f"Resolved to: {absolute_path}\n"
|
||||||
|
f"Hint: If accessing files outside workspace ({self.cwd}), use absolute path like ~/{path}"
|
||||||
|
)
|
||||||
return ToolResult.fail(f"Error: File not found: {path}")
|
return ToolResult.fail(f"Error: File not found: {path}")
|
||||||
|
|
||||||
# Check if readable
|
# Check if readable
|
||||||
|
|||||||
Reference in New Issue
Block a user