mirror of
https://github.com/AJaySi/ALwrity.git
synced 2026-04-26 09:25:55 +03:00
[PR #421] [MERGED] Add standardized structured routing logs for LLM text requests #723
Labels
No labels
AI Content Agents
AI Content Strategy
AI Content planning
AI Marketing Tools
AI SEO
AI personalization
AI writer
ALwrity Copi-lot
Alwrity web search
Anthropic
DeepSeek
Gemini AI
Integration
LLM
OnBoarding
OnBoarding
RAG knowledgebase Memory
bug
documentation
enhancement
good first issue
help wanted
invalid
openai
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ALwrity#723
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/AJaySi/ALwrity/pull/421
Author: @AJaySi
Created: 3/12/2026
Status: ✅ Merged
Merged: 3/12/2026
Merged by: @AJaySi
Base:
main← Head:codex/add-structured-logging-to-text-generation📝 Commits (1)
d01d4afAdd standardized structured routing logs for text generation📊 Changes
3 files changed (+146 additions, -7 deletions)
View changed files
📝
backend/services/llm_providers/huggingface_provider.py(+54 -3)📝
backend/services/llm_providers/main_text_generation.py(+46 -4)📝
backend/utils/logger_utils.py(+46 -0)📄 Description
Motivation
Description
emit_routing_eventhelper inbackend/utils/logger_utils.pythat emits a JSON payload with fields includingflow_type/route_intent,provider_selected,model_selected,preferred_provider,fallback_count,fallback_models_tried, and a hashedtenant_user_id(stable SHA256 prefix).llm_text_geninbackend/services/llm_providers/main_text_generation.pyto initialize routing state (flow_type,preferred_provider,fallback_count,fallback_models_tried) and callemit_routing_eventfor the primary selection and when a single fallback is attempted, and to passtenant_user_idinto provider calls.backend/services/llm_providers/huggingface_provider.pyto accepttenant_user_idon bothhuggingface_text_responseandhuggingface_structured_json_response, emit per-attempt routing events for each candidate model (primary and fallback attempts), and include the retry/no-response_formatfallback path in emitted events.get_service_loggerand allowemit_routing_eventto acceptextrapayload fields and a loglevelfor flexibility.Testing
python -m py_compile backend/utils/logger_utils.py backend/services/llm_providers/main_text_generation.py backend/services/llm_providers/huggingface_provider.py, which completed successfully with no syntax errors.Codex Task
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.