Conversation
efeae34 to
2f65b9f
Compare
| // StreamToDeltas converts an openai.CompletionStream into a channel of strings. | ||
| // This channel can then be consumed manually to search for specific markers, | ||
| // or directly converted into a StreamingMessage with NewStreamingMessage. | ||
| func StreamToDeltas(stream *openai.ChatCompletionStream) chan string { |
There was a problem hiding this comment.
Does this function need to be public? For me, it sounds like some internal helper that should not be called outside of the module.
There was a problem hiding this comment.
lib/ai/model and lib/ai/model/tools need to do this and are in separate packages. I don't think we need to expose this outside of lib/ai/model/... though. lib/ai/model manually processes the deltas, while lib/ai/model/tools can create the streaming message directly, so we can't make a single StreamtoStramingMessage() function
There was a problem hiding this comment.
I can create a new lib/ai/model/utils package, or a lib/ai/model/internal one
| // (like a marker to identify the kind of response the model is providing), | ||
| // the prefix can be passed through the prefix parameter. It will be stripped | ||
| // but will still be reflected in the token count. | ||
| func NewStreamingMessage(deltas <-chan string, alreadyStreamed, prefix string) (*StreamingMessage, *tokens.AsynchronousTokenCounter, error) { |
There was a problem hiding this comment.
The same here, it sounds more like an internal helper rather than something that can be used outside of this module.
* stream audit query responses * fixup! stream audit query responses * fixup! fixup! stream audit query responses
* Add the ability to run a specific tool to Assist. (#31112) This commit contains: - a refactoring of the model action logic to be exposed through the `DoAction` function - Expose `RunTool()` capability through ai.Client and assist.Assist - Add the "audit-query" action that invokes directly the audit generation tool * stream audit query responses (#31092) * stream audit query responses * fixup! stream audit query responses * fixup! fixup! stream audit query responses --------- Co-authored-by: Hugo Shaka <hugo.hervieux@goteleport.com>
This PR makes the audit query generation tool return streaming messages.
It extracts the existing streaming logic in
lib/ai/model/output/streaming.goso it can be used both by the main agent and by the tools. It also removes the stale tokenizer field from theai.Chatstruct.