models.json support for Groq (#2328)

* Add Groq models

Added current Groq models to improve UX.

* Add support for models.json

Added the ability to load models from models.json

* fix linting

* increment groq node version

---------

Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
ml4den
2024-05-06 11:37:06 +01:00
committed by GitHub
parent 09569d0b06
commit 713a1e815d
2 changed files with 34 additions and 4 deletions
+21
View File
@@ -365,6 +365,27 @@
}
]
},
{
"name": "groqChat",
"models": [
{
"label": "gemma-7b-it",
"name": "gemma-7b-it"
},
{
"label": "llama3-70b-8192",
"name": "llama3-70b-8192"
},
{
"label": "llama3-8b-8192",
"name": "llama3-8b-8192"
},
{
"label": "mixtral-8x7b-32768",
"name": "mixtral-8x7b-32768"
}
]
},
{
"name": "chatCohere",
"models": [
@@ -1,6 +1,7 @@
import { BaseCache } from '@langchain/core/caches'
import { ChatGroq, ChatGroqInput } from '@langchain/groq'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
class Groq_ChatModels implements INode {
@@ -18,7 +19,7 @@ class Groq_ChatModels implements INode {
constructor() {
this.label = 'GroqChat'
this.name = 'groqChat'
this.version = 2.0
this.version = 3.0
this.type = 'GroqChat'
this.icon = 'groq.png'
this.category = 'Chat Models'
@@ -41,8 +42,9 @@ class Groq_ChatModels implements INode {
{
label: 'Model Name',
name: 'modelName',
type: 'string',
placeholder: 'mixtral-8x7b-32768'
type: 'asyncOptions',
loadMethod: 'listModels',
placeholder: 'llama3-70b-8192'
},
{
label: 'Temperature',
@@ -55,6 +57,13 @@ class Groq_ChatModels implements INode {
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.CHAT, 'groqChat')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const modelName = nodeData.inputs?.modelName as string
const cache = nodeData.inputs?.cache as BaseCache