janito 3.9.0__py3-none-any.whl → 3.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- janito/agent_events.py +75 -0
- janito/cli/chat_mode/session.py +1 -0
- janito/cli/chat_mode/shell/commands/__init__.py +2 -0
- janito/cli/chat_mode/shell/commands/interactive.py +33 -0
- janito/cli/chat_mode/toolbar.py +16 -1
- janito/cli/core/runner.py +33 -0
- janito/cli/main_cli.py +9 -0
- janito/cli/prompt_core.py +67 -33
- janito/cli/rich_terminal_reporter.py +170 -179
- janito/cli/single_shot_mode/handler.py +19 -0
- janito/llm/agent.py +59 -0
- janito/plugins/tools/local/__init__.py +7 -0
- janito/plugins/tools/local/create_directory.py +44 -1
- janito/tests/test_tool_adapter_case_insensitive.py +112 -0
- janito/tools/tools_adapter.py +514 -510
- {janito-3.9.0.dist-info → janito-3.11.0.dist-info}/METADATA +1 -1
- {janito-3.9.0.dist-info → janito-3.11.0.dist-info}/RECORD +21 -18
- {janito-3.9.0.dist-info → janito-3.11.0.dist-info}/WHEEL +0 -0
- {janito-3.9.0.dist-info → janito-3.11.0.dist-info}/entry_points.txt +0 -0
- {janito-3.9.0.dist-info → janito-3.11.0.dist-info}/licenses/LICENSE +0 -0
- {janito-3.9.0.dist-info → janito-3.11.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""Test script to verify tool adapter converts argument names to lowercase."""
|
3
|
+
|
4
|
+
import tempfile
|
5
|
+
import os
|
6
|
+
import subprocess
|
7
|
+
import sys
|
8
|
+
from pathlib import Path
|
9
|
+
import json
|
10
|
+
|
11
|
+
|
12
|
+
def test_tool_adapter_lowercase_conversion():
|
13
|
+
"""Test that tool adapter converts argument names to lowercase."""
|
14
|
+
print("Testing tool adapter lowercase conversion...")
|
15
|
+
|
16
|
+
# Create a simple test tool that logs its arguments
|
17
|
+
test_tool_content = '''
|
18
|
+
from janito.plugins.tools.local.adapter import register_local_tool
|
19
|
+
from janito.tools.tool_base import ToolBase, ToolPermissions
|
20
|
+
|
21
|
+
class TestArgsTool(ToolBase):
|
22
|
+
tool_name = "test_args_tool"
|
23
|
+
description = "Test tool to verify argument case conversion"
|
24
|
+
permissions = ToolPermissions(read=True, write=False, execute=False)
|
25
|
+
|
26
|
+
def execute(self, test_path: str, test_mode: str = "default") -> str:
|
27
|
+
"""Test tool that returns its arguments."""
|
28
|
+
return f"Received: test_path={test_path}, test_mode={test_mode}"
|
29
|
+
|
30
|
+
register_local_tool(TestArgsTool)
|
31
|
+
'''
|
32
|
+
|
33
|
+
# Create a temporary Python file with the test tool
|
34
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f:
|
35
|
+
f.write(test_tool_content)
|
36
|
+
test_tool_file = f.name
|
37
|
+
|
38
|
+
try:
|
39
|
+
# Test with mixed case arguments
|
40
|
+
print("\n1. Testing mixed case argument names...")
|
41
|
+
|
42
|
+
# Create a simple test script that uses the tool adapter directly
|
43
|
+
test_script = f'''
|
44
|
+
import sys
|
45
|
+
import os
|
46
|
+
sys.path.insert(0, os.path.join(os.getcwd(), "janito"))
|
47
|
+
|
48
|
+
# Import the test tool to register it
|
49
|
+
exec(open("{test_tool_file}").read())
|
50
|
+
|
51
|
+
from janito.plugins.tools.local.adapter import LocalToolsAdapter
|
52
|
+
from janito.llm.message_parts import FunctionCallMessagePart
|
53
|
+
import json
|
54
|
+
|
55
|
+
# Create a mock function object with mixed case arguments
|
56
|
+
class MockFunction:
|
57
|
+
def __init__(self, name, arguments):
|
58
|
+
self.name = name
|
59
|
+
self.arguments = arguments
|
60
|
+
|
61
|
+
# Create adapter
|
62
|
+
adapter = LocalToolsAdapter()
|
63
|
+
|
64
|
+
# Test with mixed case arguments
|
65
|
+
mixed_case_args = {{"Test_Path": "/tmp/test", "Test_Mode": "verify"}}
|
66
|
+
function = MockFunction("test_args_tool", json.dumps(mixed_case_args))
|
67
|
+
message_part = FunctionCallMessagePart(tool_call_id="test_123", function=function)
|
68
|
+
|
69
|
+
# Execute and print result
|
70
|
+
result = adapter.execute_function_call_message_part(message_part)
|
71
|
+
print(f"Result: {{result}}")
|
72
|
+
'''
|
73
|
+
|
74
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f:
|
75
|
+
f.write(test_script)
|
76
|
+
test_script_file = f.name
|
77
|
+
|
78
|
+
try:
|
79
|
+
# Run the test script
|
80
|
+
result = subprocess.run(
|
81
|
+
[sys.executable, test_script_file],
|
82
|
+
capture_output=True,
|
83
|
+
text=True,
|
84
|
+
cwd="/home/janito/janito"
|
85
|
+
)
|
86
|
+
|
87
|
+
print(f"Script output: {result.stdout}")
|
88
|
+
print(f"Script stderr: {result.stderr}")
|
89
|
+
|
90
|
+
# Check if the tool was executed successfully
|
91
|
+
if result.returncode == 0 and "Received: test_path=/tmp/test, test_mode=verify" in result.stdout:
|
92
|
+
print("✓ Mixed case arguments were successfully converted to lowercase")
|
93
|
+
return True
|
94
|
+
else:
|
95
|
+
print("✗ Tool execution failed or arguments were not converted properly")
|
96
|
+
return False
|
97
|
+
|
98
|
+
finally:
|
99
|
+
os.unlink(test_script_file)
|
100
|
+
|
101
|
+
finally:
|
102
|
+
os.unlink(test_tool_file)
|
103
|
+
|
104
|
+
|
105
|
+
if __name__ == "__main__":
|
106
|
+
success = test_tool_adapter_lowercase_conversion()
|
107
|
+
if success:
|
108
|
+
print("\n🎉 Test passed!")
|
109
|
+
sys.exit(0)
|
110
|
+
else:
|
111
|
+
print("\n❌ Test failed!")
|
112
|
+
sys.exit(1)
|