Buckets:
| import os | |
| from unittest.mock import MagicMock, patch | |
| import asyncio | |
| # Mocking modules for testing logic flow | |
| async def test_ask_logic(): | |
| print("Testing ask_ebook_knowledge_base logic flow...") | |
| with patch("modules.vertex_ai.generate_embedding") as mock_embed, \ | |
| patch("modules.vector_store.search_relevant_chunks") as mock_search, \ | |
| patch("modules.vertex_ai.synthesize_answer") as mock_synth: | |
| mock_embed.return_value = [0.1, 0.2, 0.3] | |
| mock_search.return_value = ["Sample text from ebook."] | |
| mock_synth.return_value = "This is a grounded answer." | |
| from server import ask_ebook_knowledge_base | |
| result = await ask_ebook_knowledge_base("What is the meaning of life?") | |
| print(f"Result: {result}") | |
| assert result == "This is a grounded answer." | |
| mock_embed.assert_called_once() | |
| mock_search.assert_called_once() | |
| mock_synth.assert_called_once() | |
| print("PASSED") | |
| if __name__ == "__main__": | |
| asyncio.run(test_ask_logic()) | |
Xet Storage Details
- Size:
- 1.07 kB
- Xet hash:
- fb9feba21cb6277f85b30cd0da69bb0de595961b3dcacbea7065a2384751561d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.