Repository navigation
Expand file tree
/
Copy pathtest_simple.py
More file actions
74 lines (60 loc) · 2.17 KB
/
Copy pathtest_simple.py
File metadata and controls
74 lines (60 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""Simple test to demonstrate the core functionality without running Claude Code."""
import sys
sys.path.insert(0, '.')
from claude_codemode.template import TemplateGenerator
from claude_codemode.types import ToolDefinition
import inspect
# Create a simple mock tool
def get_weather(city: str) -> str:
"""Get the weather for a given city.
Args:
city: Name of the city
Returns:
Weather information
"""
return f"Weather in {city}: Sunny, 72°F"
def calculate_temp_diff(temp1: str, temp2: str) -> str:
"""Calculate the difference between two temperatures.
Args:
temp1: First temperature (e.g., "72°F")
temp2: Second temperature (e.g., "65°F")
Returns:
Temperature difference
"""
import re
match1 = re.search(r'(\d+)', temp1)
match2 = re.search(r'(\d+)', temp2)
if match1 and match2:
diff = abs(int(match1.group(1)) - int(match2.group(1)))
return f"{diff}°F"
return "Unable to calculate difference"
# Create tool definitions
tools = [
ToolDefinition(
name="get_weather",
function=get_weather,
description=inspect.getdoc(get_weather),
parameters=dict(inspect.signature(get_weather).parameters),
return_annotation=inspect.signature(get_weather).return_annotation
),
ToolDefinition(
name="calculate_temp_diff",
function=calculate_temp_diff,
description=inspect.getdoc(calculate_temp_diff),
parameters=dict(inspect.signature(calculate_temp_diff).parameters),
return_annotation=inspect.signature(calculate_temp_diff).return_annotation
)
]
# Generate the agentRunner.py template
template_gen = TemplateGenerator()
prompt = "Compare the weather between San Francisco and New York"
runner_code = template_gen.generate_runner(prompt, tools, deps=None)
print("=" * 80)
print("Generated agentRunner.py Template")
print("=" * 80)
print(runner_code)
print("\n" + "=" * 80)
print("✓ Template generation works!")
print("=" * 80)
print("\nThis template would be given to Claude Code to implement the main() function.")
print("Claude Code would write Python code that calls these tools to accomplish the task.")