Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(create-langchain-integration): Update integration template #7458

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading