-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Describe the bug
If you run a graph such as the SearchGraph, the only outputs from the graph_exec_info are from the SearchGraph, but that doesn't include the child SmartScraperGraph instance used by the GraphIteratorNode. Since the GraphIteratorNode is likely using most of the tokens that the model actually needs, this could lead to people massively underestimating how much they're spending on queries/ tokens.
To Reproduce
Here's code to reproduce the issue:
import json
from scrapegraphai.utils import prettify_exec_info
from scrapegraphai.graphs import SearchGraph
graph_config = {
"llm": {
"model": "gpt-4o-mini",
},
"verbose": True,
"headless": True,
"max_results": 5
}
product_name_1 = 'Sony WH1000XM4 Wireless Noise Canceling Over-Ear Headphones - Black'
product_name_2 = 'Sony WH1000XM5 Wireless Noise Canceling Over-Ear Headphones - Black'
search_graph = SearchGraph(
prompt=f"Are these 2 products the same product? Here are the two products:\nProduct 1: {product_name_1}\nProduct 2: {product_name_2}\nYour output should be exactly 'yes' or 'no'.",
config=graph_config
)
result = search_graph.run()
print(json.dumps(result, indent=4))
graph_exec_info = search_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
** Exec Info output:
node_name total_tokens prompt_tokens completion_tokens successful_requests total_cost_USD exec_time
0 SearchInternet 231 213 18 1 0.000043 3.495771
1 GraphIterator 0 0 0 0 0.000000 4.696635
2 MergeAnswers 245 236 9 1 0.000041 0.364202
3 TOTAL RESULT 476 449 27 2 0.000084 8.556608

Expected behavior
I'd expect the GraphIterator to show the tokens that it used instead of 0. Alternatively, it should find all of the subgraphs used during the running of this graph and either print those within this graph_exec_info ie. 0 SearchInternet 1 GraphIterator 2 SmartScraperGraph 3...