Jeevant10 commited on
Commit
505157a
·
unverified ·
2 Parent(s): d66dc57633cd4e

Merge pull request #1 from Deepesh70/deep

Browse files
Files changed (1) hide show
  1. src/search.py +4 -9
src/search.py CHANGED
@@ -78,23 +78,18 @@ class RAGSearch:
78
  return out
79
 
80
  def summarize(self, query: str, retrieved: List[RetrievalResult]) -> str:
81
- if not retrieved:
82
- return "No documents are available in the vector store. Please add some documents to the data directory and restart the application."
83
-
84
  texts = [r.text for r in retrieved if r.text]
85
  context = "\n\n".join(texts)
86
- if not context:
87
- return "No relevant documents found for your query."
88
 
89
  # Using proper message formatting for better LLM interaction
90
- system_message = SystemMessage(content="You are a helpful assistant that summarizes documents based on queries. Provide clear, concise summaries with relevant quotes when appropriate.")
91
  human_message = HumanMessage(content=f"""
92
- Based on the following context, answer the query: '{query}'
93
-
94
  Context:
95
  {context}
96
 
97
- Please provide a comprehensive answer based solely on the provided context. If you quote specific information, indicate it clearly.
 
 
98
  """)
99
 
100
  try:
 
78
  return out
79
 
80
  def summarize(self, query: str, retrieved: List[RetrievalResult]) -> str:
 
 
 
81
  texts = [r.text for r in retrieved if r.text]
82
  context = "\n\n".join(texts)
 
 
83
 
84
  # Using proper message formatting for better LLM interaction
85
+ system_message = SystemMessage(content="You are a helpful assistant. Use the provided context to answer the user's question if the information is present. If the answer is not in the context, or if the context is empty, answer the question using your own knowledge.")
86
  human_message = HumanMessage(content=f"""
 
 
87
  Context:
88
  {context}
89
 
90
+ Query: {query}
91
+
92
+ Answer:
93
  """)
94
 
95
  try: