ParseLLMEvent parses raw LLM request/response JSON into a structured LLMEvent. eventType is "request" or "response"; format is "openai", "claude", or "openai-responses".
(rawJSON []byte, eventType, format string)
| 14 | // ParseLLMEvent parses raw LLM request/response JSON into a structured LLMEvent. |
| 15 | // eventType is "request" or "response"; format is "openai", "claude", or "openai-responses". |
| 16 | func ParseLLMEvent(rawJSON []byte, eventType, format string) *implantpb.LLMEvent { |
| 17 | ev := &implantpb.LLMEvent{ |
| 18 | Type: eventType, |
| 19 | Format: format, |
| 20 | } |
| 21 | |
| 22 | f := GetFormat(format) |
| 23 | if f == nil { |
| 24 | return ev |
| 25 | } |
| 26 | switch eventType { |
| 27 | case "request": |
| 28 | ev.Model = gjson.GetBytes(rawJSON, "model").String() |
| 29 | f.ParseRequest(rawJSON, ev) |
| 30 | case "response": |
| 31 | ev.Model = gjson.GetBytes(rawJSON, "model").String() |
| 32 | f.ParseResponse(rawJSON, ev) |
| 33 | } |
| 34 | |
| 35 | return ev |
| 36 | } |
| 37 | |
| 38 | // parseRequest extracts model, message count, last N messages, and tool results from a request. |
| 39 | // Deprecated: use Format.ParseRequest instead. Kept for any external callers. |