Update PlanFileEditAtomicFlow.py
Browse files- PlanFileEditAtomicFlow.py +17 -1
PlanFileEditAtomicFlow.py
CHANGED
|
@@ -43,7 +43,23 @@ class PlanFileEditAtomicFlow(AtomicFlow):
|
|
| 43 |
assert os.path.isfile(plan_file_loc), f"{plan_file_loc} is not a file"
|
| 44 |
|
| 45 |
def _generate_input_to_writer(self, input_data: Dict[str, Any]):
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
plan_file_location = input_data["plan_file_location"]
|
| 48 |
content_to_write = self._generate_content(plan_file_location, plan_str)
|
| 49 |
file_location_to_write = self._generate_temp_file_location(plan_file_location)
|
|
|
|
| 43 |
assert os.path.isfile(plan_file_loc), f"{plan_file_loc} is not a file"
|
| 44 |
|
| 45 |
def _generate_input_to_writer(self, input_data: Dict[str, Any]):
|
| 46 |
+
"""
|
| 47 |
+
sometimes the plan generator will return an arrary of indexed plans, like
|
| 48 |
+
[
|
| 49 |
+
"1. Extend the code library with a function named 'import_libraries'. This function should import necessary libraries for the task...",
|
| 50 |
+
"2. Extend the code library with a function named 'fetch_stock_prices'. This function should take two inputs: 'company_code' and 'duration'...",
|
| 51 |
+
"3. Investigate the issue with importing the 'fetch_stock_prices' function from the library..."
|
| 52 |
+
]
|
| 53 |
+
In this case we need to prase this format accorrdingly.
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
plan = input_data['plan'] if "plan" in input_data else input_data['new_plan']
|
| 57 |
+
if isinstance(plan, str):
|
| 58 |
+
plan_str = plan
|
| 59 |
+
elif isinstance(plan, list):
|
| 60 |
+
plan_str = "\n".join(plan)
|
| 61 |
+
else:
|
| 62 |
+
raise TypeError("plan is neither a string nor a list")
|
| 63 |
plan_file_location = input_data["plan_file_location"]
|
| 64 |
content_to_write = self._generate_content(plan_file_location, plan_str)
|
| 65 |
file_location_to_write = self._generate_temp_file_location(plan_file_location)
|