diff --git a/oxygent/preset_tools/file_tools.py b/oxygent/preset_tools/file_tools.py index 5b971ffc..2d46abb8 100644 --- a/oxygent/preset_tools/file_tools.py +++ b/oxygent/preset_tools/file_tools.py @@ -21,7 +21,7 @@ def write_file( @file_tools.tool( - description="Read the content of a file. Returns an error message if the file does not exist." + description="Read the content of a file. Returns an error message if the file does not exist. For uploaded files, use the complete file path including directory structure." ) def read_file(path: str = Field(description="Path to the file to read")) -> str: if not os.path.exists(path): diff --git a/oxygent/prompts.py b/oxygent/prompts.py index 8d95aa6f..11fd4239 100644 --- a/oxygent/prompts.py +++ b/oxygent/prompts.py @@ -49,6 +49,11 @@ After you call the retrieval tool, the user will give you feedback on the retrieved tools. You cannot call non-existent tools out of thin air. +File handling guidelines: +- When you see file attachments in the format "File: filename, Path: full_path", use the complete file path for tool calls +- For uploaded files, always use the full path including directory structure +- Do not extract only the filename - use the complete path provided + Important instructions: 1. When you have collected enough information to answer the user's question, please respond in the following format: Your thinking (if analysis is needed) @@ -74,6 +79,11 @@ 4. Use appropriate context from the user's question 5. Avoid simply repeating the raw data +File handling guidelines: +- When you see file attachments in the format "File: filename, Path: full_path", use the complete file path for tool calls +- For uploaded files, always use the full path including directory structure +- Do not extract only the filename - use the complete path provided + Tools for querying time can be obtained through retrieval tools. ${additional_prompt} """ diff --git a/oxygent/schemas/oxy.py b/oxygent/schemas/oxy.py index fa717ba5..e47c7603 100644 --- a/oxygent/schemas/oxy.py +++ b/oxygent/schemas/oxy.py @@ -378,15 +378,17 @@ def get_query(self, master_level=False): md_attachments = [] for i, attachment in enumerate(self.arguments.get("attachments", [])): if attachment.startswith("../static/"): - attachment = f"{Config.get_cache_save_dir()}/uploads{attachment[9:]}" + relative_path = attachment[9:].lstrip('/') + attachment = f"{Config.get_cache_save_dir()}/uploads/{relative_path}" is_image_flag = "!" if is_image(attachment) else "" attachment_base_name = os.path.basename(attachment) + # Generate a clearer format to help LLM correctly understand the path md_attachments.append( - f"{is_image_flag}[{attachment_base_name}]({attachment})" + f"{is_image_flag}File: {attachment_base_name}, Path: {attachment}" ) attachments_str = "\n".join(md_attachments) if attachments_str: - attachments_str += " " + attachments_str += "\n\n" if master_level: return attachments_str + self.shared_data.get("query", "")