Skip to content

Commit

Permalink
fix(create-langchain-integration): Update integration template (#7458)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 authored Jan 2, 2025
1 parent 4d82ce9 commit f7846d5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
18 changes: 12 additions & 6 deletions libs/create-langchain-integration/template/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "langchain-integration",
"version": "0.0.0",
"description": "Sample integration for LangChain.js",
"description": "Sample INTEGRATION_SHORT_NAME integration for LangChain.js",
"type": "module",
"engines": {
"node": ">=18"
Expand All @@ -12,7 +12,7 @@
"type": "git",
"url": "[email protected]:langchain-ai/langchainjs.git"
},
"homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-INTEGRATION_NAME/",
"homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/INTEGRATION_NAME/",
"scripts": {
"build": "yarn turbo:command build:internal --filter=@langchain/INTEGRATION_NAME",
"build:internal": "yarn lc_build --create-entrypoints --pre --tree-shaking",
Expand All @@ -31,13 +31,14 @@
},
"author": "LangChain",
"license": "MIT",
"dependencies": {
"peerDependencies": {
"@langchain/core": ">=0.3.0 <0.4.0"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"@langchain/core": "workspace:*",
"@langchain/scripts": ">=0.1.0 <0.2.0",
"@tsconfig/recommended": "^1.0.3",
"@typescript-eslint/eslint-plugin": "^6.12.0",
Expand All @@ -63,7 +64,11 @@
},
"exports": {
".": {
"types": "./index.d.ts",
"types": {
"import": "./index.d.ts",
"require": "./index.d.cts",
"default": "./index.d.ts"
},
"import": "./index.js",
"require": "./index.cjs"
},
Expand All @@ -73,6 +78,7 @@
"dist/",
"index.cjs",
"index.js",
"index.d.ts"
"index.d.ts",
"index.d.cts"
]
}
}
30 changes: 26 additions & 4 deletions libs/create-langchain-integration/template/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import {
// AIMessageChunk,
// } from "@langchain/core/messages";

// Uncomment if implementing tool calling

// import {
// type BindToolsInput,
// } from "@langchain/core/language_models/chat_models";

/**
* Input to chat model class.
*/
Expand All @@ -24,10 +30,10 @@ export interface ChatIntegrationInput extends BaseChatModelParams {}
/**
* Integration with a chat model.
*/
export class ChatIntegration<
CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions
>
extends SimpleChatModel<CallOptions>
export class ChatIntegration
// Extend BaseLanguageModelCallOptions and pass it as the generic here
// to support typing for additional runtime parameters for your integration
extends SimpleChatModel<BaseLanguageModelCallOptions>
implements ChatIntegrationInput
{
// Used for tracing, replace with the same name as your class
Expand Down Expand Up @@ -98,6 +104,22 @@ export class ChatIntegration<
// }
// }

/**
* Implement to support tool calling.
* You must also pass the bound tools into your actual chat completion call.
* See {@link ../../langchain-cerberas/src/chat_model.ts} for
* an example.
*/
// override bindTools(
// tools: BindToolsInput[],
// kwargs?: Partial<this["ParsedCallOptions"]>
// ): Runnable<BaseLanguageModelInput, AIMessageChunk, BaseLanguageModelCallOptions> {
// return this.bind({
// tools: tools.map((tool) => convertToIntegrationFormat(tool)),
// ...kwargs,
// });
// }

/** @ignore */
_combineLLMOutput() {
return [];
Expand Down

0 comments on commit f7846d5

Please sign in to comment.