-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Theia AI LLM Support [Experimental] #14048
Theia AI LLM Support [Experimental] #14048
Conversation
} | ||
|
||
export interface LanguageModel extends LanguageModelMetaData { | ||
request(request: LanguageModelRequest): Promise<LanguageModelResponse>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Some vendors explicitly support code-completion/generation/fill-in-the-middle functionality. Is it planned to have a dedicated LanguageModelRequest
type or maybe a dedicated function here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! From a technical standpoint both approaches are feasible, covering all use cases in request
with flexible input and output parameters or implementing different functions.
For now all use cases were similar enough that they did not warrant a separate function however that might change with new use cases or other architectural considerations.
Update: @dhuebner contributed an initial Ollama integration to this contribution. The ollama integration allows to specify the URL on which to contact ollama and the respective model id. This is very nice as it allows to run and test the AI integration locally. Note that this is a barebones integration, for example the "tool" integration is missing which is used by the workspace agent. Therefore some of the features are restricted when using Ollama. These are the suggested follow ups:
|
Hi @tsmaeder Thank you so much for the great and very detailed review ❤️ ! I tackled the major part of the smaller to medium review comments in commit 566b447 and marked them as resolved. I answered on all review questions. For everything which is not yet covered I suggest to move the topic to this follow up #14143. I posted a link to the follow up on all relevant review comments. Merging the current state allows for easier contributions and smaller PRs going forward. So if you are fine with the current state and the suggested follow ups, then please approve. I'll squash to two commits then, the initial EclipseSource contribution and @dhuebner's Ollama support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can merge the PR as an experimental feature and address the follow-ups at a later stage.
Implements AI LLM support via optionally consumable Theia extensions. The base functionality is provided by the following extensions: - @theia/ai-core - @theia/ai-chat - @theia/ai-chat-ui '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. This feature is still highly experimental. 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 on/off" setting. Additional features and integrations are offered by the remaining extensions: - @theia/ai-history - @theia/ai-code-completion - @theia/ai-terminal - @theia/ai-workspace-agent - @theia/ai-openai '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. Co-authored-by: Alexandra Muntean <amuntean@eclipsesource.com> Co-authored-by: Camille Letavernier <cletavernier@eclipsesource.com> Co-authored-by: Christian W. Damus <cdamus.ext@eclipsesource.com> Co-authored-by: Eugen Neufeld <neufeld.eugen@googlemail.com> Co-authored-by: Haydar Metin <hmetin@eclipsesource.com> Co-authored-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com> Co-authored-by: Jonas Helming <jhelming@eclipsesource.com> Co-authored-by: Lucas Koehler <lkoehler@eclipsesource.com> Co-authored-by: Martin Fleck <mfleck@eclipsesource.com> Co-authored-by: Maximilian Koegel <mkoegel@eclipsesource.com> Co-authored-by: Nina Doschek <ndoschek@eclipsesource.com> Co-authored-by: Olaf Lessenich <olessenich@eclipsesource.com> Co-authored-by: Philip Langer <planger@eclipsesource.com> Co-authored-by: Remi Schnekenburger <rschnekenburger@eclipsesource.com> Co-authored-by: Simon Graband <sgraband@eclipsesource.com> Co-authored-by: Tobias Ortmayr <tortmayr@eclipsesource.com>
4d96c19
to
1a32b06
Compare
I squashed the contribution into two separate commits:
No further changes were done in the force push. @tsmaeder Can you rebase-merge? Thank you! Let me know in case you would like to see different commit messages |
Integrates Ollama language models into Theia via the new 'ai-ollama' package. The endpoint and models can be configured via the preferences.
1a32b06
to
9e857c4
Compare
I forced pushed once more as the license check failed. There were minor |
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
Prompt Editing
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" viewOrchestrator Agent
Orchestrator
. It will invoke an LLM itself to determine which agent shall handle the current request@AgentName
within the chat request or by specifying another default agent in the preferencesOther 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
Addendum
@dhuebner contributed an initial Ollama integration which allows to use locally executed models. See here for more information.