Commit
·
7258b59
1
Parent(s):
6b24b53
Fixed the formatting
Browse files- src/manager/manager.py +5 -48
src/manager/manager.py
CHANGED
@@ -37,54 +37,11 @@ class Mode(Enum):
|
|
37 |
ENABLE_ECONOMY_BUDGET = auto()
|
38 |
ENABLE_MEMORY = auto()
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
indent_str = " " * indent
|
46 |
-
result = []
|
47 |
-
|
48 |
-
if isinstance(response, dict):
|
49 |
-
result.append("{")
|
50 |
-
items = list(response.items())
|
51 |
-
for i, (key, value) in enumerate(items):
|
52 |
-
end_comma = "" if i == len(items) - 1 else ","
|
53 |
-
formatted_value = format_tool_response(value, indent + 1)
|
54 |
-
result.append(f"{indent_str} \"{key}\": {formatted_value}{end_comma}")
|
55 |
-
result.append(f"{indent_str}}}")
|
56 |
-
return "\n".join(result)
|
57 |
-
|
58 |
-
elif isinstance(response, list):
|
59 |
-
result.append("[")
|
60 |
-
for i, item in enumerate(response):
|
61 |
-
end_comma = "" if i == len(response) - 1 else ","
|
62 |
-
formatted_item = format_tool_response(item, indent + 1)
|
63 |
-
result.append(f"{indent_str} {formatted_item}{end_comma}")
|
64 |
-
result.append(f"{indent_str}]")
|
65 |
-
return "\n".join(result)
|
66 |
-
|
67 |
-
elif isinstance(response, str):
|
68 |
-
# Handle multiline strings by using triple quotes and preserving newlines
|
69 |
-
if "\n" in response:
|
70 |
-
# Replace newlines with actual newlines and proper indentation
|
71 |
-
lines = response.split("\n")
|
72 |
-
indented_lines = [f"{indent_str} {line}" for line in lines]
|
73 |
-
joined_lines = "\n".join(indented_lines)
|
74 |
-
return f"'''\n{joined_lines}\n{indent_str} '''"
|
75 |
-
else:
|
76 |
-
# Regular string
|
77 |
-
return f"\"{response}\""
|
78 |
-
|
79 |
-
elif response is None:
|
80 |
-
return "null"
|
81 |
-
|
82 |
-
elif isinstance(response, (int, float, bool)):
|
83 |
-
return str(response).lower() if isinstance(response, bool) else str(response)
|
84 |
-
|
85 |
-
else:
|
86 |
-
# Fallback for other types
|
87 |
-
return f"\"{str(response)}\""
|
88 |
class GeminiManager:
|
89 |
def __init__(self, system_prompt_file="./src/models/system4.prompt",
|
90 |
gemini_model="gemini-2.5-pro-exp-03-25",
|
|
|
37 |
ENABLE_ECONOMY_BUDGET = auto()
|
38 |
ENABLE_MEMORY = auto()
|
39 |
|
40 |
+
|
41 |
+
def format_tool_response(response, indent=2):
|
42 |
+
return json.dumps(response, indent=indent).encode('utf-8').decode('unicode_escape')
|
43 |
+
|
44 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
class GeminiManager:
|
46 |
def __init__(self, system_prompt_file="./src/models/system4.prompt",
|
47 |
gemini_model="gemini-2.5-pro-exp-03-25",
|