Skip to content

Conversation

@samhvw8
Copy link
Contributor

@samhvw8 samhvw8 commented Feb 10, 2025

  • Extend ModelPicker to support OpenAI models and refreshValues
  • Refactor OpenAiModelPicker to use unified ModelPicker component
  • Add refreshValues support for Requesty API key

Description

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

Related Issues

Reviewers


Important

Refactor to unify model picker components, extending ModelPicker to support OpenAI models and refreshValues.

  • Refactor:
    • OpenAiModelPicker and RequestyModelPicker now use the unified ModelPicker component.
    • ModelPicker in ModelPicker.tsx extended to support OpenAI models and refreshValues.
  • Functionality:
    • Adds refreshValues support for Requesty API key in RequestyModelPicker.tsx.
    • Supports OpenAI models by handling them as strings in ModelPicker.tsx.

This description was created by Ellipsis for 26a315b. It will automatically update as commits are pushed.

- Extend ModelPicker to support OpenAI models and refreshValues
- Refactor OpenAiModelPicker to use unified ModelPicker component
- Add refreshValues support for Requesty API key
@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2025

⚠️ No Changeset found

Latest commit: 1653263

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cte
Copy link
Collaborator

cte commented Feb 10, 2025

Wow, nice cleanup!

import { normalizeApiConfiguration } from "./ApiOptions"
import { ModelInfoView } from "./ModelInfoView"

interface ModelPickerProps {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to ignore, but Claude suggested doing this:

type ModelProvider = "glama" | "openRouter" | "unbound" | "requesty" | "openAi"

type ModelKeys<T extends ModelProvider> = `${T}Models`
type ConfigKeys<T extends ModelProvider> = `${T}ModelId`
type InfoKeys<T extends ModelProvider> = `${T}ModelInfo`
type RefreshMessageType<T extends ModelProvider> = `refresh${Capitalize<T>}Models`

interface ModelPickerProps<T extends ModelProvider = ModelProvider> {
	defaultModelId: string
	modelsKey: ModelKeys<T>
	configKey: ConfigKeys<T>
	infoKey: InfoKeys<T>
	refreshMessageType: RefreshMessageType<T>
	refreshValues?: Record<string, any>
	serviceName: string
	serviceUrl: string
	recommendedModel: string
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cte updated ! :D

@cte
Copy link
Collaborator

cte commented Feb 10, 2025

Found one bug: After entering my Requesty API key the model picker doesn't populate the models:
https://www.loom.com/share/fc357bf384374a5fbca524e528069fb8?sid=d056c5b4-a617-4409-a3d3-abe0fd6304a3

Other than that the code looks good.

- Add proper change detection for refreshValues using deep comparison
- Increase debounce timing from 50ms to 100ms for better performance
- Add proper error handling for missing Requesty API key
- Fix apiConfiguration update to properly merge with existing state
- Remove debug console logs
@samhvw8
Copy link
Contributor Author

samhvw8 commented Feb 10, 2025

Found one bug: After entering my Requesty API key the model picker doesn't populate the models: https://www.loom.com/share/fc357bf384374a5fbca524e528069fb8?sid=d056c5b4-a617-4409-a3d3-abe0fd6304a3

Other than that the code looks good.

@cte i just fix this, and some another bug

@samhvw8
Copy link
Contributor Author

samhvw8 commented Feb 10, 2025

@cte it's ok now, but there is an problems that is openai compatible must need to implement /v1/models to work with us :(, let me fix

@samhvw8
Copy link
Contributor Author

samhvw8 commented Feb 10, 2025

image

done for fix custom model in openai compatible

@cte
Copy link
Collaborator

cte commented Feb 10, 2025

Nice, verified that the fix is working for me. One last thing. Let's change

onInput={handleInputChange("requestyApiKey")}

to

onBlur={handleInputChange("requestyApiKey")}

Otherwise the hook you added that reacts to refreshValues gets hammered on keystroke.

- Add allowCustomModel prop to control custom model feature
- Implement custom model input dialog with proper VSCode theming
- Enable custom model support in OpenAiModelPicker
- Fix z-index issues with modal dialog
@joemanley201
Copy link
Contributor

Nice, verified that the fix is working for me. One last thing. Let's change

onInput={handleInputChange("requestyApiKey")}

to

onBlur={handleInputChange("requestyApiKey")}

Otherwise the hook you added that reacts to refreshValues gets hammered on keystroke.

Very unrelated question. If we have debouncing logic, would that set us up nicely to still use onChange instead of using onBlur?

@samhvw8
Copy link
Contributor Author

samhvw8 commented Feb 10, 2025

@cte done :D

@cte
Copy link
Collaborator

cte commented Feb 10, 2025

Very unrelated question. If we have debouncing logic, would that set us up nicely to still use onChange instead of using onBlur?

Seems less problematic with debouncing, but I think it makes sense to simply avoid unnecessary work (there's no reason to execute the hook while the user is typing).


prevRefreshValuesRef.current = refreshValues
debouncedRefreshModels()
}, [debouncedRefreshModels, refreshValues])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick - adding JSON.stringify(refreshValues) to the dependecy array might help clean this up.

useEffect(() => {
	if (!refreshValues) return;
	debouncedRefreshModels();
}, [debouncedRefreshModels, JSON.stringify(refreshValues)]);

I'm not 100% sure the ref is actually needed, but I'll defer to you.

@mrubens mrubens merged commit 7ebf3fa into RooCodeInc:main Feb 10, 2025
6 checks passed
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.

4 participants