-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix empty index + generation synthesizer (#16785)
- Loading branch information
1 parent
35234d2
commit b28c19a
Showing
2 changed files
with
149 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
llama-index-core/tests/response_synthesizers/test_generate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
|
||
from llama_index.core.llms import MockLLM | ||
from llama_index.core.response_synthesizers.generation import Generation | ||
|
||
|
||
def test_synthesize() -> None: | ||
synthesizer = Generation(llm=MockLLM()) | ||
response = synthesizer.synthesize(query="test", nodes=[]) | ||
assert str(response) == "test" | ||
|
||
|
||
def test_synthesize_stream() -> None: | ||
synthesizer = Generation(llm=MockLLM(), streaming=True) | ||
response = synthesizer.synthesize(query="test", nodes=[]) | ||
|
||
gold = "test" | ||
i = 0 | ||
for chunk in response.response_gen: | ||
assert chunk == gold[i] | ||
i += 1 | ||
|
||
|
||
@pytest.mark.asyncio() | ||
async def test_asynthesize() -> None: | ||
synthesizer = Generation(llm=MockLLM()) | ||
response = await synthesizer.asynthesize(query="test", nodes=[]) | ||
assert str(response) == "test" | ||
|
||
|
||
@pytest.mark.asyncio() | ||
async def test_asynthesize_stream() -> None: | ||
synthesizer = Generation(llm=MockLLM(), streaming=True) | ||
response = await synthesizer.asynthesize(query="test", nodes=[]) | ||
|
||
gold = "test" | ||
i = 0 | ||
async for chunk in response.async_response_gen(): | ||
assert chunk == gold[i] | ||
i += 1 |