mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-14 17:03:29 +03:00
3001fa1475
# Description - Created registry processor logic for automagically adding processors to quivr_core based Entrypoints - Added a langchain_community free `SimpleTxtParser` for the quivr_core base package - Added tests - Added brain_info - Enriched parsed documents metadata based on quivr_file metadata used Rich for `Brain.print_info()` to get a better output: ![image](https://github.com/user-attachments/assets/dd9f2f03-d7d7-4be0-ba6c-3fe38e11c40f)
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
from langchain_core.embeddings import DeterministicFakeEmbedding
|
|
from langchain_core.language_models import FakeListChatModel
|
|
from rich.console import Console
|
|
from rich.panel import Panel
|
|
from rich.prompt import Prompt
|
|
|
|
from quivr_core import Brain
|
|
from quivr_core.config import LLMEndpointConfig
|
|
from quivr_core.llm.llm_endpoint import LLMEndpoint
|
|
|
|
if __name__ == "__main__":
|
|
brain = Brain.from_files(
|
|
name="test_brain",
|
|
file_paths=["tests/processor/data/dummy.pdf"],
|
|
llm=LLMEndpoint(
|
|
llm=FakeListChatModel(responses=["good"]),
|
|
llm_config=LLMEndpointConfig(model="fake_model", llm_base_url="local"),
|
|
),
|
|
embedder=DeterministicFakeEmbedding(size=20),
|
|
)
|
|
# Check brain info
|
|
brain.print_info()
|
|
|
|
console = Console()
|
|
console.print(Panel.fit("Ask your brain !", style="bold magenta"))
|
|
|
|
while True:
|
|
# Get user input
|
|
question = Prompt.ask("[bold cyan]Question[/bold cyan]")
|
|
|
|
# Check if user wants to exit
|
|
if question.lower() == "exit":
|
|
console.print(Panel("Goodbye!", style="bold yellow"))
|
|
break
|
|
|
|
answer = brain.ask(question)
|
|
# Print the answer with typing effect
|
|
console.print(f"[bold green]Quivr Assistant[/bold green]: {answer.answer}")
|
|
|
|
console.print("-" * console.width)
|
|
|
|
brain.print_info()
|