fix(util.py): fix IndentationError while parsing from source code. (#944)
This commit is contained in:
commit
4c6cd57a1f
1 changed files with 3 additions and 2 deletions
|
|
@ -1,12 +1,13 @@
|
|||
import ast
|
||||
import inspect
|
||||
import textwrap
|
||||
from typing import Dict, Union
|
||||
|
||||
from langchain.agents.tools import Tool
|
||||
|
||||
|
||||
def get_func_tool_params(func, **kwargs) -> Union[Dict, None]:
|
||||
tree = ast.parse(inspect.getsource(func))
|
||||
tree = ast.parse(textwrap.dedent(inspect.getsource(func)))
|
||||
|
||||
# Iterate over the statements in the abstract syntax tree
|
||||
for node in ast.walk(tree):
|
||||
|
|
@ -57,7 +58,7 @@ def get_func_tool_params(func, **kwargs) -> Union[Dict, None]:
|
|||
|
||||
|
||||
def get_class_tool_params(cls, **kwargs) -> Union[Dict, None]:
|
||||
tree = ast.parse(inspect.getsource(cls))
|
||||
tree = ast.parse(textwrap.dedent(inspect.getsource(cls)))
|
||||
|
||||
tool_params = {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue