|
1 | 1 | import { getStore } from 'app/store/nanostores/store';
|
2 |
| -import type { ModelIdentifierField } from 'features/nodes/types/common'; |
3 | 2 | import { modelsApi } from 'services/api/endpoints/models';
|
4 |
| -import type { AnyModelConfig, BaseModelType, ModelType } from 'services/api/types'; |
| 3 | +import type { AnyModelConfig } from 'services/api/types'; |
5 | 4 |
|
6 | 5 | /**
|
7 | 6 | * Raised when a model config is unable to be fetched.
|
@@ -47,45 +46,6 @@ const fetchModelConfig = async (key: string): Promise<AnyModelConfig> => {
|
47 | 46 | }
|
48 | 47 | };
|
49 | 48 |
|
50 |
| -/** |
51 |
| - * Fetches the model config for a given model name, base model, and model type. This provides backwards compatibility |
52 |
| - * for MM1 model identifiers. |
53 |
| - * @param name The model name. |
54 |
| - * @param base The base model. |
55 |
| - * @param type The model type. |
56 |
| - * @returns A promise that resolves to the model config. |
57 |
| - * @throws {ModelConfigNotFoundError} If the model config is unable to be fetched. |
58 |
| - */ |
59 |
| -const fetchModelConfigByAttrs = async (name: string, base: BaseModelType, type: ModelType): Promise<AnyModelConfig> => { |
60 |
| - const { dispatch } = getStore(); |
61 |
| - try { |
62 |
| - const req = dispatch( |
63 |
| - modelsApi.endpoints.getModelConfigByAttrs.initiate({ name, base, type }, { subscribe: false }) |
64 |
| - ); |
65 |
| - return await req.unwrap(); |
66 |
| - } catch { |
67 |
| - throw new ModelConfigNotFoundError(`Unable to retrieve model config for name/base/type ${name}/${base}/${type}`); |
68 |
| - } |
69 |
| -}; |
70 |
| - |
71 |
| -/** |
72 |
| - * Fetches the model config given an identifier. First attempts to fetch by key, then falls back to fetching by attrs. |
73 |
| - * @param identifier The model identifier. |
74 |
| - * @returns A promise that resolves to the model config. |
75 |
| - * @throws {ModelConfigNotFoundError} If the model config is unable to be fetched. |
76 |
| - */ |
77 |
| -export const fetchModelConfigByIdentifier = async (identifier: ModelIdentifierField): Promise<AnyModelConfig> => { |
78 |
| - try { |
79 |
| - return await fetchModelConfig(identifier.key); |
80 |
| - } catch { |
81 |
| - try { |
82 |
| - return await fetchModelConfigByAttrs(identifier.name, identifier.base, identifier.type); |
83 |
| - } catch { |
84 |
| - throw new ModelConfigNotFoundError(`Unable to retrieve model config for identifier ${identifier}`); |
85 |
| - } |
86 |
| - } |
87 |
| -}; |
88 |
| - |
89 | 49 | /**
|
90 | 50 | * Fetches the model config for a given model key and type, and ensures that the model config is of a specific type.
|
91 | 51 | * @param key The model key.
|
|
0 commit comments