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

feat(chore): Adding tags and usage for LLM Models #1894

Merged
merged 12 commits into from
Jul 18, 2024

Conversation

jamesmcnamara
Copy link
Contributor

@jamesmcnamara jamesmcnamara commented Jul 9, 2024

CODY-2746

This update is to align with a refactor in the vscode repo around model types to remove certain hard coded fields and replace them with ModelTags.

This is very rough around the edges because I don't know how to access the generated code in that PR (nor am I aware of the context on this repo) so any feedback is welcome!

Test plan

Green CI

Comment on lines +16 to +19
@get:OptionTag(tag = "tags", nameAttribute = "") var tags: MutableList<String> by list()

@get:OptionTag(tag = "usage", nameAttribute = "") var usage: MutableList<String> by list()

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 don't know the implications of this. Where is it getting this state from? Is this going to break immediately?

Copy link
Contributor

@pkukielka pkukielka Jul 9, 2024

Choose a reason for hiding this comment

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

This is state saved in a IntelliJ xml settings files.
You will need to add migration which will convert old format to the new one .
For the reference you can look at the DeprecatedChatLlmMigration.

In practice you will most likely have to:

  1. Keep ChatModelProvider::deprecated field but mark it as @Deprecated.
  2. In the migration function (see DeprecatedChatLlmMigration::migrate for reference):
  • read all the old chats
  • for each chat read the content from deprecated field
  • set tags appropriately
  • reset deprecated to be null (as it won't be used anymore, we will remove it in future)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright. I created ChatTagsLllmMigration that I believe accomplishes this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you! It looks good to me now, I just added one question about the default but otherwise I think it is mergeable.

@abeatrix abeatrix requested review from mkondratek and a team July 9, 2024 02:11
@odisseus
Copy link
Contributor

odisseus commented Jul 9, 2024

In order for the tests to work, you'll need to update the cody.commit field in gradle.properties.

@@ -190,22 +198,20 @@ class SettingsMigrationTest : BasePlatformTestCase() {
fun `test DeprecatedChatLlmMigration`() {
Copy link
Contributor

@pkukielka pkukielka Jul 9, 2024

Choose a reason for hiding this comment

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

That is incorrect I think.
That is migration function, so it specifically migrates data form one old format to another.
It needs to work after your changes.
Then your migration function can pick up state after all existing migrations, and migrate it further (so you will have to add new test for it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. I reverted those changes and added a new test for my migration.

@jamesmcnamara jamesmcnamara marked this pull request as ready for review July 10, 2024 02:17
if (selectedModel?.codyProOnly == true && isCurrentUserFree())
availableModels.find { it.default }
if (selectedModel?.isCodyProOnly() == true && isCurrentUserFree())
availableModels.getOrNull(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, if we do not have default anymore isn't there any tag which would replace it?
Like recommended LLM?

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've just replaced it with the fallback convention of the head of the list. The model structs are immutable having a mutable field tracking the user's selection was a bit tricky and also easy to get wrong (multiple default's was possible). And we always fell back to just grabbing the head of the list if we couldn't find one.

I could see adding a default tag, but I would think to only use it for what the server originally sent as the default, not as the user's current selection.

Copy link
Contributor

@pkukielka pkukielka left a comment

Choose a reason for hiding this comment

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

LGTM, but with two caveats:

  1. Isn't default replace by any tag? Don't we have any LLMs which we recommend to use?
  2. Are those changes already in the Cody?
    We bind cody version we are using by setting cody.commit there: https://github.com/sourcegraph/jetbrains/blob/main/gradle.properties#L27
    Please make sure version from this commit already contains changes to the model. If not, you need to bump that commit in this PR (you can just set it to the hash of the last commit on Cody main)

@jamesmcnamara
Copy link
Contributor Author

@pkukielka

  1. default is now the head of the list always
  2. I will update cody.commit when this PR merges.

@pkukielka
Copy link
Contributor

@pkukielka

  1. default is now the head of the list always
  2. I will update cody.commit when this PR merges.

Thanks! BTW. Looks like it's merged now :)

if (selectedModel?.codyProOnly == true && isCurrentUserFree())
availableModels.find { it.default }
if (selectedModel?.isCodyProOnly() == true && isCurrentUserFree())
availableModels.getOrNull(0)
else selectedModel

val isEnterpriseAccount =
Copy link
Contributor

@pkukielka pkukielka Jul 17, 2024

Choose a reason for hiding this comment

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

@jamesmcnamara

  1. We need to remove this line and just set isVisible = true always.
  2. Also, I noticed that there is now enterprise tag present, shouldn't we filter out LLMs displayed for enterprise users based on if that tag is present? Or maybe for an enterprise account we are guaranteed to get a correct list?

Copy link
Contributor

Choose a reason for hiding this comment

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

I pushed first change to your branch already.

I'm not sure if we need the second.

Copy link
Contributor Author

@jamesmcnamara jamesmcnamara Jul 18, 2024

Choose a reason for hiding this comment

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

I updated this because we don't want it to be visible for enterprise users that don't have multiple models enabled. However I'm still struggling with the integration tests failing and I'm not sure how to debug them. Do you know any good tricks for figuring out why they keep timing out? I tried opening the IDE to the test file and trying the document code action but it seemed to work fine.

To your second point, I think the current idea is that an enterprise user can use any model that the server provided (but most likely they will all be enterprise models).

Also, unrelated, but do you know how to access the generated kotlin code from the Cody repo? I don't see it referenced anywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

Problem with integration tests was that updated recordings were missing (requires run of the ./gradlew :recordingIntegrationTest). I updated them.
Interestingly it seems we were not reporting that fact properly, I will make sure we fixed that.

Also, unrelated, but do you know how to access the generated kotlin code from the Cody repo? I don't see it referenced anywhere.

Right now they are just working as a manual reference, BUT it will change very soon as there is @RXminuS PR in flight which adress that.

jamesmcnamara and others added 5 commits July 17, 2024 17:19
This change adds a new `serverSentModels` feature to the `ConfigFeatures` class, which is used to track whether the server supports sending models directly to the client. The `LlmDropdown` class is updated to subscribe to changes in the `CurrentConfigFeatures` and show/hide the dropdown based on the value of `serverSentModels`. Additionally, the `CodyAgentClientTest` and `CurrentConfigFeaturesTest` are updated to reflect the new feature.
@pkukielka
Copy link
Contributor

I updated recordings for integration tests + reformatted the code to make spotless happy.
I also tested it manually with pro account and two enterprise accounts (demo and gs02) and now it seems to be working perfectly fine.

Thanks @jamesmcnamara and @abeatrix for fixing bug with the auth and models!

@pkukielka pkukielka merged commit 2a28a0e into main Jul 18, 2024
7 checks passed
@pkukielka pkukielka deleted the jsm/cody-enterprise-models branch July 18, 2024 08:36
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.

3 participants