MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / getRawModelFile

Function getRawModelFile

packages/components/src/modelLoader.ts:36–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34 * If any of the loading fails, fallback to the default models.json file on disk
35 */
36const getRawModelFile = async () => {
37 const modelFile =
38 process.env.MODEL_LIST_CONFIG_JSON ?? 'https://raw.githubusercontent.com/FlowiseAI/Flowise/main/packages/components/models.json'
39 try {
40 if (isValidUrl(modelFile)) {
41 const resp = await axios.get(modelFile)
42 if (resp.status === 200 && resp.data) {
43 return resp.data
44 } else {
45 throw new Error('Error fetching model list')
46 }
47 } else if (fs.existsSync(modelFile)) {
48 const models = await fs.promises.readFile(modelFile, 'utf8')
49 if (models) {
50 return JSON.parse(models)
51 }
52 }
53 throw new Error('Model file does not exist or is empty')
54 } catch (e) {
55 const models = await fs.promises.readFile(getModelsJSONPath(), 'utf8')
56 if (models) {
57 return JSON.parse(models)
58 }
59 return {}
60 }
61}
62
63const getModelConfig = async (category: MODEL_TYPE, name: string) => {
64 const models = await getRawModelFile()

Callers 2

getModelConfigFunction · 0.85

Calls 4

isValidUrlFunction · 0.85
getModelsJSONPathFunction · 0.85
parseMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected