Skip to content

stream audit query responses#31092

Merged
hugoShaka merged 3 commits intomasterfrom
hugo/assist-stream-audit-query
Aug 30, 2023
Merged

stream audit query responses#31092
hugoShaka merged 3 commits intomasterfrom
hugo/assist-stream-audit-query

Conversation

@hugoShaka
Copy link
Copy Markdown
Contributor

This PR makes the audit query generation tool return streaming messages.

It extracts the existing streaming logic in lib/ai/model/output/streaming.go so it can be used both by the main agent and by the tools. It also removes the stale tokenizer field from the ai.Chat struct.

@hugoShaka hugoShaka requested review from jakule and xacrimon August 28, 2023 15:13
@github-actions github-actions Bot requested a review from avatus August 28, 2023 15:13
@hugoShaka hugoShaka force-pushed the hugo/assist-stream-audit-query branch from efeae34 to 2f65b9f Compare August 28, 2023 19:33
Comment thread lib/ai/model/output/messages.go
// 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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this function need to be public? For me, it sounds like some internal helper that should not be called outside of the module.

Copy link
Copy Markdown
Contributor Author

@hugoShaka hugoShaka Aug 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

@hugoShaka hugoShaka Aug 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here, it sounds more like an internal helper rather than something that can be used outside of this module.

Comment thread lib/ai/model/output/streaming.go
@hugoShaka hugoShaka requested a review from jakule August 30, 2023 18:32
@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from xacrimon August 30, 2023 19:39
@hugoShaka hugoShaka added this pull request to the merge queue Aug 30, 2023
Merged via the queue into master with commit bfae370 Aug 30, 2023
@hugoShaka hugoShaka deleted the hugo/assist-stream-audit-query branch August 30, 2023 20:00
jakule pushed a commit that referenced this pull request Oct 18, 2023
* stream audit query responses

* fixup! stream audit query responses

* fixup! fixup! stream audit query responses
github-merge-queue Bot pushed a commit that referenced this pull request Oct 19, 2023
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants