mirror of https://github.com/hwchase17/langchain
feat: add support for arxiv identifier in ArxivAPIWrapper() (#9318)
- Description: this PR adds the support for arxiv identifier of the ArxivAPIWrapper. I modified the `run()` and `load()` functions in `arxiv.py`, using regex to recognize if the query is in the form of arxiv identifier (see [https://info.arxiv.org/help/find/index.html](https://info.arxiv.org/help/find/index.html)). If so, it will directly search the paper corresponding to the arxiv identifier. I also modified and added tests in `test_arxiv.py`. - Issue: #9047 - Dependencies: N/A - Tag maintainer: N/A --------- Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>pull/11143/head
parent
d3c2ca5656
commit
05b75f3f13
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,17 @@
|
||||
import pytest as pytest
|
||||
|
||||
from langchain.utilities import ArxivAPIWrapper
|
||||
|
||||
|
||||
@pytest.mark.requires("arxiv")
|
||||
def test_is_arxiv_identifier() -> None:
|
||||
"""Test that is_arxiv_identifier returns True for valid arxiv identifiers"""
|
||||
api_client = ArxivAPIWrapper()
|
||||
assert api_client.is_arxiv_identifier("1605.08386v1")
|
||||
assert api_client.is_arxiv_identifier("0705.0123")
|
||||
assert api_client.is_arxiv_identifier("2308.07912")
|
||||
assert api_client.is_arxiv_identifier("9603067 2308.07912 2308.07912")
|
||||
assert not api_client.is_arxiv_identifier("12345")
|
||||
assert not api_client.is_arxiv_identifier("0705.012")
|
||||
assert not api_client.is_arxiv_identifier("0705.012300")
|
||||
assert not api_client.is_arxiv_identifier("1605.08386w1")
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue