I am using the below sql_agent to query through my database:
agent = create_sql_agent(llm=llm, toolkit=sql_toolkit, agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
handle_parsing_errors=True, verbose=True, max_execution_time=200,
max_iterations=1000)
response = agent.run(prompt.format_prompt(question=query))
Is there any way to count the total number of tokens(prompt tokens+query tokens+query_result tokens+thought tokens+action tokens+observation tokens+tool tokens) used by this agent.
I have used the below approach without good results: https://python.langchain.com/docs/modules/model_io/llms/token_usage_tracking When I try to verify the number of output tokens result with openai website, the number of tokens are off by large margin. for example: Output of the tried approach