Update Modules/Agent_Terminal.py
Browse files- Modules/Agent_Terminal.py +26 -0
Modules/Agent_Terminal.py
CHANGED
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
| 2 |
|
| 3 |
import os
|
| 4 |
import sys
|
|
|
|
| 5 |
import ast
|
| 6 |
from io import StringIO
|
| 7 |
from typing import Annotated
|
|
@@ -84,6 +85,31 @@ def usage(tool_name: str) -> str:
|
|
| 84 |
func = tools[tool_name]
|
| 85 |
return f"--- {tool_name} ---\n{func.__doc__ or 'No documentation available.'}"
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
# Single source of truth for the LLM-facing tool description
|
| 88 |
TOOL_SUMMARY = (
|
| 89 |
"Executes Python code as the unified interface for the entire tools ecosystem. "
|
|
|
|
| 2 |
|
| 3 |
import os
|
| 4 |
import sys
|
| 5 |
+
import types
|
| 6 |
import ast
|
| 7 |
from io import StringIO
|
| 8 |
from typing import Annotated
|
|
|
|
| 85 |
func = tools[tool_name]
|
| 86 |
return f"--- {tool_name} ---\n{func.__doc__ or 'No documentation available.'}"
|
| 87 |
|
| 88 |
+
def _initialize_mock_modules():
|
| 89 |
+
"""
|
| 90 |
+
Registers a mock 'functions' module in sys.modules so that LLMs
|
| 91 |
+
can do 'from functions import ...' without error.
|
| 92 |
+
"""
|
| 93 |
+
mock_module = types.ModuleType("functions")
|
| 94 |
+
|
| 95 |
+
# Add tools
|
| 96 |
+
for name, tool in _get_tools_map().items():
|
| 97 |
+
setattr(mock_module, name, tool)
|
| 98 |
+
|
| 99 |
+
# Add helpers
|
| 100 |
+
helpers = {
|
| 101 |
+
"list_tools": list_tools,
|
| 102 |
+
"search_tools": search_tools,
|
| 103 |
+
"usage": usage,
|
| 104 |
+
"search_packages": search_packages,
|
| 105 |
+
}
|
| 106 |
+
for name, func in helpers.items():
|
| 107 |
+
setattr(mock_module, name, func)
|
| 108 |
+
|
| 109 |
+
sys.modules["functions"] = mock_module
|
| 110 |
+
|
| 111 |
+
_initialize_mock_modules()
|
| 112 |
+
|
| 113 |
# Single source of truth for the LLM-facing tool description
|
| 114 |
TOOL_SUMMARY = (
|
| 115 |
"Executes Python code as the unified interface for the entire tools ecosystem. "
|