Download src/utils/extract-model-and-provider.ts from SaylorTwift/openhands: direct link, hf CLI and curl.
- Browser
- Download file 702 Bytes
-
https://huggingface.co/SaylorTwift/openhands/resolve/main/src/utils/extract-model-and-provider.ts
- Command line
-
hf download hf://SaylorTwift/openhands/src/utils/extract-model-and-provider.ts
-
curl -L -o extract-model-and-provider.ts https://huggingface.co/SaylorTwift/openhands/resolve/main/src/utils/extract-model-and-provider.ts
702 Bytes
| /** | |
| * Given a model string, extract the provider and model name. | |
| * | |
| * Provider assignment for bare model names is handled by the backend before | |
| * the model list reaches the frontend. This function only parses slash-based | |
| * ``provider/model`` strings and leaves everything else as a bare model. | |
| * | |
| * @example | |
| * extractModelAndProvider("azure/ada") | |
| * // returns { provider: "azure", model: "ada", separator: "/" } | |
| */ | |
| export const extractModelAndProvider = (model: string) => { | |
| const [provider, ...modelId] = model.split("/"); | |
| if (!provider || modelId.length === 0) { | |
| return { provider: "", model, separator: "" }; | |
| } | |
| return { provider, model: modelId.join("/"), separator: "/" }; | |
| }; | |