mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Expose LLM token usage (in_token, out_token, model) across all service layers Propagate token counts from LLM services through the prompt, text-completion, graph-RAG, document-RAG, and agent orchestrator pipelines to the API gateway and Python SDK. All fields are Optional — None means "not available", distinguishing from a real zero count. Key changes: - Schema: Add in_token/out_token/model to TextCompletionResponse, PromptResponse, GraphRagResponse, DocumentRagResponse, AgentResponse - TextCompletionClient: New TextCompletionResult return type. Split into text_completion() (non-streaming) and text_completion_stream() (streaming with per-chunk handler callback) - PromptClient: New PromptResult with response_type (text/json/jsonl), typed fields (text/object/objects), and token usage. All callers updated. - RAG services: Accumulate token usage across all prompt calls (extract-concepts, edge-scoring, edge-reasoning, synthesis). Non-streaming path sends single combined response instead of chunk + end_of_session. - Agent orchestrator: UsageTracker accumulates tokens across meta-router, pattern prompt calls, and react reasoning. Attached to end_of_dialog. - Translators: Encode token fields when not None (is not None, not truthy) - Python SDK: RAG and text-completion methods return TextCompletionResult (non-streaming) or RAGChunk/AgentAnswer with token fields (streaming) - CLI: --show-usage flag on tg-invoke-llm, tg-invoke-prompt, tg-invoke-graph-rag, tg-invoke-document-rag, tg-invoke-agent |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| conftest.py | ||
| test_agent_service_non_streaming.py | ||
| test_agent_step_arguments.py | ||
| test_aggregator.py | ||
| test_callback_message_id.py | ||
| test_completion_dispatch.py | ||
| test_conversation_state.py | ||
| test_explainability_parsing.py | ||
| test_mcp_tool_auth.py | ||
| test_meta_router.py | ||
| test_on_action_callback.py | ||
| test_orchestrator_provenance_integration.py | ||
| test_parse_chunk_message_id.py | ||
| test_pattern_base_subagent.py | ||
| test_provenance_triples.py | ||
| test_react_processor.py | ||
| test_reasoning_engine.py | ||
| test_tool_coordination.py | ||
| test_tool_filter.py | ||
| test_tool_service.py | ||
| test_tool_service_lifecycle.py | ||