mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-06 17:24:55 -05:00
feat(ui): set HF token in MM tab
- Display a toast on UI launch if the HF token is invalid - Show form in MM if token is invalid or unable to be verified, let user set the token via this form
This commit is contained in:
@@ -27,6 +27,15 @@ type GetModelConfigsResponse = NonNullable<
|
||||
paths['/api/v2/models/']['get']['responses']['200']['content']['application/json']
|
||||
>;
|
||||
|
||||
type GetHFTokenStatusResponse =
|
||||
paths['/api/v2/models/hf_login']['get']['responses']['200']['content']['application/json'];
|
||||
type SetHFTokenResponse = NonNullable<
|
||||
paths['/api/v2/models/hf_login']['post']['responses']['200']['content']['application/json']
|
||||
>;
|
||||
type SetHFTokenArg = NonNullable<
|
||||
paths['/api/v2/models/hf_login']['post']['requestBody']['content']['application/json']
|
||||
>;
|
||||
|
||||
export type GetStarterModelsResponse =
|
||||
paths['/api/v2/models/starter_models']['get']['responses']['200']['content']['application/json'];
|
||||
|
||||
@@ -265,6 +274,22 @@ export const modelsApi = api.injectEndpoints({
|
||||
getStarterModels: build.query<GetStarterModelsResponse, void>({
|
||||
query: () => buildModelsUrl('starter_models'),
|
||||
}),
|
||||
getHFTokenStatus: build.query<GetHFTokenStatusResponse, void>({
|
||||
query: () => buildModelsUrl('hf_login'),
|
||||
providesTags: ['HFTokenStatus'],
|
||||
}),
|
||||
setHFToken: build.mutation<SetHFTokenResponse, SetHFTokenArg>({
|
||||
query: (body) => ({ url: buildModelsUrl('hf_login'), method: 'POST', body }),
|
||||
invalidatesTags: ['HFTokenStatus'],
|
||||
onQueryStarted: async (_, { dispatch, queryFulfilled }) => {
|
||||
try {
|
||||
const { data } = await queryFulfilled;
|
||||
dispatch(modelsApi.util.updateQueryData('getHFTokenStatus', undefined, () => data));
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -284,4 +309,6 @@ export const {
|
||||
useCancelModelInstallMutation,
|
||||
usePruneCompletedModelInstallsMutation,
|
||||
useGetStarterModelsQuery,
|
||||
useGetHFTokenStatusQuery,
|
||||
useSetHFTokenMutation,
|
||||
} = modelsApi;
|
||||
|
||||
@@ -12,6 +12,7 @@ export const tagTypes = [
|
||||
'Board',
|
||||
'BoardImagesTotal',
|
||||
'BoardAssetsTotal',
|
||||
'HFTokenStatus',
|
||||
'Image',
|
||||
'ImageNameList',
|
||||
'ImageList',
|
||||
|
||||
Reference in New Issue
Block a user