geronimo-pericoli
commited on
Commit
•
472de85
1
Parent(s):
154614f
Update app.py
Browse files
app.py
CHANGED
@@ -345,7 +345,7 @@ def ctx_relevancy_eval():
|
|
345 |
# Extraer los textos de los source nodes
|
346 |
contexts = []
|
347 |
for node in source_nodes:
|
348 |
-
if node.score <=
|
349 |
text = node.node.text.strip()
|
350 |
contexts.append(text)
|
351 |
|
@@ -367,30 +367,12 @@ def ctx_relevancy_eval():
|
|
367 |
def faithfulness_eval():
|
368 |
global final_response
|
369 |
global query
|
370 |
-
|
371 |
-
# Verificamos si 'final_response' tiene el atributo 'source_nodes'
|
372 |
-
if not hasattr(final_response, 'source_nodes'):
|
373 |
-
raise AttributeError("El objeto 'final_response' no tiene un atributo 'source_nodes'.")
|
374 |
-
|
375 |
-
# Obtener los source_nodes de la respuesta
|
376 |
-
source_nodes = final_response.source_nodes
|
377 |
-
|
378 |
-
# Extraer los textos de los source nodes
|
379 |
-
contexts = []
|
380 |
-
for node in source_nodes:
|
381 |
-
if node.score <= 1: # Excluir nodos con score > 1
|
382 |
-
text = node.node.text.strip()
|
383 |
-
contexts.append(text)
|
384 |
-
|
385 |
-
# Si no se encuentran textos en los source nodes, puedes manejarlo de alguna forma
|
386 |
-
if not contexts:
|
387 |
-
raise ValueError("No se encontraron textos en los source nodes.")
|
388 |
-
|
389 |
evaluator = FaithfulnessEvaluator(llm=gpt4omini)
|
390 |
-
eval_result = evaluator.evaluate_response(query=query, response=final_response
|
391 |
|
392 |
print("Groundedness: " + str(eval_result.score) + " - " + str(eval_result.passing) + "\n")
|
393 |
-
print("Respuesta: " + str(final_response) + "\n
|
|
|
394 |
return float(eval_result.score)
|
395 |
|
396 |
def ans_relevancy_eval():
|
|
|
345 |
# Extraer los textos de los source nodes
|
346 |
contexts = []
|
347 |
for node in source_nodes:
|
348 |
+
if node.score <= 10000: # Excluir nodos con score > 10000
|
349 |
text = node.node.text.strip()
|
350 |
contexts.append(text)
|
351 |
|
|
|
367 |
def faithfulness_eval():
|
368 |
global final_response
|
369 |
global query
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
evaluator = FaithfulnessEvaluator(llm=gpt4omini)
|
371 |
+
eval_result = evaluator.evaluate_response(query=query, response=final_response.response)
|
372 |
|
373 |
print("Groundedness: " + str(eval_result.score) + " - " + str(eval_result.passing) + "\n")
|
374 |
+
print("Respuesta: " + str(final_response) + "\n")
|
375 |
+
print("Query: " + str(query) + "\n\n----------")
|
376 |
return float(eval_result.score)
|
377 |
|
378 |
def ans_relevancy_eval():
|