Skip to content

Commit 5301db5

Browse files
committed
Merge branch 'main' into feature/Datasource
# Conflicts: # pnpm-lock.yaml
2 parents 3308cb1 + af4e28a commit 5301db5

File tree

14 files changed

+637
-35
lines changed

14 files changed

+637
-35
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { INodeParams, INodeCredential } from '../src/Interface'
2+
3+
class CouchbaseApi implements INodeCredential {
4+
label: string
5+
name: string
6+
version: number
7+
description: string
8+
inputs: INodeParams[]
9+
10+
constructor() {
11+
this.label = 'Couchbase API'
12+
this.name = 'couchbaseApi'
13+
this.version = 1.0
14+
this.inputs = [
15+
{
16+
label: 'Couchbase Connection String',
17+
name: 'connectionString',
18+
type: 'string'
19+
},
20+
{
21+
label: 'Couchbase Username',
22+
name: 'username',
23+
type: 'string'
24+
},
25+
{
26+
label: 'Couchbase Password',
27+
name: 'password',
28+
type: 'password'
29+
}
30+
]
31+
}
32+
}
33+
34+
module.exports = { credClass: CouchbaseApi }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { INodeParams, INodeCredential } from '../src/Interface'
2+
3+
class TogetherAIApi implements INodeCredential {
4+
label: string
5+
name: string
6+
version: number
7+
inputs: INodeParams[]
8+
9+
constructor() {
10+
this.label = 'TogetherAI API'
11+
this.name = 'togetherAIApi'
12+
this.version = 1.0
13+
this.inputs = [
14+
{
15+
label: 'TogetherAI Api Key',
16+
name: 'togetherAIApiKey',
17+
type: 'password'
18+
}
19+
]
20+
}
21+
}
22+
23+
module.exports = { credClass: TogetherAIApi }

Diff for: packages/components/models.json

+21
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,27 @@
365365
}
366366
]
367367
},
368+
{
369+
"name": "groqChat",
370+
"models": [
371+
{
372+
"label": "gemma-7b-it",
373+
"name": "gemma-7b-it"
374+
},
375+
{
376+
"label": "llama3-70b-8192",
377+
"name": "llama3-70b-8192"
378+
},
379+
{
380+
"label": "llama3-8b-8192",
381+
"name": "llama3-8b-8192"
382+
},
383+
{
384+
"label": "mixtral-8x7b-32768",
385+
"name": "mixtral-8x7b-32768"
386+
}
387+
]
388+
},
368389
{
369390
"name": "chatCohere",
370391
"models": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { BaseCache } from '@langchain/core/caches'
2+
import { ChatTogetherAI } from '@langchain/community/chat_models/togetherai'
3+
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
4+
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
5+
6+
class ChatTogetherAI_ChatModels implements INode {
7+
label: string
8+
name: string
9+
version: number
10+
type: string
11+
icon: string
12+
category: string
13+
description: string
14+
baseClasses: string[]
15+
inputs: INodeParams[]
16+
credential: INodeParams
17+
18+
constructor() {
19+
this.label = 'ChatTogetherAI'
20+
this.name = 'chatTogetherAI'
21+
this.version = 1.0
22+
this.type = 'ChatTogetherAI'
23+
this.icon = 'togetherai.png'
24+
this.category = 'Chat Models'
25+
this.description = 'Wrapper around TogetherAI large language models'
26+
this.baseClasses = [this.type, ...getBaseClasses(ChatTogetherAI)]
27+
this.credential = {
28+
label: 'Connect Credential',
29+
name: 'credential',
30+
type: 'credential',
31+
credentialNames: ['togetherAIApi']
32+
}
33+
this.inputs = [
34+
{
35+
label: 'Cache',
36+
name: 'cache',
37+
type: 'BaseCache',
38+
optional: true
39+
},
40+
{
41+
label: 'Model Name',
42+
name: 'modelName',
43+
type: 'string',
44+
placeholder: 'mixtral-8x7b-32768',
45+
description: 'Refer to <a target="_blank" href="https://docs.together.ai/docs/inference-models">models</a> page'
46+
},
47+
{
48+
label: 'Temperature',
49+
name: 'temperature',
50+
type: 'number',
51+
step: 0.1,
52+
default: 0.9,
53+
optional: true
54+
}
55+
]
56+
}
57+
58+
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
59+
const modelName = nodeData.inputs?.modelName as string
60+
const cache = nodeData.inputs?.cache as BaseCache
61+
const temperature = nodeData.inputs?.temperature as string
62+
const streaming = nodeData.inputs?.streaming as boolean
63+
64+
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
65+
const togetherAIApiKey = getCredentialParam('togetherAIApiKey', credentialData, nodeData)
66+
67+
const obj: any = {
68+
model: modelName,
69+
temperature: parseFloat(temperature),
70+
togetherAIApiKey: togetherAIApiKey,
71+
streaming: streaming ?? true
72+
}
73+
if (cache) obj.cache = cache
74+
75+
const model = new ChatTogetherAI(obj)
76+
return model
77+
}
78+
}
79+
80+
module.exports = { nodeClass: ChatTogetherAI_ChatModels }
Loading

