Spaces:
Build error
Build error
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -6,7 +6,6 @@ import os
|
|
| 6 |
def parse_file_content(string: str) -> tuple[str | None, str | None]:
|
| 7 |
"""
|
| 8 |
Parses the content of a file and returns the action and description.
|
| 9 |
-
|
| 10 |
:param string: The content of a file.
|
| 11 |
:return: A tuple containing the action and description.
|
| 12 |
"""
|
|
@@ -25,7 +24,6 @@ def parse_file_content(string: str) -> tuple[str | None, str | None]:
|
|
| 25 |
def parse_action(string: str) -> tuple[str, str | None]:
|
| 26 |
"""
|
| 27 |
Parses the action from a string.
|
| 28 |
-
|
| 29 |
:param string: The string to parse the action from.
|
| 30 |
:return: A tuple containing the action and action input.
|
| 31 |
"""
|
|
@@ -39,7 +37,6 @@ def parse_action(string: str) -> tuple[str, str | None]:
|
|
| 39 |
def extract_imports(file_contents: str) -> tuple[list[str], list[ast.FunctionDef], list[ast.ClassDef]]:
|
| 40 |
"""
|
| 41 |
Extracts imports, functions, and classes from a file's contents.
|
| 42 |
-
|
| 43 |
:param file_contents: The contents of a file.
|
| 44 |
:return: A tuple containing the imports, functions, and classes.
|
| 45 |
"""
|
|
@@ -67,7 +64,6 @@ def extract_imports(file_contents: str) -> tuple[list[str], list[ast.FunctionDef
|
|
| 67 |
def read_python_module_structure(path: str) -> tuple[str, dict[str, str], dict[str, list[str]]]:
|
| 68 |
"""
|
| 69 |
Reads the structure of a Python module and returns a prompt, content, and internal imports map.
|
| 70 |
-
|
| 71 |
:param path: The path to the Python module.
|
| 72 |
:return: A tuple containing the structure prompt, content, and internal imports map.
|
| 73 |
"""
|
|
@@ -102,4 +98,6 @@ def read_python_module_structure(path: str) -> tuple[str, dict[str, str], dict[s
|
|
| 102 |
|
| 103 |
structure_prompt += f"{fn}\n"
|
| 104 |
for function in functions:
|
| 105 |
-
structure_prompt += " {}({})
|
|
|
|
|
|
|
|
|
| 6 |
def parse_file_content(string: str) -> tuple[str | None, str | None]:
|
| 7 |
"""
|
| 8 |
Parses the content of a file and returns the action and description.
|
|
|
|
| 9 |
:param string: The content of a file.
|
| 10 |
:return: A tuple containing the action and description.
|
| 11 |
"""
|
|
|
|
| 24 |
def parse_action(string: str) -> tuple[str, str | None]:
|
| 25 |
"""
|
| 26 |
Parses the action from a string.
|
|
|
|
| 27 |
:param string: The string to parse the action from.
|
| 28 |
:return: A tuple containing the action and action input.
|
| 29 |
"""
|
|
|
|
| 37 |
def extract_imports(file_contents: str) -> tuple[list[str], list[ast.FunctionDef], list[ast.ClassDef]]:
|
| 38 |
"""
|
| 39 |
Extracts imports, functions, and classes from a file's contents.
|
|
|
|
| 40 |
:param file_contents: The contents of a file.
|
| 41 |
:return: A tuple containing the imports, functions, and classes.
|
| 42 |
"""
|
|
|
|
| 64 |
def read_python_module_structure(path: str) -> tuple[str, dict[str, str], dict[str, list[str]]]:
|
| 65 |
"""
|
| 66 |
Reads the structure of a Python module and returns a prompt, content, and internal imports map.
|
|
|
|
| 67 |
:param path: The path to the Python module.
|
| 68 |
:return: A tuple containing the structure prompt, content, and internal imports map.
|
| 69 |
"""
|
|
|
|
| 98 |
|
| 99 |
structure_prompt += f"{fn}\n"
|
| 100 |
for function in functions:
|
| 101 |
+
structure_prompt += f" {function.name}({function.args})\n"
|
| 102 |
+
|
| 103 |
+
return structure_prompt, content, internal_imports_map
|