Skip to content

Python scraper based on AI

fixed eval output

PeriniMcb8ed4fc5b7e
diff --git a/examples/graph_examples/graph_evaluation_example.py b/examples/graph_examples/graph_evaluation_example.py
index 5b086ff6..4691654d 100644
--- a/examples/graph_examples/graph_evaluation_example.py
+++ b/examples/graph_examples/graph_evaluation_example.py
@@ -27,7 +27,7 @@ list_of_inputs = [
# Create the TrulensEvaluator instance
trulens_evaluator = TrulensEvaluator(openai_key)
# Evaluate SmartScraperGraph on the list of inputs
-results_df = trulens_evaluator.evaluate(list_of_inputs, dashboard=False)
+(results_df, answer) = trulens_evaluator.evaluate(list_of_inputs, dashboard=False)
# Print the results
-print(results_df)
+print(answer)
diff --git a/scrapegraphai/evaluators/trulens_evaluator.py b/scrapegraphai/evaluators/trulens_evaluator.py
index 81dbca93..a06afc65 100644
--- a/scrapegraphai/evaluators/trulens_evaluator.py
+++ b/scrapegraphai/evaluators/trulens_evaluator.py
@@ -33,6 +33,8 @@ class TrulensEvaluator:
app_id="smart_scraper_evaluator",
feedbacks=[self.f_relevance,
self.f_custom_function])
+
+ self.graph_output = []
def evaluate(self, graph_params: list[tuple[str, str, dict]], dashboard: bool = True):
"""
@@ -44,14 +46,16 @@ class TrulensEvaluator:
Returns:
None
"""
+
with self.tru_llm_standalone_recorder as recording:
for params in graph_params:
output = SmartScraperGraph(*params).run()
self.tru_llm_standalone_recorder.app(params[0], output)
+ self.graph_output.append(output)
if dashboard:
self.tru.run_dashboard()
else:
- return self.tru.get_records_and_feedback(app_ids=[])[0]
+ return (self.tru.get_records_and_feedback(app_ids=[])[0], self.graph_output)
def llm_standalone(self, prompt, response):
"""