Diff for: packages/components/nodes/chatmodels/Groq/Groq.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BaseCache } from '@langchain/core/caches'
22
import { ChatGroq, ChatGroqInput } from '@langchain/groq'
3-
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
3+
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
4+
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
45
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
56

67
class Groq_ChatModels implements INode {
@@ -18,7 +19,7 @@ class Groq_ChatModels implements INode {
1819
constructor() {
1920
this.label = 'GroqChat'
2021
this.name = 'groqChat'
21-
this.version = 2.0
22+
this.version = 3.0
2223
this.type = 'GroqChat'
2324
this.icon = 'groq.png'
2425
this.category = 'Chat Models'
@@ -41,8 +42,9 @@ class Groq_ChatModels implements INode {
4142
{
4243
label: 'Model Name',
4344
name: 'modelName',
44-
type: 'string',
45-
placeholder: 'mixtral-8x7b-32768'
45+
type: 'asyncOptions',
46+
loadMethod: 'listModels',
47+
placeholder: 'llama3-70b-8192'
4648
},
4749
{
4850
label: 'Temperature',
@@ -55,6 +57,13 @@ class Groq_ChatModels implements INode {
5557
]
5658
}
5759

60+
//@ts-ignore
61+
loadMethods = {
62+
async listModels(): Promise<INodeOptionsValue[]> {
63+
return await getModels(MODEL_TYPE.CHAT, 'groqChat')
64+
}
65+
}
66+
5867
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
5968
const modelName = nodeData.inputs?.modelName as string
6069
const cache = nodeData.inputs?.cache as BaseCache
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { TogetherAIEmbeddings, TogetherAIEmbeddingsParams } from '@langchain/community/embeddings/togetherai'
2+
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
3+
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
4+
5+
class TogetherAIEmbedding_Embeddings implements INode {
6+
label: string
7+
name: string
8+
version: number
9+
type: string
10+
icon: string
11+
category: string
12+
description: string
13+
baseClasses: string[]
14+
inputs: INodeParams[]
15+
credential: INodeParams
16+
17+
constructor() {
18+
this.label = 'TogetherAIEmbedding'
19+
this.name = 'togetherAIEmbedding'
20+
this.version = 1.0
21+
this.type = 'TogetherAIEmbedding'
22+
this.icon = 'togetherai.png'
23+
this.category = 'Embeddings'
24+
this.description = 'TogetherAI Embedding models to generate embeddings for a given text'
25+
this.baseClasses = [this.type, ...getBaseClasses(TogetherAIEmbeddings)]
26+
this.credential = {
27+
label: 'Connect Credential',
28+
name: 'credential',
29+
type: 'credential',
30+
credentialNames: ['togetherAIApi']
31+
}
32+
this.inputs = [
33+
{
34+
label: 'Cache',
35+
name: 'cache',
36+
type: 'BaseCache',
37+
optional: true
38+
},
39+
{
40+
label: 'Model Name',
41+
name: 'modelName',
42+
type: 'string',
43+
placeholder: 'sentence-transformers/msmarco-bert-base-dot-v5',
44+
description: 'Refer to <a target="_blank" href="https://docs.together.ai/docs/embedding-models">embedding models</a> page'
45+
}
46+
]
47+
}
48+
49+
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
50+
const modelName = nodeData.inputs?.modelName as string
51+
52+
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
53+
const togetherAIApiKey = getCredentialParam('togetherAIApiKey', credentialData, nodeData)
54+
55+
const obj: Partial<TogetherAIEmbeddingsParams> = {
56+
modelName: modelName,
57+
apiKey: togetherAIApiKey,
58+
//@ts-ignore
59+
model: modelName,
60+
togetherAIApiKey: togetherAIApiKey
61+
}
62+
63+
const model = new TogetherAIEmbeddings(obj)
64+
return model
65+
}
66+
}
67+
68+
module.exports = { nodeClass: TogetherAIEmbedding_Embeddings }
Loading

0 commit comments

Comments
 (0)