Phoenix21 commited on
Commit
0036873
·
verified ·
1 Parent(s): 9724455

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +13 -0
pipeline.py CHANGED
@@ -182,6 +182,19 @@ def build_rag_chain(llm_model: LiteLLMModel, vectorstore: FAISS) -> RetrievalQA:
182
  except Exception as e:
183
  raise RuntimeError(f"Error building RAG chain: {str(e)}")
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  def run_pipeline(query: str) -> str:
186
  try:
187
  query = sanitize_message(query)
 
182
  except Exception as e:
183
  raise RuntimeError(f"Error building RAG chain: {str(e)}")
184
 
185
+
186
+ def sanitize_message(message: Any) -> str:
187
+ """Sanitize message input to ensure it's a valid string."""
188
+ try:
189
+ if hasattr(message, 'content'):
190
+ return str(message.content)
191
+ if isinstance(message, (list, dict)):
192
+ return str(message)
193
+ return str(message)
194
+ except Exception as e:
195
+ raise RuntimeError(f"Error in sanitize function: {str(e)}")
196
+
197
+
198
  def run_pipeline(query: str) -> str:
199
  try:
200
  query = sanitize_message(query)