Skip to content

Commit

Permalink
Include Groq provider
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Nov 6, 2024
1 parent 8043bf9 commit 3608c0b
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@jupyterlab/rendermime": "^4.2.0",
"@jupyterlab/settingregistry": "^4.2.0",
"@langchain/core": "^0.3.13",
"@langchain/groq": "^0.1.2",
"@langchain/mistralai": "^0.1.1",
"@lumino/coreutils": "^2.1.2",
"@lumino/polling": "^2.1.2",
Expand Down
2 changes: 1 addition & 1 deletion schema/ai-provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"title": "The AI provider",
"description": "The AI provider to use for chat and completion",
"default": "None",
"enum": ["None", "MistralAI"]
"enum": ["None", "MistralAI", "Groq"]
},
"apiKey": {
"type": "string",
Expand Down
5 changes: 5 additions & 0 deletions src/llm-models/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
import { ChatMistralAI } from '@langchain/mistralai';
import { ChatGroq } from '@langchain/groq';
import { IBaseCompleter } from './base-completer';
import { CodestralCompleter } from './codestral-completer';
import { ReadonlyPartialJSONObject } from '@lumino/coreutils';
Expand All @@ -26,6 +27,8 @@ export function getChatModel(
): BaseChatModel | null {
if (name === 'MistralAI') {
return new ChatMistralAI({ ...settings });
} else if (name === 'Groq') {
return new ChatGroq({ ...settings });
}
return null;
}
Expand All @@ -36,6 +39,8 @@ export function getChatModel(
export function getErrorMessage(name: string, error: any): string {
if (name === 'MistralAI') {
return error.message;
} else if (name === 'Groq') {
return error.error.error.message;
}
return 'Unknown provider';
}
210 changes: 209 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,20 @@ __metadata:
languageName: node
linkType: hard

"@langchain/groq@npm:^0.1.2":
version: 0.1.2
resolution: "@langchain/groq@npm:0.1.2"
dependencies:
"@langchain/openai": ~0.3.0
groq-sdk: ^0.5.0
zod: ^3.22.4
zod-to-json-schema: ^3.22.5
peerDependencies:
"@langchain/core": ">=0.2.21 <0.4.0"
checksum: 79da224a6428f1350d5e0bc91b5a3cde5ed03c1aaa3524f2216b60954a9790ed0a0299faff562d4517219dc173bbf235bfd1bb53160a72ce8852d4718af8cf84
languageName: node
linkType: hard

"@langchain/mistralai@npm:^0.1.1":
version: 0.1.1
resolution: "@langchain/mistralai@npm:0.1.1"
Expand All @@ -1534,6 +1548,20 @@ __metadata:
languageName: node
linkType: hard

"@langchain/openai@npm:~0.3.0":
version: 0.3.11
resolution: "@langchain/openai@npm:0.3.11"
dependencies:
js-tiktoken: ^1.0.12
openai: ^4.68.0
zod: ^3.22.4
zod-to-json-schema: ^3.22.3
peerDependencies:
"@langchain/core": ">=0.2.26 <0.4.0"
checksum: ea0fe974320a387469b91312c2a2a0ee80f194c7954b8aca0d8ab9cf68fd25ef74663af2e644d217257f2317dee2ac04ff0006b5dd9d3701f52daabfa097d868
languageName: node
linkType: hard

"@lezer/common@npm:^1.0.0, @lezer/common@npm:^1.0.2, @lezer/common@npm:^1.1.0, @lezer/common@npm:^1.2.0, @lezer/common@npm:^1.2.1":
version: 1.2.1
resolution: "@lezer/common@npm:1.2.1"
Expand Down Expand Up @@ -2272,6 +2300,16 @@ __metadata:
languageName: node
linkType: hard

"@types/node-fetch@npm:^2.6.4":
version: 2.6.11
resolution: "@types/node-fetch@npm:2.6.11"
dependencies:
"@types/node": "*"
form-data: ^4.0.0
checksum: 180e4d44c432839bdf8a25251ef8c47d51e37355ddd78c64695225de8bc5dc2b50b7bb855956d471c026bb84bd7295688a0960085e7158cbbba803053492568b
languageName: node
linkType: hard

"@types/node@npm:*":
version: 20.14.2
resolution: "@types/node@npm:20.14.2"
Expand All @@ -2281,6 +2319,15 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^18.11.18":
version: 18.19.64
resolution: "@types/node@npm:18.19.64"
dependencies:
undici-types: ~5.26.4
checksum: e7680215b03c9bee8a33947f03d06048e8e460f23b1b7b29c45350cf437faa5f8fcb7d8c3eb8dfec8427923e7a184df42bc710c1b6252b4852e3ed7064c6228f
languageName: node
linkType: hard

"@types/normalize-package-data@npm:^2.4.0":
version: 2.4.4
resolution: "@types/normalize-package-data@npm:2.4.4"
Expand Down Expand Up @@ -2705,6 +2752,15 @@ __metadata:
languageName: node
linkType: hard

"abort-controller@npm:^3.0.0":
version: 3.0.0
resolution: "abort-controller@npm:3.0.0"
dependencies:
event-target-shim: ^5.0.0
checksum: 170bdba9b47b7e65906a28c8ce4f38a7a369d78e2271706f020849c1bfe0ee2067d4261df8bbb66eb84f79208fd5b710df759d64191db58cfba7ce8ef9c54b75
languageName: node
linkType: hard

"acorn-import-assertions@npm:^1.9.0":
version: 1.9.0
resolution: "acorn-import-assertions@npm:1.9.0"
Expand Down Expand Up @@ -2732,6 +2788,15 @@ __metadata:
languageName: node
linkType: hard

"agentkeepalive@npm:^4.2.1":
version: 4.5.0
resolution: "agentkeepalive@npm:4.5.0"
dependencies:
humanize-ms: ^1.2.1
checksum: 13278cd5b125e51eddd5079f04d6fe0914ac1b8b91c1f3db2c1822f99ac1a7457869068997784342fe455d59daaff22e14fb7b8c3da4e741896e7e31faf92481
languageName: node
linkType: hard

"ajv-formats@npm:^2.1.1":
version: 2.1.1
resolution: "ajv-formats@npm:2.1.1"
Expand Down Expand Up @@ -2890,6 +2955,13 @@ __metadata:
languageName: node
linkType: hard

"asynckit@npm:^0.4.0":
version: 0.4.0
resolution: "asynckit@npm:0.4.0"
checksum: 7b78c451df768adba04e2d02e63e2d0bf3b07adcd6e42b4cf665cb7ce899bedd344c69a1dcbce355b5f972d597b25aaa1c1742b52cffd9caccb22f348114f6be
languageName: node
linkType: hard

"available-typed-arrays@npm:^1.0.7":
version: 1.0.7
resolution: "available-typed-arrays@npm:1.0.7"
Expand Down Expand Up @@ -3125,6 +3197,15 @@ __metadata:
languageName: node
linkType: hard

"combined-stream@npm:^1.0.8":
version: 1.0.8
resolution: "combined-stream@npm:1.0.8"
dependencies:
delayed-stream: ~1.0.0
checksum: 49fa4aeb4916567e33ea81d088f6584749fc90c7abec76fd516bf1c5aa5c79f3584b5ba3de6b86d26ddd64bae5329c4c7479343250cfe71c75bb366eae53bb7c
languageName: node
linkType: hard

"commander@npm:^10.0.1":
version: 10.0.1
resolution: "commander@npm:10.0.1"
Expand Down Expand Up @@ -3424,6 +3505,13 @@ __metadata:
languageName: node
linkType: hard

"delayed-stream@npm:~1.0.0":
version: 1.0.0
resolution: "delayed-stream@npm:1.0.0"
checksum: 46fe6e83e2cb1d85ba50bd52803c68be9bd953282fa7096f51fc29edd5d67ff84ff753c51966061e5ba7cb5e47ef6d36a91924eddb7f3f3483b1c560f77a0020
languageName: node
linkType: hard

"dir-glob@npm:^3.0.1":
version: 3.0.1
resolution: "dir-glob@npm:3.0.1"
Expand Down Expand Up @@ -3857,6 +3945,13 @@ __metadata:
languageName: node
linkType: hard

"event-target-shim@npm:^5.0.0":
version: 5.0.1
resolution: "event-target-shim@npm:5.0.1"
checksum: 1ffe3bb22a6d51bdeb6bf6f7cf97d2ff4a74b017ad12284cc9e6a279e727dc30a5de6bb613e5596ff4dc3e517841339ad09a7eec44266eccb1aa201a30448166
languageName: node
linkType: hard

"eventemitter3@npm:^4.0.4":
version: 4.0.7
resolution: "eventemitter3@npm:4.0.7"
Expand Down Expand Up @@ -4035,6 +4130,34 @@ __metadata:
languageName: node
linkType: hard

"form-data-encoder@npm:1.7.2":
version: 1.7.2
resolution: "form-data-encoder@npm:1.7.2"
checksum: aeebd87a1cb009e13cbb5e4e4008e6202ed5f6551eb6d9582ba8a062005178907b90f4887899d3c993de879159b6c0c940af8196725b428b4248cec5af3acf5f
languageName: node
linkType: hard

"form-data@npm:^4.0.0":
version: 4.0.1
resolution: "form-data@npm:4.0.1"
dependencies:
asynckit: ^0.4.0
combined-stream: ^1.0.8
mime-types: ^2.1.12
checksum: ccee458cd5baf234d6b57f349fe9cc5f9a2ea8fd1af5ecda501a18fd1572a6dd3bf08a49f00568afd995b6a65af34cb8dec083cf9d582c4e621836499498dd84
languageName: node
linkType: hard

"formdata-node@npm:^4.3.2":
version: 4.4.1
resolution: "formdata-node@npm:4.4.1"
dependencies:
node-domexception: 1.0.0
web-streams-polyfill: 4.0.0-beta.3
checksum: d91d4f667cfed74827fc281594102c0dabddd03c9f8b426fc97123eedbf73f5060ee43205d89284d6854e2fc5827e030cd352ef68b93beda8decc2d72128c576
languageName: node
linkType: hard

"free-style@npm:3.1.0":
version: 3.1.0
resolution: "free-style@npm:3.1.0"
Expand Down Expand Up @@ -4268,6 +4391,22 @@ __metadata:
languageName: node
linkType: hard

"groq-sdk@npm:^0.5.0":
version: 0.5.0
resolution: "groq-sdk@npm:0.5.0"
dependencies:
"@types/node": ^18.11.18
"@types/node-fetch": ^2.6.4
abort-controller: ^3.0.0
agentkeepalive: ^4.2.1
form-data-encoder: 1.7.2
formdata-node: ^4.3.2
node-fetch: ^2.6.7
web-streams-polyfill: ^3.2.1
checksum: 051ca56e99e4a2440080943c831b109687dd346b24155d3f085113df1ad0639cb95724c14a05611f7314d340db8bf342af425eb11905c97bc6a6948cd7262f04
languageName: node
linkType: hard

"hard-rejection@npm:^2.1.0":
version: 2.1.0
resolution: "hard-rejection@npm:2.1.0"
Expand Down Expand Up @@ -4381,6 +4520,15 @@ __metadata:
languageName: node
linkType: hard

"humanize-ms@npm:^1.2.1":
version: 1.2.1
resolution: "humanize-ms@npm:1.2.1"
dependencies:
ms: ^2.0.0
checksum: 9c7a74a2827f9294c009266c82031030eae811ca87b0da3dceb8d6071b9bde22c9f3daef0469c3c533cc67a97d8a167cd9fc0389350e5f415f61a79b171ded16
languageName: node
linkType: hard

"iconv-lite@npm:^0.6.2":
version: 0.6.3
resolution: "iconv-lite@npm:0.6.3"
Expand Down Expand Up @@ -4884,6 +5032,7 @@ __metadata:
"@jupyterlab/rendermime": ^4.2.0
"@jupyterlab/settingregistry": ^4.2.0
"@langchain/core": ^0.3.13
"@langchain/groq": ^0.1.2
"@langchain/mistralai": ^0.1.1
"@lumino/coreutils": ^2.1.2
"@lumino/polling": ^2.1.2
Expand Down Expand Up @@ -5209,7 +5358,7 @@ __metadata:
languageName: node
linkType: hard

"mime-types@npm:^2.1.27":
"mime-types@npm:^2.1.12, mime-types@npm:^2.1.27":
version: 2.1.35
resolution: "mime-types@npm:2.1.35"
dependencies:
Expand Down Expand Up @@ -5305,6 +5454,13 @@ __metadata:
languageName: node
linkType: hard

"ms@npm:^2.0.0":
version: 2.1.3
resolution: "ms@npm:2.1.3"
checksum: aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d
languageName: node
linkType: hard

"mustache@npm:^4.2.0":
version: 4.2.0
resolution: "mustache@npm:4.2.0"
Expand Down Expand Up @@ -5344,6 +5500,13 @@ __metadata:
languageName: node
linkType: hard

"node-domexception@npm:1.0.0":
version: 1.0.0
resolution: "node-domexception@npm:1.0.0"
checksum: ee1d37dd2a4eb26a8a92cd6b64dfc29caec72bff5e1ed9aba80c294f57a31ba4895a60fd48347cf17dd6e766da0ae87d75657dfd1f384ebfa60462c2283f5c7f
languageName: node
linkType: hard

"node-fetch@npm:^2.6.7":
version: 2.7.0
resolution: "node-fetch@npm:2.7.0"
Expand Down Expand Up @@ -5459,6 +5622,28 @@ __metadata:
languageName: node
linkType: hard

"openai@npm:^4.68.0":
version: 4.70.3
resolution: "openai@npm:4.70.3"
dependencies:
"@types/node": ^18.11.18
"@types/node-fetch": ^2.6.4
abort-controller: ^3.0.0
agentkeepalive: ^4.2.1
form-data-encoder: 1.7.2
formdata-node: ^4.3.2
node-fetch: ^2.6.7
peerDependencies:
zod: ^3.23.8
peerDependenciesMeta:
zod:
optional: true
bin:
openai: bin/cli
checksum: 6aa40cb8362b966f56dd10c31e2d60ba97989f4d1d3fe18602838b1be49b38bc1ae412b8ebd97a518e450ac2bca71e312508059da1656c0eef015cdfcccfed1f
languageName: node
linkType: hard

"optionator@npm:^0.9.3":
version: 0.9.4
resolution: "optionator@npm:0.9.4"
Expand Down Expand Up @@ -7183,6 +7368,20 @@ __metadata:
languageName: node
linkType: hard

"web-streams-polyfill@npm:4.0.0-beta.3":
version: 4.0.0-beta.3
resolution: "web-streams-polyfill@npm:4.0.0-beta.3"
checksum: dfec1fbf52b9140e4183a941e380487b6c3d5d3838dd1259be81506c1c9f2abfcf5aeb670aeeecfd9dff4271a6d8fef931b193c7bedfb42542a3b05ff36c0d16
languageName: node
linkType: hard

"web-streams-polyfill@npm:^3.2.1":
version: 3.3.3
resolution: "web-streams-polyfill@npm:3.3.3"
checksum: 21ab5ea08a730a2ef8023736afe16713b4f2023ec1c7085c16c8e293ee17ed085dff63a0ad8722da30c99c4ccbd4ccd1b2e79c861829f7ef2963d7de7004c2cb
languageName: node
linkType: hard

"webidl-conversions@npm:^3.0.0":
version: 3.0.1
resolution: "webidl-conversions@npm:3.0.1"
Expand Down Expand Up @@ -7507,6 +7706,15 @@ __metadata:
languageName: node
linkType: hard

"zod-to-json-schema@npm:^3.22.5":
version: 3.23.5
resolution: "zod-to-json-schema@npm:3.23.5"
peerDependencies:
zod: ^3.23.3
checksum: 3ac37128d1b989b027e55684201e1da90237f0955dc9bb40da013bc60f2ed23c57026df2fdc14da187be4d53873daad08210807c28c0dde4375c9df0e5fe7901
languageName: node
linkType: hard

"zod@npm:^3.22.4":
version: 3.23.8
resolution: "zod@npm:3.23.8"
Expand Down

0 comments on commit 3608c0b

Please sign in to comment.