Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Assist] Add in SSH context Assist endpoints #30319

Merged
merged 5 commits into from Aug 14, 2023

Conversation

jakule
Copy link
Contributor

@jakule jakule commented Aug 11, 2023

This change introduces web endpoints used by Assist to support SSH context functionality in the WebUI. Now a user will be able to generate Bash command and explain output in the terminal (like application logs).

Posthog events will be introduced in a following PR.

Closes https://github.com/gravitational/teleport.e/issues/1986

@jakule jakule requested review from ryanclark and xacrimon and removed request for ravicious and greedy52 August 11, 2023 01:00
// acknowledgement field is used to convince the LLM to return the JSON.
// Base on my testing LLM ignores the JSON when the schema has only one field.
// Adding additional "pseudo-fields" to the schema makes the LLM return the JSON.
return fmt.Sprintf(`Generate a Bash command.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we specify something other than bash here? Maybe we could feed the prompt the OS (if we have that available during an SSH session?)

If not, something more generic would avoid the assumption the user's shell is always bash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is something that we could explore "when needed". WebUI doesn't know what OS the client is using. I'm also not sure how good OpenAI is at generating commands for different terminals. I think that the bottom line, 98% of the syntax is the same between bash, sh, zsh, fish or whatever you're using. The differences are mainly when you write a script which we don't do.

Comment on lines +44 to +47
{
"command": string, \\ The generated command
"acknowledgement": boolean \\ Set to true to ackowledge that you understand the formatting
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not too familiar with the structure of Assist but could this generate markdown instead? We could stream it to the UI quickly if that was the case, with the suggested command going in between three backticks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OpenAI sends the markdown back most of the time.

Okay, so what is the response to my last comment? If using information obtained from the tools you must mention it explicitly without mentioning the tool names - I have forgotten all TOOL RESPONSES! Remember to respond with a markdown code snippet of a json blob with a single action, and NOTHING else.`, toolResponse)

@jakule jakule requested a review from ryanclark August 11, 2023 17:41
@jakule
Copy link
Contributor Author

jakule commented Aug 14, 2023

Friendly ping @ryanclark @xacrimon

@xacrimon
Copy link
Contributor

xacrimon commented Aug 14, 2023

lgtm but tests seem to be failing, both units and flakies

This change introduces web endpoints used by Assist to support in SSH context functionality in the WebUI. Now a user will be able to generate Bash command and explain output in the terminal (like application logs).
This commit removes a redundant comment on the AI model selection in client.go that suggested a model change that is not needed. It also adds missing documentation in chat.go, to clarify the purpose and functionality of the Reply function.
Usage of the fake clock was failing the tests, and it's not really beneficial in this case.
@jakule jakule force-pushed the jakule/assist-in-ssh-context branch from 8c0cf6d to 608d3be Compare August 14, 2023 14:06
@jakule
Copy link
Contributor Author

jakule commented Aug 14, 2023

lgtm but tests seem to be failing, both units and flakies

Fixed. That was me fixing too many things at once 😒

@jakule jakule enabled auto-merge August 14, 2023 14:07
@jakule jakule added this pull request to the merge queue Aug 14, 2023
@jakule jakule removed this pull request from the merge queue due to a manual request Aug 14, 2023
@jakule jakule added this pull request to the merge queue Aug 14, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 14, 2023
@jakule jakule added this pull request to the merge queue Aug 14, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 14, 2023
@jakule jakule added this pull request to the merge queue Aug 14, 2023
Merged via the queue into master with commit e572328 Aug 14, 2023
22 checks passed
@jakule jakule deleted the jakule/assist-in-ssh-context branch August 14, 2023 19:25
jakule added a commit that referenced this pull request Aug 21, 2023
* Add in SSH context Assist endpoints

This change introduces web endpoints used by Assist to support in SSH context functionality in the WebUI. Now a user will be able to generate Bash command and explain output in the terminal (like application logs).

* Remove mockup web UI

* Make the linter happy

* Remove unnecessary comments and add missing documentation

This commit removes a redundant comment on the AI model selection in client.go that suggested a model change that is not needed. It also adds missing documentation in chat.go, to clarify the purpose and functionality of the Reply function.

* Revert ws.WriteControl to use real time.

Usage of the fake clock was failing the tests, and it's not really beneficial in this case.
github-merge-queue bot pushed a commit that referenced this pull request Aug 22, 2023
* assist: move embeddings in a separate library, add tool config, opportunistic node lookup (#29716)

* assist: extract embedding types into a dedicated module

* assist: allow the embedding tool to query nodes from proxy cache

This commit does two things:
- Introduce a new toolsConfig structure to pass all required clients to
  the tools. This can also be used to enable or disable specicifc tools,
  which helps with testing
- Pass the proxy node cache and the request access checker to the
  embedding tool so it can try to lookup nodes from cache in if the user
  has less than 10 nodes available.

* Add tests for the opportunistic proxy node lookup

* Apply suggestions from code review

* Update lib/ai/client.go

* [Assist] Add Assist to the terminal UI (#30496)

* Add Assist to the terminal UI

* Use getPlatform()

* Fix spacing beneath the message box

* [Assist] Add in SSH context Assist endpoints (#30319)

* Add in SSH context Assist endpoints

This change introduces web endpoints used by Assist to support in SSH context functionality in the WebUI. Now a user will be able to generate Bash command and explain output in the terminal (like application logs).

* Remove mockup web UI

* Make the linter happy

* Remove unnecessary comments and add missing documentation

This commit removes a redundant comment on the AI model selection in client.go that suggested a model change that is not needed. It also adds missing documentation in chat.go, to clarify the purpose and functionality of the Reply function.

* Revert ws.WriteControl to use real time.

Usage of the fake clock was failing the tests, and it's not really beneficial in this case.

* Replace caret symbol with Windows key in Terminal utility (#30642)

The caret symbol (^) previously used in the Terminal utility was not universally recognized or understanding. To increase usability, it has been replaced with the Windows key symbol (⊞). This should make the tool more intuitive to use for a wider range of users.

* [Assist] Add AssistAction and AssistAccessRequest PostHog event reporting (#30513)

* Add AssistAction and AssistAccessRequest PostHog event reporting

This commit introduced new usage tracking for Assist features. AssistAction event is emitted when user triggers an action like SSH command generation or output explaining. AssistAccessRequest event is fired when user requests access to a resource. The events capture anonymized username, resource type or action triggered, and a breakdown of tokens used for generating command summaries or completion responses.

* "Removed userName in AssistAccessRequest and AssistAction"

Both "AssistAccessRequest" and "AssistAction" messages in usageevents.proto file and their corresponding Go structures were modified to remove the "userName" field.

* Add GoDoc

---------

Co-authored-by: Hugo Shaka <hugo.hervieux@goteleport.com>
Co-authored-by: Ryan Clark <ryan.clark@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.

None yet

3 participants