Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What it does
Implements support for creating assistants ("agents") for Theia-based applications via integrating AI (more specifically "LLM") support as optionally consumable Theia extensions, a.k.a "Theia AI"
The base functionality is provided by the following extensions:
ai-core
contains the basic LLM integration and defines the core concepts for interacting with LLM via agents, prompts and variables.ai-chat
builts on top to define a model for chat like conversations.ai-chat-ui
provides the actual Chat UI.The AI integration was built from the ground up to be flexible, inspectible, customizable and configurable. More precisely, we want to follow these core principles:
This feature is still highly experimental. We will actively continue to develop this feature. However, we want to provide early access to potential adopters and users of the Theia IDE. Therefore, even when the AI extensions are included in a Theia based application, they are turned off by default and need to be enabled in the preferences. The preferences include a convenient turn all AI features off setting.
Additional features and integrations are offered by the remaining
extensions:
ai-history
offers a service to record requests and responses. The recordings can be inspected via the 'AI History View'.ai-code-completion
offers AI based code completion via completion items and inline suggestions.ai-terminal
offers a specialized AI for the Theia terminal which will suggest commands to execute.ai-workspace-agent
is a specialized agent which is able to inspect the current workspace content for context specific questions.ai-openai
integrates the LLM offerings of Open AI into Theia as an LLM providerHow to test
browser-only
, they can't be tested without integrating a browser-only LLMOPENAI_API_KEY
environment variable set, then configure your API key in the preferencesDemo examples
Chat View
Terminal
Architecture
The following diagram gives a rough overview over the architecture and the intended communication paths
Chat Flow
ChatService
ChatService
resolves variables, if there are any in the request, and determines the agent to use. It invokes theChatAgentService
to do soPromptService
to receive its basic prompt. ThePromptService
may return the originally registered prompt or a user modified variantLanguageModelRegistry
. The user is able to manually specify which specific LLM shall be used within the "AI Configuration" viewChatResponsePart
sChatResponsePartRenderer
s within the UI take over the rendering of the parts. The registry can be contributed to by developers.Chat Flow Considerations
CommunicatonRecordingService
which brings its own "AI History" viewDelegating Agent
DelegatingChatAgent
. It will invoke an LLM itself to determine which agent shall handle the current request@AgentName
within the chat requestOther Flows and Considerations
Contrary to VS Code we don't force all LLM integrations through the ChatFlow.
Agent
s are not necessarilyChatAgent
s and can therefore provide customized API tailored to specific use cases. In this first contribution we implemented aCodeCompletionAgent
as well as aTerminalAgent
which are specialized for their use cases and can't be used in Chat.Still all agents can participate in global services like the AI History, whether they are chat related or not.
All of the features and concepts are optional. If some developer only wants to use the LLM base layer to invoke their own specialized LLM without going through chats, prompts etc., then this of course possible.
Frontend / Backend Split
The diagram above gives a rough overview over the frontend/backend split.
common
base implementation and can therefore be bound and used in both the frontend and the backend. This is marked in orange in the diagramcommon
implementation but a specialized one, integrating features only available in the frontend. For example as preferences and the workspace are frontend concepts, the respective services only respect these customization in the frontend.browser-only
. However in this initial contribution we only include Open AI bindings for the backend.Follow-ups
As noted above, this contribution is highly experimental. Therefore there are a lot of known issues and potential followups. We still think that this contribution is already valuable enough to be included in Theia.
Incomplete list of follow up topics:
Many more features and improvements can be made. We will continue to actively develop this feature, however we think the current code is ready to be evaluated by the community.
We already implemented POCs for an Llamafile integration, RAG based variable resolving as well specialized agents like a "PR Finalization Agent". However these are not yet stable enough to be part of the initial contribution.
We are excited what the future will bring and which concepts and ideas will be contributed by the community.
Review checklist
Reminder for reviewers