mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-21 14:18:52 +00:00
community[patch]: Handle empty PR body in get_pull_request in Github utility (#26739)
**Description:** When PR body is empty `get_pull_request` method fails with bellow exception. **Issue:** ``` TypeError('expected string or buffer')Traceback (most recent call last): File ".../.venv/lib/python3.9/site-packages/langchain_core/tools/base.py", line 661, in run response = context.run(self._run, *tool_args, **tool_kwargs) File ".../.venv/lib/python3.9/site-packages/langchain_community/tools/github/tool.py", line 52, in _run return self.api_wrapper.run(self.mode, query) File ".../.venv/lib/python3.9/site-packages/langchain_community/utilities/github.py", line 816, in run return json.dumps(self.get_pull_request(int(query))) File ".../.venv/lib/python3.9/site-packages/langchain_community/utilities/github.py", line 495, in get_pull_request add_to_dict(response_dict, "body", pull.body) File ".../.venv/lib/python3.9/site-packages/langchain_community/utilities/github.py", line 487, in add_to_dict tokens = get_tokens(value) File ".../.venv/lib/python3.9/site-packages/langchain_community/utilities/github.py", line 483, in get_tokens return len(tiktoken.get_encoding("cl100k_base").encode(text)) File "....venv/lib/python3.9/site-packages/tiktoken/core.py", line 116, in encode if match := _special_token_regex(disallowed_special).search(text): TypeError: expected string or buffer ``` **Twitter:** __gorros__
This commit is contained in:
parent
238a31bbd9
commit
f97ac92f00
@ -492,7 +492,7 @@ class GitHubAPIWrapper(BaseModel):
|
||||
response_dict: Dict[str, str] = {}
|
||||
add_to_dict(response_dict, "title", pull.title)
|
||||
add_to_dict(response_dict, "number", str(pr_number))
|
||||
add_to_dict(response_dict, "body", pull.body)
|
||||
add_to_dict(response_dict, "body", pull.body if pull.body else "")
|
||||
|
||||
comments: List[str] = []
|
||||
page = 0
|
||||
|
Loading…
Reference in New Issue
Block a user