trustgraph/trustgraph-flow/trustgraph
Cyber MacGeddon 56d700f301 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
2026-04-13 14:34:02 +01:00
..
agent Expose LLM token usage (in_token, out_token, model) across all 2026-04-13 14:34:02 +01:00
chunking RabbitMQ pub/sub backend with topic exchange architecture (#752) 2026-04-02 12:47:16 +01:00
config/service Config push notify pattern: replace stateful pub/sub with signal+ fetch (#760) 2026-04-06 16:57:27 +01:00
cores Subscriber resilience and RabbitMQ fixes (#765) 2026-04-07 14:51:14 +01:00
decoding RabbitMQ pub/sub backend with topic exchange architecture (#752) 2026-04-02 12:47:16 +01:00
direct Fix Cassandra schema and graph filter semantics (#680) 2026-03-10 12:52:51 +00:00
embeddings Config push notify pattern: replace stateful pub/sub with signal+ fetch (#760) 2026-04-06 16:57:27 +01:00
external Implement logging strategy (#444) 2025-07-30 23:18:38 +01:00
extract Expose LLM token usage (in_token, out_token, model) across all 2026-04-13 14:34:02 +01:00
gateway Fix Metadata/EntityEmbeddings schema migration tail and add regression tests (#777) 2026-04-10 20:43:45 +01:00
librarian Subscriber resilience and RabbitMQ fixes (#765) 2026-04-07 14:51:14 +01:00
metering Subscriber resilience and RabbitMQ fixes (#765) 2026-04-07 14:51:14 +01:00
model Feat: Auto-pull missing Ollama models (#757) 2026-04-06 11:10:53 +01:00
processing Fix/startup failure (#445) 2025-07-30 23:42:11 +01:00
prompt Expose LLM token usage (in_token, out_token, model) across all 2026-04-13 14:34:02 +01:00
query Config push notify pattern: replace stateful pub/sub with signal+ fetch (#760) 2026-04-06 16:57:27 +01:00
retrieval Expose LLM token usage (in_token, out_token, model) across all 2026-04-13 14:34:02 +01:00
rev_gateway Messaging fabric plugins (#592) 2025-12-17 21:40:43 +00:00
storage Config push notify pattern: replace stateful pub/sub with signal+ fetch (#760) 2026-04-06 16:57:27 +01:00
tables Fix Metadata/EntityEmbeddings schema migration tail and add regression tests (#777) 2026-04-10 20:43:45 +01:00
template Feature/prompts jsonl (#619) 2026-01-26 17:38:00 +00:00
tool_service Tool services - dynamically pluggable tool implementations for agent frameworks (#658) 2026-03-04 14:51:32 +00:00
__init__.py Feature/pkgsplit (#83) 2024-09-30 19:36:09 +01:00