-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathagent_tools.py
44 lines (37 loc) · 1.45 KB
/
agent_tools.py
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
import subprocess
def plan_tool(input_text: str) -> str:
"""
Calls `python api_tester.py plan` and returns the console output.
"""
try:
result = subprocess.check_output(["python", "api_tester.py", "plan"])
return result.decode("utf-8")
except subprocess.CalledProcessError as e:
return f"Error running plan_tool: {str(e)}"
def generate_tool(input_text: str) -> str:
"""
Calls `python api_tester.py generate` and returns the console output.
"""
try:
result = subprocess.check_output(["python", "api_tester.py", "generate"])
return result.decode("utf-8")
except subprocess.CalledProcessError as e:
return f"Error running generate_tool: {str(e)}"
def run_tool(input_text: str) -> str:
"""
Calls `python api_tester.py run` and returns the console output.
"""
try:
result = subprocess.check_output(["python", "api_tester.py", "run"])
return result.decode("utf-8")
except subprocess.CalledProcessError as e:
return f"Error running run_tool: {str(e)}"
def feedback_tool(user_feedback: str) -> str:
"""
Calls `python api_tester.py feedback "<user_feedback>"` and returns the console output.
"""
try:
result = subprocess.check_output(["python", "api_tester.py", "feedback", user_feedback])
return result.decode("utf-8")
except subprocess.CalledProcessError as e:
return f"Error running feedback_tool: {str(e)}"