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

fix: open ai messages #160

Closed
wants to merge 102 commits into from
Closed

fix: open ai messages #160

wants to merge 102 commits into from

Conversation

sdirix
Copy link
Member

@sdirix sdirix commented Aug 2, 2024

What it does

Fixes an edge case in message handling for open ai

How to test

  • post a question to see whether chat is working
  • remove all models in open ai settings
  • post another question in same thread, which triggers an error
  • reset all models
  • post another question in same thread

The LM should properly answer. Previously there was an error as a message sent to OpenAI API was null, resulting in a 400 error

Follow-ups

Review checklist

Reminder for reviewers

eneufeld and others added 30 commits May 13, 2024 13:38
- add ui
- add openai integration
- introduce ChatResponseParts
- LanguageModelProvider can be used in both backend and frontend
  - frontend access is generically implemented independent of the
    actual LanguageModelProvider implementation
- split code into four packages:
  - ai-agent: containing the AgentDispatcher. At the moment just
    delegates to the LanguageModelProvider. Can run in both frontend
    and backend
  - ai-chat: only containing the UI part of the chat.
  - ai-model-provider: containing the infrastructure of the
    LanguageModelProvider and its frontend bridge
  - ai-openao: only contains the Open AI LanguageModelProvider
Implements the LanguageModelProviderRegistry which is able to handle
an arbitrary number of LanguageModelProviders.

Refactors the LanguageModelProvider to only return a simple text or
stream of text. It's now the agent's responsibility to convert this
into response parts. Therefore the interfaces are also moved to the
agent package.

The LanguageModelProviderRegistry implementation for the frontend
handles all LanguageModelProvider registered in the frontend as well as
in the backend.

Fixes the StreamNode in the tree-widget to update itself correctly
when new tokens arrive.
Introduces ChatModel, including nested ChatRequestModel and
ChatResponseModel to represent chat sessions. The chat models allow to
inspect and track requests and their responses.

Also introduces the ChatService which can be used to manage chat
sessions and sending requests.

Architecture is inspired by the VS Code implementation, however it
intends to be more generic.
…e-theia#13936)

fixes eclipse-theia#13800

contributed on behalf of STMicroelectronics

Signed-off-by: Remi Schnekenburger <[email protected]>
Co-authored-by: Philip Langer <[email protected]>
…#13912)

fixes eclipse-theia#13886

contributed on behalf of STMicroelectronics

Signed-off-by: Remi Schnekenburger <[email protected]>
Change-Id: I179432698332ff52b33aba7b1f7e203f2bee9c77
fixes eclipse-theia#13848

contributed on behalf of STMicroelectronics

Signed-off-by: Remi Schnekenburger <[email protected]>
Change-Id: I80d33303ceadf940f17265b7d910a5c13b59ec89
eclipsesource/osweek-2024#47

Change-Id: Ib9dd82e3ba062990f5642883bc9439aca52931ad
Change-Id: I186190dede14d729992977c2805e2c07100c2d17
Change-Id: Ia257c9a65b5f2bb9aa3e9ccc506f6394d744ff8f
cdamus and others added 28 commits August 1, 2024 10:46
- Move today variable contribution to common where it should have been
- Add a variable to retrieve the complete content of the current editor

Relates to eclipsesource/osweek-2024#46
Introduces ChatAgent to assist users in creating PRs based on current changes.
The system prompt now asks for the git diff, status, ticket link, and PR template.
Added two variables, #git-status and #git-diff, for capturing status and diff information.
Added the "Invoke PR finalization" command, which opens the chat and sends a predefined message including the git diff and status.
Includes various bug fixes.

Co-authored-by: Lucas Koehler <[email protected]>
- Allow user to lock auto-scroll on chat window toolbar
- Persist lock state during reloads

Fixes eclipsesource/osweek-2024#62
- add a default template that the Default Chat Agent can use
- add a variable contribution to list available agents
- Ensure variables and arguments are properly handled for prompts

