nic-6443 opened a new pull request, #13609:
URL: https://github.com/apache/apisix/pull/13609

   ### Description
   
   The `ai-proxy` / `ai-proxy-multi` observability variables — streaming flag, 
tool count / tool-call detection, end-user id, cache read/creation tokens, 
reasoning tokens and content risk level — are already exposed as `$llm_*` 
access-log variables, but they were never added to the `llm_summary` object 
that logger plugins consume.
   
   So even though the data is computed per request, capturing it in a logger 
(kafka-logger, clickhouse-logger, etc.) required adding each `$llm_*` variable 
to that plugin's `log_format` by hand. The summary, which is meant to be the 
ready-to-log AI digest, only carried model / duration / prompt / completion / 
total tokens / upstream time.
   
   This adds the remaining variables to `llm_summary` (with the `llm_` prefix 
stripped, matching the existing keys), so loggers receive the full summary 
automatically:
   
   `stream`, `tool_count`, `has_tool_calls`, `end_user_id`, 
`cache_read_input_tokens`, `cache_creation_input_tokens`, `reasoning_tokens`, 
`content_risk_level`.
   
   The values are read the same way as the existing summary fields 
(`ctx.var.llm_*`), so unset ones are simply absent. It's additive and backward 
compatible. Also documented the variables in `ai-proxy` / `ai-proxy-multi` and 
extended `t/plugin/ai-proxy-kafka-log.t` to assert the new fields appear in the 
logged summary.
   
   #### Which issue(s) this PR fixes:
   
   N/A
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to