mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
Feature/externalize model list (#2113)
* fixes * test json * test json * externalize model list * externalize model list * correcting awsChatBedRock Name * lint fixes * externalize models * externalize chat models * externalize chat models * externalize llm models * externalize llm models * lint fixes * addition of models for ChatMistral * updating version numbers for all imapacted nodes. * marketplace template updates * update embeddings, marketplaces, add chatCohere * config changes for new env variable * removal of local models.json * update models json file --------- Co-authored-by: Henry <hzj94@hotmail.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { INodeOptionsValue } from './Interface'
|
||||
import axios from 'axios'
|
||||
|
||||
const MASTER_MODEL_LIST = 'https://raw.githubusercontent.com/FlowiseAI/Flowise/main/packages/components/models.json'
|
||||
|
||||
export enum MODEL_TYPE {
|
||||
CHAT = 'chat',
|
||||
LLM = 'llm',
|
||||
EMBEDDING = 'embedding'
|
||||
}
|
||||
|
||||
const getModelConfig = async (category: MODEL_TYPE, name: string) => {
|
||||
const modelFile = process.env.MODEL_LIST_CONFIG_JSON || MASTER_MODEL_LIST
|
||||
if (!modelFile) {
|
||||
throw new Error('MODEL_LIST_CONFIG_JSON not set')
|
||||
}
|
||||
const resp = await axios.get(modelFile)
|
||||
const models = resp.data
|
||||
const categoryModels = models[category]
|
||||
return categoryModels.find((model: any) => model.name === name)
|
||||
}
|
||||
|
||||
export const getModels = async (category: MODEL_TYPE, name: string) => {
|
||||
const returnData: INodeOptionsValue[] = []
|
||||
try {
|
||||
const modelConfig = await getModelConfig(category, name)
|
||||
returnData.push(...modelConfig.models)
|
||||
return returnData
|
||||
} catch (e) {
|
||||
throw new Error(`Error: getModels - ${e}`)
|
||||
}
|
||||
}
|
||||
|
||||
export const getRegions = async (category: MODEL_TYPE, name: string) => {
|
||||
const returnData: INodeOptionsValue[] = []
|
||||
try {
|
||||
const modelConfig = await getModelConfig(category, name)
|
||||
returnData.push(...modelConfig.regions)
|
||||
return returnData
|
||||
} catch (e) {
|
||||
throw new Error(`Error: getRegions - ${e}`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user