mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-09 23:12:38 +00:00
Core: google docstring parsing fix (#28404)
Thank you for contributing to LangChain! - [ ] **PR title**: "core: google docstring parsing fix" - [x] **PR message**: - **Description:** Added a solution for invalid parsing of google docstring such as: Args: net_annual_income (float): The user's net annual income (in current year dollars). - **Issue:** Previous code would return arg = "net_annual_income (float)" which would cause exception in _validate_docstring_args_against_annotations - **Dependencies:** None If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17. Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
@@ -646,9 +646,13 @@ def _parse_google_docstring(
|
||||
for line in args_block.split("\n")[1:]:
|
||||
if ":" in line:
|
||||
arg, desc = line.split(":", maxsplit=1)
|
||||
arg_descriptions[arg.strip()] = desc.strip()
|
||||
arg = arg.strip()
|
||||
arg_name, _, _annotations = arg.partition(" ")
|
||||
if _annotations.startswith("(") and _annotations.endswith(")"):
|
||||
arg = arg_name
|
||||
arg_descriptions[arg] = desc.strip()
|
||||
elif arg:
|
||||
arg_descriptions[arg.strip()] += " " + line.strip()
|
||||
arg_descriptions[arg] += " " + line.strip()
|
||||
return description, arg_descriptions
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user