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

828 streamline chat model configuration info message network call #875

Conversation

pmarsh-scottlogic
Copy link
Contributor

@pmarsh-scottlogic pmarsh-scottlogic commented Mar 22, 2024

Description

Before, when the user would configure the chatModel, we would send a request to the backend. If the backend successfully configured the model, then the frontend would send a further request to add the info message to the chat history, eg 'changed frequencyPenalty to 0.6'.

This PR changes it so that when the backend successfully configures the chatModel, the backend generates the info message and appends it to the history, then forwards it on to the frontend.

Notes

  • handleConfigureModel now generates an info message, appends it to the chat history and forwards it to the frontend.
  • renames MODEL_CONFIG enum to MODEL_CONFIG_ID and converts it to a string literal type, on frontend and backend.
  • adds detailed validation to handleConfigureModel.
  • adds unit tests for handleConfigureModel.

Checklist

Have you done the following?

  • Linked the relevant Issue
  • Added tests
  • Ensured the workflow steps are passing

Copy link
Member

@chriswilty chriswilty left a comment

Choose a reason for hiding this comment

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

Much the same as for defence config updates, nice work but I think I see a problem.

backend/src/controller/modelController.ts Show resolved Hide resolved
backend/src/models/api/OpenAiConfigureModelRequest.ts Outdated Show resolved Hide resolved
backend/src/models/chat.ts Show resolved Hide resolved
frontend/src/models/chat.ts Outdated Show resolved Hide resolved
frontend/src/service/chatService.ts Outdated Show resolved Hide resolved
@@ -39,6 +31,10 @@ const modelConfigIds = [

type MODEL_CONFIG_ID = (typeof modelConfigIds)[number];

type ChatModelConfigurations = {
Copy link
Member

@chriswilty chriswilty Mar 26, 2024

Choose a reason for hiding this comment

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

There must be a reason you pluralised this, right? Is there a clash with another type, or did you feel it made more sense as a plural? Or did you do so to match the frontend code?

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 prefer it that way.

If each of top p, `frequency penalty etc are one configuration, then the set of all of them should be called configurations.

Copy link
Member

Choose a reason for hiding this comment

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

That's fine, but then export it as that - currently you're exporting it as ChatModelConfiguration.

Copy link
Member

@chriswilty chriswilty left a comment

Choose a reason for hiding this comment

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

Nice work 👌

A couple of random thoughts but nothing that should prevent merging.

frontend/src/service/chatService.ts Outdated Show resolved Hide resolved
Copy link
Member

@chriswilty chriswilty left a comment

Choose a reason for hiding this comment

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

One teeny thing, else good to go 👍

@@ -39,6 +31,10 @@ const modelConfigIds = [

type MODEL_CONFIG_ID = (typeof modelConfigIds)[number];

type ChatModelConfigurations = {
Copy link
Member

Choose a reason for hiding this comment

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

That's fine, but then export it as that - currently you're exporting it as ChatModelConfiguration.

Copy link
Member

@chriswilty chriswilty left a comment

Choose a reason for hiding this comment

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

Get it in! ⚡

@pmarsh-scottlogic pmarsh-scottlogic merged commit 57d2027 into dev Mar 28, 2024
4 checks passed
@pmarsh-scottlogic pmarsh-scottlogic deleted the 828-streamline-chat-model-configuration-info-message-network-call branch March 28, 2024 09:58
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.

Stop adding messages to backend history via frontend 🛠🛠
2 participants