Commit ·
a52ea90
1
Parent(s): aa7f8bc
הוספת בדיקת ולידציה לזיהוי תשובות שגיבוב של מילים
Browse files- app/rag_service.py +11 -0
app/rag_service.py
CHANGED
|
@@ -155,6 +155,17 @@ class RAGService:
|
|
| 155 |
# Response is very short, try to get more detail (target is 600-800 words)
|
| 156 |
return self._request_fix(response, query, aggregates_str)
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
# Check if response seems too generic or just a list of examples (doesn't contain analysis)
|
| 159 |
has_numbers = any(char.isdigit() for char in response)
|
| 160 |
has_analysis_terms = any(term in response for term in [
|
|
|
|
| 155 |
# Response is very short, try to get more detail (target is 600-800 words)
|
| 156 |
return self._request_fix(response, query, aggregates_str)
|
| 157 |
|
| 158 |
+
# Check if response is just a jumble of words (no clear structure, no sentences, just words)
|
| 159 |
+
# Count sentences (periods, exclamation marks, question marks)
|
| 160 |
+
sentence_count = response.count('.') + response.count('!') + response.count('?')
|
| 161 |
+
if sentence_count < 10 and word_count > 200:
|
| 162 |
+
# Response has many words but few sentences - might be a jumble
|
| 163 |
+
# Check if there are enough paragraphs (double newlines or line breaks)
|
| 164 |
+
paragraph_count = response.count('\n\n') + response.count('\r\n\r\n')
|
| 165 |
+
if paragraph_count < 3:
|
| 166 |
+
# Response seems like a jumble - not enough structure
|
| 167 |
+
return self._request_fix(response, query, aggregates_str)
|
| 168 |
+
|
| 169 |
# Check if response seems too generic or just a list of examples (doesn't contain analysis)
|
| 170 |
has_numbers = any(char.isdigit() for char in response)
|
| 171 |
has_analysis_terms = any(term in response for term in [
|