Skip to content

Commit

Permalink
shows progress bar when running rag pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewcoole committed Dec 20, 2024
1 parent 68db64b commit 984344b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions scripts/run_rag_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from haystack_integrations.components.generators.ollama.generator import OllamaGenerator
from haystack_integrations.components.retrievers.chroma import ChromaQueryTextRetriever
from haystack_integrations.document_stores.chroma import ChromaDocumentStore
from tqdm import tqdm

TMP_DOC_PATH = ".tmp/doc-store"

Expand Down Expand Up @@ -93,12 +94,17 @@ def run_query(query: str, pipeline: Pipeline) -> Dict[str, Any]:
def query_pipeline(questions: List[str], rag_pipe: Pipeline) -> Tuple[str, List[str]]:
answers = []
contexts = []
for q in questions:
response = run_query(q, rag_pipe)
answers.append(response["answer_builder"]["answers"][0].data)
contexts.append(
[doc.content for doc in response["answer_builder"]["answers"][0].documents]
)
for q in tqdm(questions):
try:
response = run_query(q, rag_pipe)
answers.append(response["answer_builder"]["answers"][0].data)
contexts.append(
[doc.content for doc in response["answer_builder"]["answers"][0].documents]
)
except Exception as e:
print(str(e))
answers.append("Error")
contexts.append([])
return answers, contexts


Expand Down

0 comments on commit 984344b

Please sign in to comment.