Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: make docstring parsing more robust #28628

Closed
1 task done
ccurme opened this issue Dec 9, 2024 · 1 comment · Fixed by #28730
Closed
1 task done

core: make docstring parsing more robust #28628

ccurme opened this issue Dec 9, 2024 · 1 comment · Fixed by #28730
Labels
Ɑ: core Related to langchain-core

Comments

@ccurme
Copy link
Collaborator

ccurme commented Dec 9, 2024

Privileged issue

  • I am a LangChain maintainer, or was asked directly by a LangChain maintainer to create an issue here.

Issue Content

Valid Google-style docstrings with descriptions > 1 paragraph are not supported.

Example failure:

from langchain_core.tools import tool


@tool(parse_docstring=True)
def search(query: str) -> None:
  """Searches for information based on the query.

  Use this tool to look up factual information or search for relevant content.

  Args:
    query: The search query. A good query is a clear and concise question or statement.

  Returns:
    A list of documents that match the query.
  """
  pass

Root cause is raising an error when second \n\n-delimited block does not start with Args:

len(docstring_blocks) < 2 or not docstring_blocks[1].startswith("Args:")

@isatyamks
Copy link
Contributor

isatyamks commented Dec 15, 2024

@ccurme Could you please review my PR #28730? I improved _parse_google_docstring to support multi-paragraph descriptions while ensuring backward compatibility.

isatyamks added a commit to isatyamks/langchain that referenced this issue Dec 16, 2024
isatyamks added a commit to isatyamks/langchain that referenced this issue Dec 16, 2024
isatyamks added a commit to isatyamks/langchain that referenced this issue Dec 16, 2024
isatyamks added a commit to isatyamks/langchain that referenced this issue Dec 16, 2024
refactor: improve error handling and argument parsing in _parse_google_docstring function
efriis added a commit to isatyamks/langchain that referenced this issue Dec 16, 2024
isatyamks added a commit to isatyamks/langchain that referenced this issue Dec 17, 2024
ccurme added a commit to isatyamks/langchain that referenced this issue Dec 17, 2024
isatyamks added a commit to isatyamks/langchain that referenced this issue Dec 18, 2024
@ccurme ccurme closed this as completed in 90f7713 Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: core Related to langchain-core
Projects
None yet
2 participants