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

ArxivAPIWrapper - doc_content_chars_max #6063

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions langchain/utilities/arxiv.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Util that calls Arxiv."""
import logging
import os
from typing import Any, Dict, List
from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Extra, root_validator

Expand Down Expand Up @@ -38,7 +38,7 @@ class ArxivAPIWrapper(BaseModel):
ARXIV_MAX_QUERY_LENGTH = 300
load_max_docs: int = 100
load_all_available_meta: bool = False
doc_content_chars_max: int = 4000
doc_content_chars_max: Optional[int] = 4000

class Config:
"""Configuration for this pydantic object."""
Expand Down
18 changes: 18 additions & 0 deletions tests/integration_tests/utilities/test_arxiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ def test_load_returns_limited_docs() -> None:
assert_docs(docs)


def test_load_returns_limited_doc_content_chars() -> None:
"""Test that returns limited doc_content_chars_max"""

doc_content_chars_max = 100
api_client = ArxivAPIWrapper(doc_content_chars_max=doc_content_chars_max)
docs = api_client.load("1605.08386")
assert len(docs[0].page_content) == doc_content_chars_max


def test_load_returns_unlimited_doc_content_chars() -> None:
"""Test that returns unlimited doc_content_chars_max"""

doc_content_chars_max = None
api_client = ArxivAPIWrapper(doc_content_chars_max=doc_content_chars_max)
docs = api_client.load("1605.08386")
assert len(docs[0].page_content) == 54337


def test_load_returns_full_set_of_metadata() -> None:
"""Test that returns several docs"""
api_client = ArxivAPIWrapper(load_max_docs=1, load_all_available_meta=True)
Expand Down