Skip to content

Building 'Data Analyst Agent' via Agent Concept #13633

Answered by dosubot bot
mraguth asked this question in Q&A
Discussion options

You must be logged in to vote

To measure the token usage for the agent's actions in your current setup, you can integrate the TokenCountingHandler from the LlamaIndex library. Here is the modified version of your code with the TokenCountingHandler integrated:

import pandas as pd
from llama_index.agent.openai import OpenAIAgent
from llama_index.llms.openai import OpenAI
from llama_index.experimental.query_engine.pandas import PandasQueryEngine
from llama_index.core.schema import QueryBundle
from llama_index.core.callbacks import CallbackManager, TokenCountingHandler
import tiktoken

# Sample DataFrame
data = {
    'Name': ['Alice', 'Bob', 'Charlie', 'David'],
    'Age': [24, 30, 22, 35],
    'Salary': [70000, 80000, 6…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@mraguth
Comment options

@dosubot
Comment options

@mraguth
Comment options

@dosubot
Comment options

Answer selected by mraguth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant