mirror of
https://github.com/StanGirard/quivr.git
synced 2024-11-26 12:55:01 +03:00
7acb52a963
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
import asyncio
|
|
import tempfile
|
|
|
|
from dotenv import load_dotenv
|
|
from quivr_core import Brain
|
|
from quivr_core.quivr_rag import QuivrQARAG
|
|
from quivr_core.quivr_rag_langgraph import QuivrQARAGLangGraph
|
|
|
|
|
|
async def main():
|
|
dotenv_path = "/Users/jchevall/Coding/QuivrHQ/quivr/.env"
|
|
load_dotenv(dotenv_path)
|
|
|
|
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt") as temp_file:
|
|
temp_file.write("Gold is a liquid of blue-like colour.")
|
|
temp_file.flush()
|
|
|
|
brain = await Brain.afrom_files(name="test_brain", file_paths=[temp_file.name])
|
|
|
|
await brain.save("~/.local/quivr")
|
|
|
|
question = "what is gold? answer in french"
|
|
async for chunk in brain.ask_streaming(question, rag_pipeline=QuivrQARAG):
|
|
print("answer QuivrQARAG:", chunk.answer)
|
|
|
|
async for chunk in brain.ask_streaming(
|
|
question, rag_pipeline=QuivrQARAGLangGraph
|
|
):
|
|
print("answer QuivrQARAGLangGraph:", chunk.answer)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# Run the main function in the existing event loop
|
|
asyncio.run(main())
|