Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,30 +36,29 @@ def process_course(input_text):
|
|
| 36 |
stored_HTMLs = chunk_HTMLs(input_text)
|
| 37 |
|
| 38 |
results = []
|
| 39 |
-
|
| 40 |
-
# First analysis
|
| 41 |
for html_id, html_content in stored_HTMLs.items():
|
|
|
|
|
|
|
|
|
|
| 42 |
messages = [
|
| 43 |
-
{"role": "system", "content": "Analyseer het perspectief van deze tekst, bedoeld voor zorgprofessionals.
|
| 44 |
{"role": "user", "content": html_content}
|
| 45 |
]
|
| 46 |
oordeel = api_call(messages)
|
| 47 |
-
results.append(
|
| 48 |
|
| 49 |
-
|
| 50 |
-
if "deels zorgvrager" in oordeel: # Replace "specific criterion" with your actual condition
|
| 51 |
-
# Prepare a second API call for the individual HTML chunk
|
| 52 |
follow_up_messages = [
|
| 53 |
-
{"role": "system", "content":
|
| 54 |
-
Citaat: [citaat van zin(nen) met foute doelgroep]
|
| 55 |
-
Correctie: [gecorrigeerde zin(nen)]
|
| 56 |
-
Verander hierbij zo min mogelijk aan de rest van de zin, verander alleen de doelgroep."""},
|
| 57 |
{"role": "user", "content": html_content}
|
| 58 |
]
|
| 59 |
follow_up_result = api_call(follow_up_messages, 0.7)
|
| 60 |
-
results.append(
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
| 63 |
return results_string
|
| 64 |
|
| 65 |
|
|
|
|
| 36 |
stored_HTMLs = chunk_HTMLs(input_text)
|
| 37 |
|
| 38 |
results = []
|
| 39 |
+
last_html_id = None # Track the last processed HTML ID
|
|
|
|
| 40 |
for html_id, html_content in stored_HTMLs.items():
|
| 41 |
+
if last_html_id and html_id != last_html_id:
|
| 42 |
+
results.append("\n") # Add extra newline for a new HTML ID group
|
| 43 |
+
|
| 44 |
messages = [
|
| 45 |
+
{"role": "system", "content": "Analyseer het perspectief van deze tekst, bedoeld voor zorgprofessionals."},
|
| 46 |
{"role": "user", "content": html_content}
|
| 47 |
]
|
| 48 |
oordeel = api_call(messages)
|
| 49 |
+
results.append(f"{html_id}: {oordeel}")
|
| 50 |
|
| 51 |
+
if "deels zorgvrager" in oordeel:
|
|
|
|
|
|
|
| 52 |
follow_up_messages = [
|
| 53 |
+
{"role": "system", "content": "Follow-up content..."},
|
|
|
|
|
|
|
|
|
|
| 54 |
{"role": "user", "content": html_content}
|
| 55 |
]
|
| 56 |
follow_up_result = api_call(follow_up_messages, 0.7)
|
| 57 |
+
results.append(f"{html_id} - Follow-up: {follow_up_result}")
|
| 58 |
+
|
| 59 |
+
last_html_id = html_id # Update the last processed HTML ID after handling
|
| 60 |
+
|
| 61 |
+
results_string = '\n'.join(results) # Use single newline for final join
|
| 62 |
return results_string
|
| 63 |
|
| 64 |
|