Skip to content

Commit f7846d5

Browse files
authored
fix(create-langchain-integration): Update integration template (#7458)
1 parent 4d82ce9 commit f7846d5

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

libs/create-langchain-integration/template/package.json

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "langchain-integration",
33
"version": "0.0.0",
4-
"description": "Sample integration for LangChain.js",
4+
"description": "Sample INTEGRATION_SHORT_NAME integration for LangChain.js",
55
"type": "module",
66
"engines": {
77
"node": ">=18"
@@ -12,7 +12,7 @@
1212
"type": "git",
1313
"url": "[email protected]:langchain-ai/langchainjs.git"
1414
},
15-
"homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-INTEGRATION_NAME/",
15+
"homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/INTEGRATION_NAME/",
1616
"scripts": {
1717
"build": "yarn turbo:command build:internal --filter=@langchain/INTEGRATION_NAME",
1818
"build:internal": "yarn lc_build --create-entrypoints --pre --tree-shaking",
@@ -31,13 +31,14 @@
3131
},
3232
"author": "LangChain",
3333
"license": "MIT",
34-
"dependencies": {
34+
"peerDependencies": {
3535
"@langchain/core": ">=0.3.0 <0.4.0"
3636
},
3737
"devDependencies": {
3838
"@jest/globals": "^29.5.0",
3939
"@swc/core": "^1.3.90",
4040
"@swc/jest": "^0.2.29",
41+
"@langchain/core": "workspace:*",
4142
"@langchain/scripts": ">=0.1.0 <0.2.0",
4243
"@tsconfig/recommended": "^1.0.3",
4344
"@typescript-eslint/eslint-plugin": "^6.12.0",
@@ -63,7 +64,11 @@
6364
},
6465
"exports": {
6566
".": {
66-
"types": "./index.d.ts",
67+
"types": {
68+
"import": "./index.d.ts",
69+
"require": "./index.d.cts",
70+
"default": "./index.d.ts"
71+
},
6772
"import": "./index.js",
6873
"require": "./index.cjs"
6974
},
@@ -73,6 +78,7 @@
7378
"dist/",
7479
"index.cjs",
7580
"index.js",
76-
"index.d.ts"
81+
"index.d.ts",
82+
"index.d.cts"
7783
]
78-
}
84+
}

libs/create-langchain-integration/template/src/chat_models.ts

+26-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ import {
1616
// AIMessageChunk,
1717
// } from "@langchain/core/messages";
1818

19+
// Uncomment if implementing tool calling
20+
21+
// import {
22+
// type BindToolsInput,
23+
// } from "@langchain/core/language_models/chat_models";
24+
1925
/**
2026
* Input to chat model class.
2127
*/
@@ -24,10 +30,10 @@ export interface ChatIntegrationInput extends BaseChatModelParams {}
2430
/**
2531
* Integration with a chat model.
2632
*/
27-
export class ChatIntegration<
28-
CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions
29-
>
30-
extends SimpleChatModel<CallOptions>
33+
export class ChatIntegration
34+
// Extend BaseLanguageModelCallOptions and pass it as the generic here
35+
// to support typing for additional runtime parameters for your integration
36+
extends SimpleChatModel<BaseLanguageModelCallOptions>
3137
implements ChatIntegrationInput
3238
{
3339
// Used for tracing, replace with the same name as your class
@@ -98,6 +104,22 @@ export class ChatIntegration<
98104
// }
99105
// }
100106

107+
/**
108+
* Implement to support tool calling.
109+
* You must also pass the bound tools into your actual chat completion call.
110+
* See {@link ../../langchain-cerberas/src/chat_model.ts} for
111+
* an example.
112+
*/
113+
// override bindTools(
114+
// tools: BindToolsInput[],
115+
// kwargs?: Partial<this["ParsedCallOptions"]>
116+
// ): Runnable<BaseLanguageModelInput, AIMessageChunk, BaseLanguageModelCallOptions> {
117+
// return this.bind({
118+
// tools: tools.map((tool) => convertToIntegrationFormat(tool)),
119+
// ...kwargs,
120+
// });
121+
// }
122+
101123
/** @ignore */
102124
_combineLLMOutput() {
103125
return [];

0 commit comments

Comments
 (0)