Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,33 +82,30 @@ Q18: Is private sector experience allowed?
|
|
| 82 |
Q19: Do references need to be identified?
|
| 83 |
Q20: Is subcontracting permitted?
|
| 84 |
|
| 85 |
-
Answer clearly and in the same format:
|
| 86 |
-
Q1: ...
|
| 87 |
-
A1: ...
|
| 88 |
-
Q2: ...
|
| 89 |
-
A2: ...
|
| 90 |
...
|
| 91 |
"""
|
| 92 |
|
| 93 |
# 🧼 Cleaner
|
| 94 |
def clean_output(raw_output):
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
| 112 |
|
| 113 |
# 🚀 Main analysis function
|
| 114 |
@spaces.GPU(duration=150)
|
|
|
|
| 82 |
Q19: Do references need to be identified?
|
| 83 |
Q20: Is subcontracting permitted?
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
...
|
| 86 |
"""
|
| 87 |
|
| 88 |
# 🧼 Cleaner
|
| 89 |
def clean_output(raw_output):
|
| 90 |
+
# Find first valid Q1
|
| 91 |
+
start_idx = raw_output.find("Q1:")
|
| 92 |
+
if start_idx == -1:
|
| 93 |
+
return raw_output.strip()
|
| 94 |
+
|
| 95 |
+
cleaned = raw_output[start_idx:]
|
| 96 |
+
|
| 97 |
+
# Remove everything after second instance of Q1 (to drop repeated prompts)
|
| 98 |
+
second_q1 = cleaned.find("Q1:", 3) # skip first one
|
| 99 |
+
if second_q1 != -1:
|
| 100 |
+
cleaned = cleaned[:second_q1]
|
| 101 |
+
|
| 102 |
+
# Drop leftover instructions if they show up later
|
| 103 |
+
cut_phrases = ["You are an expert", "Now provide answers", "CONTENT:", "Answer clearly and in the same format:"]
|
| 104 |
+
for phrase in cut_phrases:
|
| 105 |
+
if phrase in cleaned:
|
| 106 |
+
cleaned = cleaned.split(phrase)[0]
|
| 107 |
+
|
| 108 |
+
return cleaned.strip()
|
| 109 |
|
| 110 |
# 🚀 Main analysis function
|
| 111 |
@spaces.GPU(duration=150)
|