Skip to content

Commit

Permalink
improve RAG formating in streamlit
Browse files Browse the repository at this point in the history
  • Loading branch information
boczekbartek committed Oct 21, 2024
1 parent 0333ea2 commit 9a4399e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/rai_hmi/rai_hmi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,14 @@ def status_callback(self):
self.status_publisher.publish(String(data=status.value))

def query_faiss_index_with_scores(
self, query: str, k: int = 4
self, query: str, k: int = 20
) -> List[Tuple[Document, float]]:
output = self.faiss_index.similarity_search_with_score(query, k)
return output
formatted_output = ""
for doc, score in output:
source = doc.metadata.get("source", "Unknown source")
formatted_output += f"Document source: {source}\nScore: {score}\nContent: \n{doc.page_content}\n\n"
return formatted_output

def _initialize_system_prompt(self):
return append_whoami_info_to_prompt(
Expand Down

0 comments on commit 9a4399e

Please sign in to comment.