Fixes eclipsesource/osweek-2024#93

Co-authored-by: Johannes Faltermeier <[email protected]>
Fix AI chat view command registration
- add a function call registry
- refactor the Workspace Agent to use the Function registry
- move getTools to its own method
- remove override of callLlm in WorkspaceAgent
- rename the Workspace Agent (TheiaWorkspaceAgent => Workspace)
- Theia variables are registered a bit delayed so UI needs to update
- Enhance variable service with event for variable changes

Fixes eclipsesource/osweek-2024#105
* feat: configure open ai providers from frontend

- provide preferences to set OpenAI Api Key
- provide preferences to add/remove OpenAI models
- add listener mechanism for language model add/remove
- propagate backend language model registry changes automatically to
  frontend
- add error handling in chat view in case an error is thrown during
  a request
eclipsesource/osweek-2024#109

Change-Id: I530b0d87a7baea0026bafaec8decd0479f5357d8
- Agents select LLM based on settings and requirements or default
- Ensure we show the default case in case requirements do not set LLM

Fixes eclipsesource/osweek-2024#100
* adds an AbstractChatAgent
  * this does
    * get the messages with optional system prompt
    * record the request
    * get a response from the language model
    * _passes response to an abstract function to add response contents_ 
    * completes response
    * records the response
* Default Chat Agent extends AbstractChatAgent
* Add a further AbstractTextToModelParsingChatAgent that extends AbstractChatAgent
  * splits adding contents to response in three steps
    * getting response as plain text
    * parsing text to an object
    * based on object add contents to response
* CommandChatAgent extends AbstractTextToModelParsingChatAgent
- add cancellation token support
- offer cancel for chat requests
- trigger cancel for code completions
- also nicely formats requests in the output channels

Co-authored-by: Stefan Dirix <[email protected]>
Added multi conversation support to the chat window.
A new add button can be used to create a new chat session (this can also be done programatically).
With a history button the user can switch to another chat session.
This is done via a quick Picker that shows all other sessions that you can switch to.
Changed the PR finalization feature so that it opens up a new chat session.

Co-authored-by: Haydar Metin <[email protected]>
- Register an inline completion provider
- Check for cancellation regularly
- Introduce preference for inline code completion

Fixes eclipsesource/osweek-2024#61
The cancel button is now part of the input line so it is turned on while a request is in progress. Otherwise the submit icon is shown.

---------

Co-authored-by: Stefan Dirix <[email protected]>
- add an AgentService to list all (enabled) agents
- add methods to track enabled/disabled agents
- update the configuration UI to enable/disable agents
- fix undefined exception in CodeFixAgent Settings UI
Change-Id: I4f7233051b776aa704dc4b448d44ebe8baef5506
Beforehand we would always jumpt to the latest chat,w hen another one was deleted.
Now this will only happen if you manage to delete the active one, which should not happen via UI.
- don't bind the widgets as singletons because they must be
  recreated after disposal
- Add an action to extract the chat view to a separate window
- Include AI Chat UI CSS in the secondary window
- avoid PerfectScroll rails

Note that this does result in odd
behaviour when opening the view again
in the main window, yanking it out of\the separate window, as then closing
the separate window closes the view
that is now in the main window. This
boils down to a known issue in the
general support for secondary windows.

Co-authored-by: Remi Schnekenburger <[email protected]>
…es (#144)

Improve the AI chat ui input field with autocompletion for chat agents
and ai variables:

Typing `@` allows to autocomplete chat agents.
Typing `#` allows to autocomplete ai variables.

To facilitate this, the input field was changed from a textarea to an
inline monaco editor. A custom language `ai-chat-view-language` is
introduced to provide the completions via completion item providers
that query the ChatAgentService resp. AIVariableService

Co-authored-by: Alexandra Muntean <[email protected]>
Co-authored-by: Martin Fleck <[email protected]>
@sdirix
Copy link
Member Author

sdirix commented Aug 2, 2024

wrong pr

@sdirix sdirix closed this Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.