import asyncio from typing import Any from llama_index.core.agent.workflow import FunctionAgent from llama_index.core.base.llms.types import ( ChatMessage, ChatResponse, CompletionResponse, LLMMetadata, MessageRole, ) from llama_index.core.llms.function_calling import FunctionCallingLLM from llama_index.core.llms.llm import ToolSelection TOOL_CALL_LOG: list[str] = [] TOOL_RESULT_LOG: list[str] = [] def get_invoice_total(invoice_id: str) -> str: """Return the approved total for an invoice ID.""" total = {"INV-1024": "$184.50"}[invoice_id] result = f"The approved total for {invoice_id} is {total}." TOOL_CALL_LOG.append(f"get_invoice_total(invoice_id={invoice_id})") TOOL_RESULT_LOG.append(result) return result