documents = SimpleDirectoryReader(directory).load_data() llm_predictor = MockLLMPredictor(max_tokens=256) service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor) index = GPTTreeIndex.from_documents(documents, service_context=service_context) print(llm_predictor.last_token_usage)
INFO:llama_index.indices.common.tree.base:> Building index from nodes: 4 chunks INFO:llama_index.token_counter.token_counter:> [build_index_from_nodes] Total LLM token usage: 17442 tokens INFO:llama_index.token_counter.token_counter:> [build_index_from_nodes] Total embedding token usage: 0 tokens