[MM2] Use typed ModelRecordChanges for model_install() rather than untyped dict (#6645)

* [MM2] replace untyped config dict passed to install_model with typed ModelRecordChanges

- adjusted frontend to work with new schema
- used this facility to assign "starter model" names and descriptions to the installed
  models.

* documentation fix

* [MM2] replace untyped config dict passed to install_model with typed ModelRecordChanges

- adjusted frontend to work with new schema
- used this facility to assign "starter model" names and descriptions to the installed
  models.

* documentation fix

* remove v9 pnpm lockfile

* [MM2] replace untyped config dict passed to install_model with typed ModelRecordChanges

- adjusted frontend to work with new schema
- used this facility to assign "starter model" names and descriptions to the installed
  models.

* [MM2] replace untyped config dict passed to install_model with typed ModelRecordChanges

- adjusted frontend to work with new schema
- used this facility to assign "starter model" names and descriptions to the installed
  models.

* remove v9 pnpm lockfile

* regenerate schema.ts

* prettified

---------

Co-authored-by: Lincoln Stein <lstein@gmail.com>
This commit is contained in:
Lincoln Stein
2024-07-23 17:41:00 -04:00
committed by GitHub
parent a221ab2fb6
commit 633bbb4e85
13 changed files with 266 additions and 13546 deletions

View File

@@ -1,11 +1,9 @@
import { toast } from 'features/toast/toast';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { useInstallModelMutation } from 'services/api/endpoints/models';
import { type InstallModelArg, useInstallModelMutation } from 'services/api/endpoints/models';
type InstallModelArg = {
source: string;
inplace?: boolean;
type InstallModelArgWithCallbacks = InstallModelArg & {
onSuccess?: () => void;
onError?: (error: unknown) => void;
};
@@ -15,8 +13,9 @@ export const useInstallModel = () => {
const [_installModel, request] = useInstallModelMutation();
const installModel = useCallback(
({ source, inplace, onSuccess, onError }: InstallModelArg) => {
_installModel({ source, inplace })
({ source, inplace, config, onSuccess, onError }: InstallModelArgWithCallbacks) => {
config ||= {};
_installModel({ source, inplace, config })
.unwrap()
.then((_) => {
if (onSuccess) {

View File

@@ -12,17 +12,19 @@ type Props = {
export const StarterModelsResultItem = ({ result }: Props) => {
const { t } = useTranslation();
const allSources = useMemo(() => {
const _allSources = [result.source];
const _allSources = [{ source: result.source, config: { name: result.name, description: result.description } }];
if (result.dependencies) {
_allSources.push(...result.dependencies.map((d) => d.source));
for (const d of result.dependencies) {
_allSources.push({ source: d.source, config: { name: d.name, description: d.description } });
}
}
return _allSources;
}, [result]);
const [installModel] = useInstallModel();
const onClick = useCallback(() => {
for (const source of allSources) {
installModel({ source });
for (const { config, source } of allSources) {
installModel({ config, source });
}
}, [allSources, installModel]);