fix(graph): report the effective token window in execution info by Ebenezer-03 · Pull Request #1147 · ScrapeGraphAI/Scrapegraph-ai · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scrapegraphai/graphs/abstract_graph.py
8 changes: 8 additions & 0 deletions scrapegraphai/graphs/base_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def __init__(
self.graph_name = graph_name
self.initial_state = {}
self.callback_manager = CustomLLMCallbackManager()
# Effective input-token window used to chunk documents, and whether it
# is the 8192 fallback rather than the model's real limit. AbstractGraph
# fills these in after building the graph; they are reported in the
# "TOTAL RESULT" entry of the execution info (see #1121).
self.model_token = None
self.model_tokens_defaulted = False

if nodes[0].node_name != entry_point.node_name:
warnings.warn(
Expand Down Expand Up @@ -316,6 +322,8 @@ def _execute_standard(self, initial_state: dict) -> Tuple[dict, list]:
"successful_requests": cb_total["successful_requests"],
"total_cost_USD": cb_total["total_cost_USD"],
"exec_time": total_exec_time,
"effective_model_tokens": self.model_token,
"model_tokens_defaulted": self.model_tokens_defaulted,
}
)

Expand Down
76 changes: 76 additions & 0 deletions tests/graphs/abstract_graph_test.py