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: provider endpoint and mux section #275

Merged
merged 14 commits into from
Feb 7, 2025
Merged

fix: provider endpoint and mux section #275

merged 14 commits into from
Feb 7, 2025

Conversation

peppescg
Copy link
Collaborator

@peppescg peppescg commented Feb 6, 2025

  • Fix auth_type, api_key update
  • Prefilled auth_type and provider endpoint
  • small fix on text
  • add banner on preferred model in case of missing providers
  • add notification message on added provider

sorry 🙏 , I am still missing tests coverage, but after this PR I am going to add them.

Kapture.2025-02-06.at.21.32.02.mp4

Providers exist
Screenshot 2025-02-06 at 21 35 20

No providers
Screenshot 2025-02-06 at 21 35 42

@peppescg peppescg self-assigned this Feb 6, 2025
@peppescg peppescg changed the title Issues/272 fix: provider endpoint and mux section Feb 6, 2025
@peppescg peppescg linked an issue Feb 6, 2025 that may be closed by this pull request
@coveralls
Copy link
Collaborator

coveralls commented Feb 6, 2025

Pull Request Test Coverage Report for Build 13195998776

Details

  • 6 of 33 (18.18%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-1.2%) to 69.045%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/features/providers/components/table-providers.tsx 0 3 0.0%
src/features/providers/components/provider-form.tsx 0 5 0.0%
src/features/providers/hooks/use-mutation-update-provider.ts 0 6 0.0%
src/features/providers/lib/utils.ts 0 13 0.0%
Totals Coverage Status
Change from base Build 13181770328: -1.2%
Covered Lines: 819
Relevant Lines: 1122

💛 - Coveralls

@@ -27,3 +28,23 @@ export function isProviderType(value: unknown): value is ProviderType {
export function isProviderAuthType(value: unknown): value is ProviderAuthType {
return Object.values(ProviderAuthType).includes(value as ProviderAuthType);
}

export function getProviderEndpointByAuthType(provider_type: ProviderType) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this can/should be fixed in this PR, but just to raise the point: should this mapping/data not come from BE instead? I would like to avoid hardcoding the same thing in multiple different places. Otherwise there might be problems when we change the url for one of the providers in BE but not in FE or vice versa. This could be a problem since the number of providers keeps growing...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

well, this is only a prefilled text field for us. The BE doesn't have this logic cause it is up to the user specify the endpoint url...previously the provider endpoint field was empty, but correctly Dan and Luke pointed out that we can prefilled the url that are hardcoded for the providers

.with(ProviderType.OPENAI, () => ProviderAuthType.API_KEY)
.with(ProviderType.ANTHROPIC, () => ProviderAuthType.API_KEY)
.with(ProviderType.OPENROUTER, () => ProviderAuthType.API_KEY)
.otherwise(() => ProviderAuthType.NONE);
Copy link
Member

Choose a reason for hiding this comment

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

should this one not also be exhaustive instead? and the same point, not in the scope of this PR, but if there is hardcoded "data" or mapping should be done in BE, unless it's something that is 100% only relevant in the dashboard 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the logic here is return api_key for those provider type, for the other return none, for that reason is correct to use otherwise rather than exhaustive. It will be none for the rest of the provider type, so duplicated a lot.

Also this is for prefilled fields in the form, so a UI logic, an helper, so the BE doesn't have this logic, they have only a validation in case of missing api_key for a provider

usePreferredModelWorkspace(workspaceName);
const { mutateAsync } = useMutationPreferredModelWorkspace();
const { data: providerModels = [] } = useModelsData();
const { model, provider_id } = preferredModel;
const isModelsEmpty = !isPending && providerModels.length === 0;
Copy link
Member

Choose a reason for hiding this comment

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

nit pick, the naming is slightly questionable as isPending === true does not means models is empty. But I don't have a perfect suggestion so feel free to ignore the comment 🤷‍♂️

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤔 sorry i don't understand, it is checking boht isPending and the length

Copy link
Member

@kantord kantord left a comment

Choose a reason for hiding this comment

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

Looks great!

@peppescg peppescg merged commit cadbd5f into main Feb 7, 2025
7 of 8 checks passed
@peppescg peppescg deleted the issues/272 branch February 7, 2025 10:49
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.

Provider API key update
4 participants