mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
exa docs and python package update (#31307)
Added support for new Exa API features. Updated Exa docs and python package (langchain-exa). Description Added support for new Exa API features in the langchain-exa package: - Added max_characters option for text content - Added support for summary and custom summary prompts - Added livecrawl option with "always", "fallback", "never" settings - Added "auto" option for search type - Updated documentation and tests Dependencies - No new dependencies required. Using existing features from exa-py. twitter: @theishangoswami --------- Co-authored-by: Chester Curme <chester.curme@gmail.com>
This commit is contained in:
@@ -26,3 +26,19 @@ def test_exa_retriever_highlights() -> None:
|
||||
assert isinstance(highlight_scores, list)
|
||||
assert isinstance(highlights[0], str)
|
||||
assert isinstance(highlight_scores[0], float)
|
||||
|
||||
|
||||
def test_exa_retriever_advanced_features() -> None:
|
||||
retriever = ExaSearchRetriever(
|
||||
k=3, text_contents_options={"max_characters": 1000}, summary=True, type="auto"
|
||||
)
|
||||
res = retriever.invoke("best time to visit japan")
|
||||
print(res) # noqa: T201
|
||||
assert len(res) == 3 # requested k=3
|
||||
assert isinstance(res, list)
|
||||
assert isinstance(res[0], Document)
|
||||
# Verify summary is in metadata
|
||||
assert "summary" in res[0].metadata
|
||||
assert isinstance(res[0].metadata["summary"], str)
|
||||
# Verify text was limited
|
||||
assert len(res[0].page_content) <= 1000
|
||||
|
||||
@@ -8,3 +8,23 @@ def test_search_tool() -> None:
|
||||
res = tool.invoke({"query": "best time to visit japan", "num_results": 5})
|
||||
print(res) # noqa: T201
|
||||
assert not isinstance(res, str) # str means error for this tool\
|
||||
|
||||
|
||||
def test_search_tool_advanced_features() -> None:
|
||||
tool = ExaSearchResults()
|
||||
res = tool.invoke(
|
||||
{
|
||||
"query": "best time to visit japan",
|
||||
"num_results": 3,
|
||||
"text_contents_options": {"max_characters": 1000},
|
||||
"summary": True,
|
||||
"type": "auto",
|
||||
}
|
||||
)
|
||||
print(res) # noqa: T201
|
||||
assert not isinstance(res, str) # str means error for this tool
|
||||
assert len(res.results) == 3
|
||||
# Verify summary exists
|
||||
assert hasattr(res.results[0], "summary")
|
||||
# Verify text was limited
|
||||
assert len(res.results[0].text) <= 1000
|
||||
|
||||
Reference in New Issue
Block a user