Skip to content

Commit

Permalink
models.json support for Groq (#2328)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ml4den and HenryHengZJ authored May 6, 2024
1 parent 09569d0 commit 713a1e8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
21 changes: 21 additions & 0 deletions packages/components/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
17 changes: 13 additions & 4 deletions packages/components/nodes/chatmodels/Groq/Groq.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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'
Expand All @@ -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',
Expand All @@ -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
Expand Down

0 comments on commit 713a1e8

Please sign in to comment.