Spaces:
Runtime error
Runtime error
Edit output (add list sources)
Browse files
main.py
CHANGED
@@ -163,21 +163,28 @@ async def process_court_decision(url, question, progress=gr.Progress()):
|
|
163 |
unique_citations = sorted(set(citations), key=int)
|
164 |
|
165 |
# Prepare output
|
166 |
-
output = f"**Правова
|
167 |
output += f"**Відповідь ШІ:**\n{result.response}\n\n"
|
168 |
|
169 |
-
output += "**Цитовані
|
170 |
-
for citation in unique_citations:
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
progress(1.0, desc="Complete!")
|
176 |
-
return
|
177 |
except Exception as e:
|
178 |
return f"Error processing court decision: {str(e)}"
|
179 |
|
180 |
-
|
181 |
# Also, add the extract_court_decision_text function if it's not already there
|
182 |
def extract_court_decision_text(url):
|
183 |
response = requests.get(url)
|
|
|
163 |
unique_citations = sorted(set(citations), key=int)
|
164 |
|
165 |
# Prepare output
|
166 |
+
output = f"**Правова позиція нового судового рішення:**\n{legal_position_json['Title']}: {legal_position_json['Legal_position']}\n\n"
|
167 |
output += f"**Відповідь ШІ:**\n{result.response}\n\n"
|
168 |
|
169 |
+
output += "**Цитовані джерела існуючих правових позицій Верховного Суду:**\n"
|
170 |
+
# for citation in unique_citations:
|
171 |
+
# citation_index = int(citation) - 1
|
172 |
+
# if 0 <= citation_index < len(result.source_nodes):
|
173 |
+
# output += f"[{citation}]: {result.source_nodes[citation_index].node.metadata['title']}\n"
|
174 |
+
|
175 |
+
# Display each source node with its title and score in Gradio
|
176 |
+
sources_output = ""
|
177 |
+
for index, node in enumerate(result.source_nodes, start=1):
|
178 |
+
sources_output += f"[{index}] {node.metadata['title']} 👉 {node.get_score()} \n\n"
|
179 |
+
|
180 |
+
# Combine main output and sources output
|
181 |
+
final_output = output + "\n\n" + sources_output
|
182 |
|
183 |
progress(1.0, desc="Complete!")
|
184 |
+
return final_output
|
185 |
except Exception as e:
|
186 |
return f"Error processing court decision: {str(e)}"
|
187 |
|
|
|
188 |
# Also, add the extract_court_decision_text function if it's not already there
|
189 |
def extract_court_decision_text(url):
|
190 |
response = requests.get(url)
|