Repository: FlowiseAI/Flowise
File: packages/components/nodes/llms/Fireworks/Fireworks.ts (TypeScript)

Code before:
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
import { BaseCache } from '@langchain/core/caches'

class Fireworks_LLMs implements INode {
    label: string
    name: string
    version: number
    type: string
    icon: string
    category: string
    description: string
    baseClasses: string[]
    credential: INodeParams
    inputs: INodeParams[]

    constructor() {
        this.label = 'Fireworks'
        this.name = 'fireworks'
        this.version = 1.0
        this.type = 'Fireworks'
        this.icon = 'fireworks.png'
        this.category = 'LLMs'
        this.description = 'Wrapper around Fireworks API for large language models'
        this.baseClasses = [this.type, ...getBaseClasses(Fireworks)]
        this.credential = {
            label: 'Connect Credential',
            name: 'credential',
            type: 'credential',
            credentialNames: ['fireworksApi']
        }
        this.inputs = [
            {
                label: 'Cache',
                name: 'cache',
                type: 'BaseCache',
                optional: true
            }
        ]
    }

    loadMethods = {
        async listModels(): Promise<INodeOptionsValue[]> {
            return await getModels(MODEL_TYPE.LLM, 'fireworks')
        }
    }

    async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
        const cache = nodeData.inputs?.cache as BaseCache

        const credentialData = await getCredentialData(nodeData.credential ?? '', options)
        const fireworksKey = getCredentialParam('fireworksApiKey', credentialData, nodeData)

Review comment (suggestion):
We need to have the model field parameter, example - https://github.com/FlowiseAI/Flowise/blob/main/packages/components/nodes/chatmodels/ChatHuggingFace/ChatHuggingFace.ts#L41

Since there are so many models, we can just make it as a type: 'string field, and get rid of the listModels method

Code after:
    description: string
    baseClasses: string[]
    credential: INodeParams
    inputs: INodeParams[]

    constructor() {
        this.label = 'Fireworks'
        this.name = 'fireworks'
        this.version = 1.0
        this.type = 'Fireworks'
        this.icon = 'fireworks.png'
        this.category = 'LLMs'
        this.description = 'Wrapper around Fireworks API for large language models'
        this.baseClasses = [this.type, ...getBaseClasses(Fireworks)]
        this.credential = {
            label: 'Connect Credential',
            name: 'credential',
            type: 'credential',
            credentialNames: ['fireworksApi']
        }
        this.inputs = [
            {
                label: 'Cache',
                name: 'cache',
                type: 'BaseCache',
                optional: true
            },
            {
                label: 'Model Name',
                name: 'modelName',
                type: 'string',
                default: 'accounts/fireworks/models/llama-v3-70b-instruct-hf',
                description: 'For more details see https://fireworks.ai/models',
                optional: true
            }
        ]
    }

    async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
        const cache = nodeData.inputs?.cache as BaseCache
        const modelName = nodeData.inputs?.modelName as string

        const credentialData = await getCredentialData(nodeData.credential ?? '', options)
        const fireworksKey = getCredentialParam('fireworksApiKey', credentialData, nodeData)

        const obj: any = {
            fireworksApiKey: fireworksKey,
            modelName: modelName
        }
        if (cache) obj.cache = cache