diff --git a/.github/workflows/test-exports.yml b/.github/workflows/test-exports.yml index 15b15338107b..4872490161ff 100644 --- a/.github/workflows/test-exports.yml +++ b/.github/workflows/test-exports.yml @@ -34,7 +34,7 @@ jobs: - name: Install dependencies run: yarn install --immutable - name: Build - run: yarn run build:deps && yarn workspace langchain build + run: yarn run build:deps && yarn build --filter=langchain shell: bash env: SKIP_API_DOCS: true @@ -54,7 +54,7 @@ jobs: - name: Install dependencies run: yarn install --immutable - name: Build - run: yarn run build:deps && yarn workspace langchain build + run: yarn run build:deps && yarn build --filter=langchain shell: bash env: SKIP_API_DOCS: true @@ -74,7 +74,7 @@ jobs: - name: Install dependencies run: yarn install --immutable - name: Build - run: yarn run build:deps && yarn workspace langchain build + run: yarn run build:deps && yarn build --filter=langchain shell: bash env: SKIP_API_DOCS: true @@ -94,7 +94,7 @@ jobs: - name: Install dependencies run: yarn install --immutable - name: Build - run: yarn run build:deps && yarn workspace langchain build + run: yarn run build:deps && yarn build --filter=langchain shell: bash env: SKIP_API_DOCS: true @@ -114,7 +114,7 @@ jobs: - name: Install dependencies run: yarn install --immutable - name: Build - run: yarn run build:deps && yarn workspace langchain build + run: yarn run build:deps && yarn build --filter=langchain shell: bash env: SKIP_API_DOCS: true @@ -134,7 +134,7 @@ jobs: - name: Install dependencies run: yarn install --immutable - name: Build - run: yarn run build:deps && yarn workspace langchain build + run: yarn run build:deps && yarn build --filter=langchain shell: bash env: SKIP_API_DOCS: true @@ -154,7 +154,7 @@ jobs: # - name: Install dependencies # run: yarn install --immutable # - name: Build - # run: yarn run build:deps && yarn workspace langchain build + # run: yarn run build:deps && yarn build --filter=langchain # shell: bash # env: # SKIP_API_DOCS: true diff --git a/docs/api_refs/package.json b/docs/api_refs/package.json index 262b3b25ec30..c14730aabf79 100644 --- a/docs/api_refs/package.json +++ b/docs/api_refs/package.json @@ -1,12 +1,13 @@ { - "name": "api_refs", + "name": "@langchain/api_refs", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev -p 3001", "typedoc": "npx typedoc --options typedoc.json", "build:scripts": "node ./scripts/generate-api-refs.js && node ./scripts/update-typedoc-css.js", - "build": "yarn run build:deps && yarn workspace langchain build && yarn build:scripts && next build", + "build": "yarn turbo run build:next", + "build:next": "next build", "start": "yarn build && next start -p 3001", "lint": "next lint" }, @@ -25,6 +26,7 @@ "postcss": "^8", "tailwindcss": "^3.3.0", "ts-morph": "^20.0.0", + "turbo": "latest", "typescript": "^5" } } diff --git a/docs/api_refs/turbo.json b/docs/api_refs/turbo.json new file mode 100644 index 000000000000..111e2a631744 --- /dev/null +++ b/docs/api_refs/turbo.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://turbo.build/schema.json", + "extends": ["//"], + "pipeline": { + "build:scripts": { + "outputs": ["public/**"], + "dependsOn": [ + "@langchain/openai#build", + "@langchain/anthropic#build", + "langchain#build" + ] + }, + "build:next": { + "outputs": [".next/**", ".vercel/**"], + "dependsOn": ["build:scripts"] + } + } +} diff --git a/docs/core_docs/package.json b/docs/core_docs/package.json index ea690f08c985..5b6c9a24684d 100644 --- a/docs/core_docs/package.json +++ b/docs/core_docs/package.json @@ -1,11 +1,13 @@ { - "name": "core_docs", + "name": "@langchain/core_docs", "version": "0.0.0", "private": true, "scripts": { "docusaurus": "docusaurus", "start": "yarn build:typedoc && rimraf ./docs/api && NODE_OPTIONS=--max-old-space-size=7168 docusaurus start", - "build": "yarn build:typedoc && rimraf ./build && NODE_OPTIONS=--max-old-space-size=7168 DOCUSAURUS_SSR_CONCURRENCY=4 docusaurus build", + "rimraf:build": "rimraf ./build", + "build:docusaurus": "NODE_OPTIONS=--max-old-space-size=7168 DOCUSAURUS_SSR_CONCURRENCY=4 docusaurus build", + "build": "yarn turbo run build:docusaurus", "build:typedoc": "cd ../api_refs && yarn build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", @@ -47,6 +49,7 @@ "prettier": "^2.7.1", "rimraf": "^5.0.1", "swc-loader": "^0.2.3", + "turbo": "latest", "typedoc": "^0.24.4", "typedoc-plugin-markdown": "next" }, diff --git a/docs/core_docs/turbo.json b/docs/core_docs/turbo.json new file mode 100644 index 000000000000..6f1c5b77b96a --- /dev/null +++ b/docs/core_docs/turbo.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://turbo.build/schema.json", + "extends": ["//"], + "pipeline": { + "rimraf:build": { + "dependsOn": ["@langchain/api_refs#build"] + }, + "build:docusaurus": { + "outputs": [".docusaurus/**", "build/**"], + "dependsOn": ["rimraf:build"] + } + } +} diff --git a/langchain-core/src/callbacks/manager.ts b/langchain-core/src/callbacks/manager.ts index baeccb445618..572234de9660 100644 --- a/langchain-core/src/callbacks/manager.ts +++ b/langchain-core/src/callbacks/manager.ts @@ -1,7 +1,7 @@ import { v4 as uuidv4 } from "uuid"; -import { AgentAction, AgentFinish } from "../agents.js"; +import type { AgentAction, AgentFinish } from "../agents.js"; import type { ChainValues } from "../utils/types.js"; -import { LLMResult } from "../outputs.js"; +import type { LLMResult } from "../outputs.js"; import { BaseCallbackHandler, CallbackHandlerMethods, diff --git a/langchain-core/src/language_models/chat_models.ts b/langchain-core/src/language_models/chat_models.ts index 4a426c00b053..ac8d3d96d5e9 100644 --- a/langchain-core/src/language_models/chat_models.ts +++ b/langchain-core/src/language_models/chat_models.ts @@ -2,17 +2,17 @@ import { AIMessage, BaseMessage, BaseMessageChunk, - BaseMessageLike, + type BaseMessageLike, HumanMessage, coerceMessageLikeToMessage, } from "../messages/index.js"; import { BasePromptValue } from "../prompt_values.js"; import { - LLMResult, + type LLMResult, RUN_KEY, - ChatGeneration, + type ChatGeneration, ChatGenerationChunk, - ChatResult, + type ChatResult, } from "../outputs.js"; import { BaseLanguageModel, diff --git a/langchain-core/src/language_models/llms.ts b/langchain-core/src/language_models/llms.ts index c5ccb205cc7d..2bbccea20edc 100644 --- a/langchain-core/src/language_models/llms.ts +++ b/langchain-core/src/language_models/llms.ts @@ -1,11 +1,16 @@ import { AIMessage, BaseMessage, getBufferString } from "../messages/index.js"; import { BasePromptValue } from "../prompt_values.js"; -import { LLMResult, RUN_KEY, Generation, GenerationChunk } from "../outputs.js"; import { - BaseCallbackConfig, + type LLMResult, + RUN_KEY, + type Generation, + GenerationChunk, +} from "../outputs.js"; +import { + type BaseCallbackConfig, CallbackManager, CallbackManagerForLLMRun, - Callbacks, + type Callbacks, } from "../callbacks/manager.js"; import { BaseLanguageModel, @@ -13,7 +18,7 @@ import { type BaseLanguageModelInput, type BaseLanguageModelParams, } from "./base.js"; -import { RunnableConfig } from "../runnables/config.js"; +import type { RunnableConfig } from "../runnables/config.js"; export type SerializedLLM = { _model: string; diff --git a/langchain-core/src/messages/tests/base_message.test.ts b/langchain-core/src/messages/tests/base_message.test.ts index 0e05d2b00bc0..c7b9d2908c41 100644 --- a/langchain-core/src/messages/tests/base_message.test.ts +++ b/langchain-core/src/messages/tests/base_message.test.ts @@ -1,6 +1,6 @@ import { test } from "@jest/globals"; import { ChatPromptTemplate } from "../../prompts/chat.js"; -import { HumanMessage } from "../../messages/index.js"; +import { HumanMessage } from "../index.js"; test("Test ChatPromptTemplate can format OpenAI content image messages", async () => { const message = new HumanMessage({ diff --git a/package.json b/package.json index af0779770ea1..b821d01e3a71 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,12 @@ "packageManager": "yarn@3.4.1", "scripts": { "build": "turbo run build --filter=\"!test-exports-*\" --concurrency 1", - "build:deps": "yarn workspace @langchain/core build && yarn workspace @langchain/anthropic build && yarn workspace @langchain/openai build", + "build:deps": "yarn build --filter=@langchain/openai --filter=@langchain/anthropic --filter=@langchain/core", "format": "turbo run format", "format:check": "turbo run format:check", "lint": "turbo run lint --concurrency 1", "lint:fix": "yarn lint -- --fix", - "test": "yarn test:unit && yarn workspace @langchain/core build && yarn workspace langchain build && yarn test:exports:docker", + "test": "yarn test:unit && yarn build --filter=langchain && yarn test:exports:docker", "test:unit": "turbo run test --filter @langchain/core --filter langchain", "test:int": "yarn run test:int:deps && turbo run test:integration ; yarn run test:int:deps:down", "test:int:deps": "docker compose -f test-int-deps-docker-compose.yml up -d", @@ -34,8 +34,8 @@ "publish:core": "bash langchain/scripts/release-branch.sh && turbo run --filter @langchain/core build lint test --concurrency 1 && yarn run test:exports:docker && yarn workspace @langchain/core run release && echo '🔗 Open https://github.com/langchain-ai/langchainjs/compare/release?expand=1 and merge the release PR'", "example": "yarn workspace examples start", "precommit": "turbo run precommit", - "docs": "yarn workspace core_docs start", - "docs:api_refs": "yarn workspace api_refs start" + "docs": "yarn workspace @langchain/core_docs start", + "docs:api_refs": "yarn workspace @langchain/api_refs start" }, "author": "LangChain", "license": "MIT", diff --git a/turbo.json b/turbo.json index a3910c255d9d..1324193d7ff9 100644 --- a/turbo.json +++ b/turbo.json @@ -1,38 +1,32 @@ { "$schema": "https://turbo.build/schema.json", - "globalDependencies": [ - "**/.env" - ], + "globalDependencies": ["**/.env"], "pipeline": { - "@langchain/core#build": {}, - "libs/langchain-anthropic#build": { - "dependsOn": [ - "@langchain/core#build" + "@langchain/core#build": { + "outputs": [ + "langchain-core/dist/**", + "langchain-core/dist-cjs/**", + "langchain-core/*.js", + "langchain-core/*.cjs", + "langchain-core/*.d.ts" + ], + "inputs": [ + "langchain-core/src/**", + "langchain-core/scripts/**", + "langchain-core/package.json", + "langchain-core/tsconfig.json" ] }, + "libs/langchain-anthropic#build": { + "dependsOn": ["@langchain/core#build"] + }, "libs/langchain-openai#build": { - "dependsOn": [ - "@langchain/core#build" - ] + "dependsOn": ["@langchain/core#build"] }, "build": { - "dependsOn": [ - "@langchain/core#build", - "^build" - ], - "outputs": [ - "dist/**", - "dist-cjs/**", - "*.js", - "*.cjs", - "*.d.ts" - ], - "inputs": [ - "src/**", - "scripts/**", - "package.json", - "tsconfig.json" - ] + "dependsOn": ["@langchain/core#build", "^build"], + "outputs": ["dist/**", "dist-cjs/**", "*.js", "*.cjs", "*.d.ts"], + "inputs": ["src/**", "scripts/**", "package.json", "tsconfig.json"] }, "lint": { "outputs": [] @@ -45,15 +39,11 @@ }, "test": { "outputs": [], - "dependsOn": [ - "^build" - ] + "dependsOn": ["^build"] }, "test:integration": { "outputs": [], - "dependsOn": [ - "^build" - ] + "dependsOn": ["^build"] }, "precommit": {}, "start": { diff --git a/yarn.lock b/yarn.lock index e044f63324bd..ae44b3e678f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7997,6 +7997,27 @@ __metadata: languageName: unknown linkType: soft +"@langchain/api_refs@workspace:docs/api_refs": + version: 0.0.0-use.local + resolution: "@langchain/api_refs@workspace:docs/api_refs" + dependencies: + "@types/node": ^20 + "@types/react": ^18 + "@types/react-dom": ^18 + autoprefixer: ^10.0.1 + eslint: ^8 + eslint-config-next: 14.0.1 + next: 14.0.1 + postcss: ^8 + react: ^18 + react-dom: ^18 + tailwindcss: ^3.3.0 + ts-morph: ^20.0.0 + turbo: latest + typescript: ^5 + languageName: unknown + linkType: soft + "@langchain/core@workspace:*, @langchain/core@workspace:langchain-core, @langchain/core@~0.0.6": version: 0.0.0-use.local resolution: "@langchain/core@workspace:langchain-core" @@ -8030,6 +8051,41 @@ __metadata: languageName: unknown linkType: soft +"@langchain/core_docs@workspace:docs/core_docs": + version: 0.0.0-use.local + resolution: "@langchain/core_docs@workspace:docs/core_docs" + dependencies: + "@babel/eslint-parser": ^7.18.2 + "@docusaurus/core": 2.4.1 + "@docusaurus/preset-classic": 2.4.1 + "@docusaurus/remark-plugin-npm2yarn": ^2.4.1 + "@mdx-js/react": ^1.6.22 + "@mendable/search": ^0.0.160 + "@swc/core": ^1.3.62 + clsx: ^1.2.1 + docusaurus-plugin-typedoc: 1.0.0-next.5 + eslint: ^8.19.0 + eslint-config-airbnb: ^19.0.4 + eslint-config-prettier: ^8.5.0 + eslint-plugin-header: ^3.1.1 + eslint-plugin-import: ^2.26.0 + eslint-plugin-jsx-a11y: ^6.6.0 + eslint-plugin-react: ^7.30.1 + eslint-plugin-react-hooks: ^4.6.0 + json-loader: ^0.5.7 + prettier: ^2.7.1 + process: ^0.11.10 + react: ^17.0.2 + react-dom: ^17.0.2 + rimraf: ^5.0.1 + swc-loader: ^0.2.3 + turbo: latest + typedoc: ^0.24.4 + typedoc-plugin-markdown: next + webpack: ^5.75.0 + languageName: unknown + linkType: soft + "@langchain/openai@workspace:libs/langchain-openai": version: 0.0.0-use.local resolution: "@langchain/openai@workspace:libs/langchain-openai" @@ -13099,26 +13155,6 @@ __metadata: languageName: node linkType: hard -"api_refs@workspace:docs/api_refs": - version: 0.0.0-use.local - resolution: "api_refs@workspace:docs/api_refs" - dependencies: - "@types/node": ^20 - "@types/react": ^18 - "@types/react-dom": ^18 - autoprefixer: ^10.0.1 - eslint: ^8 - eslint-config-next: 14.0.1 - next: 14.0.1 - postcss: ^8 - react: ^18 - react-dom: ^18 - tailwindcss: ^3.3.0 - ts-morph: ^20.0.0 - typescript: ^5 - languageName: unknown - linkType: soft - "apify-client@npm:^2.7.1": version: 2.7.1 resolution: "apify-client@npm:2.7.1" @@ -15475,40 +15511,6 @@ __metadata: languageName: node linkType: hard -"core_docs@workspace:docs/core_docs": - version: 0.0.0-use.local - resolution: "core_docs@workspace:docs/core_docs" - dependencies: - "@babel/eslint-parser": ^7.18.2 - "@docusaurus/core": 2.4.1 - "@docusaurus/preset-classic": 2.4.1 - "@docusaurus/remark-plugin-npm2yarn": ^2.4.1 - "@mdx-js/react": ^1.6.22 - "@mendable/search": ^0.0.160 - "@swc/core": ^1.3.62 - clsx: ^1.2.1 - docusaurus-plugin-typedoc: 1.0.0-next.5 - eslint: ^8.19.0 - eslint-config-airbnb: ^19.0.4 - eslint-config-prettier: ^8.5.0 - eslint-plugin-header: ^3.1.1 - eslint-plugin-import: ^2.26.0 - eslint-plugin-jsx-a11y: ^6.6.0 - eslint-plugin-react: ^7.30.1 - eslint-plugin-react-hooks: ^4.6.0 - json-loader: ^0.5.7 - prettier: ^2.7.1 - process: ^0.11.10 - react: ^17.0.2 - react-dom: ^17.0.2 - rimraf: ^5.0.1 - swc-loader: ^0.2.3 - typedoc: ^0.24.4 - typedoc-plugin-markdown: next - webpack: ^5.75.0 - languageName: unknown - linkType: soft - "cosmiconfig@npm:8.0.0": version: 8.0.0 resolution: "cosmiconfig@npm:8.0.0"