Spaces:
Running
Running
Update pipeline.py
Browse files- 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)
|