Skip to content

Commit

Permalink
Add deprecation notice to deprecated entrypoints, update remaining do…
Browse files Browse the repository at this point in the history
…cs/examples
  • Loading branch information
nfcampos committed Apr 9, 2023
1 parent b97c1d4 commit 3f3cdd3
Show file tree
Hide file tree
Showing 49 changed files with 92 additions and 50 deletions.
7 changes: 4 additions & 3 deletions docs/docs/getting-started/guide-llm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The most basic building block of LangChain is calling an LLM on some input. Let'
In order to do this, we first need to import the LLM wrapper.

```typescript
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
```

We will then need to set the environment variable for the OpenAI key. Three options here:
Expand Down Expand Up @@ -165,9 +165,10 @@ SERPAPI_API_KEY="..."
Now we can get started!
```typescript
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor } from "langchain/agents";
import { SerpAPI, Calculator } from "langchain/tools";
import { SerpAPI } from "langchain/tools";
import { Calculator } from "langchain/tools/calculator";
const model = new OpenAI({ temperature: 0 });
const tools = [new SerpAPI(), new Calculator()];
Expand Down
5 changes: 3 additions & 2 deletions docs/docs/modules/agents/executor/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ SERPAPI_API_KEY="..."
Now we can get started!

```typescript
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor } from "langchain/agents";
import { SerpAPI, Calculator } from "langchain/tools";
import { SerpAPI } from "langchain/tools";
import { Calculator } from "langchain/tools/calculator";

const model = new OpenAI({ temperature: 0 });
const tools = [new SerpAPI(), new Calculator()];
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/agents/toolkits/examples/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
This example shows how to load and use an agent with a JSON toolkit.

```typescript
import { OpenAI } from "langchain";
import * as fs from "fs";
import * as yaml from "js-yaml";
import { OpenAI } from "langchain/llms/openai";
import { JsonSpec, JsonObject } from "langchain/tools";
import { JsonToolkit, createJsonAgent } from "langchain/agents";

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/agents/toolkits/examples/openapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ This example shows how to load and use an agent with a OpenAPI toolkit.
```typescript
import * as fs from "fs";
import * as yaml from "js-yaml";
import { OpenAI } from "langchain/llms/openai";
import { JsonSpec, JsonObject } from "langchain/tools";
import { createOpenApiAgent, OpenApiToolkit } from "langchain/agents";
import { OpenAI } from "langchain";

export const run = async () => {
let data: JsonObject;
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/agents/toolkits/examples/vectorstore.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example shows how to load and use an agent with a vectorstore toolkit.

```typescript
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { HNSWLib } from "langchain/vectorstores/hnswlib";
import { OpenAIEmbeddings } from "langchain/embeddings/openai";
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/agents/tools/agents_with_vectorstores.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The recommended method for doing so is to create a VectorDBQAChain and then use
First, you'll want to import the relevant modules:

```typescript
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor } from "langchain/agents";
import { SerpAPI, Calculator, ChainTool } from "langchain/tools";
import { VectorDBQAChain } from "langchain/chains";
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/agents/tools/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The `DynamicTool` class takes as input a name, a description, and a function. Im
See below for an example of defining and using `DynamicTool`s.

```typescript
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor } from "langchain/agents";
import { DynamicTool } from "langchain/tools";

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/agents/tools/zapier_agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This quick start will focus on the server-side use case for brevity. Review full
This example goes over how to use the Zapier integration an Agent. In code, below:

```typescript
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor, ZapierToolKit } from "langchain/agents";
import { ZapierNLAWrapper } from "langchain/tools";

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/production/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You can also use the `langchain-server` command if you have the python `langchai
Here's an example of how to use tracing in `langchain.js`. All that needs to be done is setting the `LANGCHAIN_HANDLER` environment variable to `langchain`.

```typescript
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor } from "langchain/agents";
import { SerpAPI } from "langchain/tools";
import { Calculator } from "langchain/tools/calculator";
Expand Down Expand Up @@ -41,7 +41,7 @@ export const run = async () => {
We are actively working on improving tracing to work better with concurrency. For now, the best way to use tracing with concurrency is to follow the below example:

```typescript
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor } from "langchain/agents";
import { SerpAPI } from "langchain/tools";
import { Calculator } from "langchain/tools/calculator";
Expand Down
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"format": "prettier --write \"**/*.ts\"",
"format:check": "prettier --check \"**/*.ts\""
},
"author": "Langchain",
"author": "LangChain",
"license": "MIT",
"dependencies": {
"@dqbd/tiktoken": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/src/agents/concurrent_mrkl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor, Agent } from "langchain/agents";
import { SerpAPI } from "langchain/tools";
import { Calculator } from "langchain/tools/calculator";
Expand Down
2 changes: 1 addition & 1 deletion examples/src/agents/custom_tool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor } from "langchain/agents";
import { DynamicTool } from "langchain/tools";

Expand Down
2 changes: 1 addition & 1 deletion examples/src/agents/json.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OpenAI } from "langchain";
import * as fs from "fs";
import * as yaml from "js-yaml";
import { OpenAI } from "langchain/llms/openai";
import { JsonSpec, JsonObject } from "langchain/tools";
import { JsonToolkit, createJsonAgent } from "langchain/agents";

Expand Down
2 changes: 1 addition & 1 deletion examples/src/agents/load_from_hub.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { AgentExecutor } from "langchain/agents";
import { loadAgent } from "langchain/agents/load";
import { SerpAPI } from "langchain/tools";
Expand Down
2 changes: 1 addition & 1 deletion examples/src/agents/mrkl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor } from "langchain/agents";
import { SerpAPI } from "langchain/tools";
import { Calculator } from "langchain/tools/calculator";
Expand Down
2 changes: 1 addition & 1 deletion examples/src/agents/mrkl_with_tracing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor } from "langchain/agents";
import { SerpAPI } from "langchain/tools";
import { Calculator } from "langchain/tools/calculator";
Expand Down
2 changes: 1 addition & 1 deletion examples/src/agents/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from "fs";
import * as yaml from "js-yaml";
import { JsonSpec, JsonObject } from "langchain/tools";
import { createOpenApiAgent, OpenApiToolkit } from "langchain/agents";
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";

export const run = async () => {
let data: JsonObject;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/agents/sql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { SqlDatabase } from "langchain/sql_db";
import { createSqlAgent, SqlToolkit } from "langchain/agents";
import { DataSource } from "typeorm";
Expand Down
2 changes: 1 addition & 1 deletion examples/src/agents/streaming.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LLMChain } from "langchain";
import { LLMChain } from "langchain/chains";
import { AgentExecutor, ZeroShotAgent } from "langchain/agents";
import { CallbackManager } from "langchain/callbacks";
import { ChatOpenAI } from "langchain/chat_models/openai";
Expand Down
2 changes: 1 addition & 1 deletion examples/src/agents/vectorstore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { HNSWLib } from "langchain/vectorstores/hnswlib";
import { OpenAIEmbeddings } from "langchain/embeddings/openai";
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
Expand Down
2 changes: 1 addition & 1 deletion examples/src/agents/zapier_mrkl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { initializeAgentExecutor, ZapierToolKit } from "langchain/agents";
import { ZapierNLAWrapper } from "langchain/tools";

Expand Down
4 changes: 3 additions & 1 deletion examples/src/callbacks/console_handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { CallbackManager, ConsoleCallbackHandler } from "langchain/callbacks";
import { OpenAI, PromptTemplate, LLMChain } from "langchain";
import { LLMChain } from "langchain/chains";
import { OpenAI } from "langchain/llms/openai";
import { PromptTemplate } from "langchain/prompts";

export const run = async () => {
const callbackManager = new CallbackManager();
Expand Down
2 changes: 1 addition & 1 deletion examples/src/chat/agent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LLMChain } from "langchain";
import { LLMChain } from "langchain/chains";
import { ChatOpenAI } from "langchain/chat_models/openai";
import { ZeroShotAgent, AgentExecutor } from "langchain/agents";
import { SerpAPI } from "langchain/tools";
Expand Down
2 changes: 1 addition & 1 deletion examples/src/chat/llm_chain.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LLMChain } from "langchain";
import { LLMChain } from "langchain/chains";
import { ChatOpenAI } from "langchain/chat_models/openai";
import {
ChatPromptTemplate,
Expand Down
3 changes: 1 addition & 2 deletions examples/src/chat/overview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LLMChain } from "langchain";
import { AgentExecutor, ChatAgent } from "langchain/agents";
import { ConversationChain } from "langchain/chains";
import { ConversationChain, LLMChain } from "langchain/chains";
import { ChatOpenAI } from "langchain/chat_models/openai";
import { BufferMemory } from "langchain/memory";
import {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/customParameters/differentBaseUrl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";

export const run = async () => {
const model = new OpenAI(
Expand Down
3 changes: 2 additions & 1 deletion examples/src/prompts/comma_list_parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OpenAI, PromptTemplate } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { PromptTemplate } from "langchain/prompts";
import { CommaSeparatedListOutputParser } from "langchain/output_parsers";

export const run = async () => {
Expand Down
3 changes: 2 additions & 1 deletion examples/src/prompts/structured_parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OpenAI, PromptTemplate } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { PromptTemplate } from "langchain/prompts";
import { StructuredOutputParser } from "langchain/output_parsers";

export const run = async () => {
Expand Down
3 changes: 2 additions & 1 deletion examples/src/prompts/structured_parser_zod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { z } from "zod";
import { OpenAI, PromptTemplate } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { PromptTemplate } from "langchain/prompts";
import { StructuredOutputParser } from "langchain/output_parsers";

export const run = async () => {
Expand Down
2 changes: 1 addition & 1 deletion langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
"format": "prettier --write \"src\"",
"format:check": "prettier --check \"src\""
},
"author": "Langchain",
"author": "LangChain",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.20.12",
Expand Down
4 changes: 3 additions & 1 deletion langchain/src/chains/llm_chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export interface LLMChainInput extends ChainInputs {
*
* @example
* ```ts
* import { LLMChain, OpenAI, PromptTemplate } from "langchain";
* import { LLMChain } from "langchain/chains";
* import { OpenAI } from "langchain/llms/openai";
* import { PromptTemplate } from "langchain/prompts";
* const prompt = PromptTemplate.fromTemplate("Tell me a {adjective} joke");
* const llm = LLMChain({ llm: new OpenAI(), prompt });
* ```
Expand Down
5 changes: 5 additions & 0 deletions langchain/src/chat_models/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
/* #__PURE__ */ console.error(
"[WARN] Importing from 'langchain/chat_models' is deprecated. Import from eg. 'langchain/chat_models/openai' instead. See https://js.langchain.com/docs/getting-started/install#updating-from-0052 for upgrade instructions."
);

export { BaseChatModel, BaseChatModelParams, SimpleChatModel } from "./base.js";
export { ChatOpenAI } from "./openai.js";
export { ChatAnthropic } from "./anthropic.js";
5 changes: 5 additions & 0 deletions langchain/src/document_loaders/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
/* #__PURE__ */ console.error(
"[WARN] Importing from 'langchain/document_loaders' is deprecated. Import from eg. 'langchain/document_loaders/fs/text' or 'langchain/document_loaders/web/cheerio' instead. See https://js.langchain.com/docs/getting-started/install#updating-from-0052 for upgrade instructions."
);

export type { DocumentLoader } from "./base.js";
export { BaseDocumentLoader } from "./base.js";
export { CheerioWebBaseLoader } from "./web/cheerio.js";
Expand Down
5 changes: 5 additions & 0 deletions langchain/src/embeddings/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
/* #__PURE__ */ console.error(
"[WARN] Importing from 'langchain/embeddings' is deprecated. Import from eg. 'langchain/embeddings/openai' instead. See https://js.langchain.com/docs/getting-started/install#updating-from-0052 for upgrade instructions."
);

export { OpenAIEmbeddings } from "./openai.js";
export { CohereEmbeddings } from "./cohere.js";
export { Embeddings } from "./base.js";
Expand Down
10 changes: 7 additions & 3 deletions langchain/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
/* #__PURE__ */ console.error(
"[WARN] Importing from 'langchain' is deprecated. See https://js.langchain.com/docs/getting-started/install#updating-from-0052 for upgrade instructions."
);

export {
PromptTemplate,
BasePromptTemplate,
FewShotPromptTemplate,
} from "./prompts/index.js";

export { LLMChain } from "./chains/index.js";
export { OpenAI } from "./llms/index.js";
export { LLMChain } from "./chains/llm_chain.js";
export { OpenAI } from "./llms/openai.js";
5 changes: 5 additions & 0 deletions langchain/src/llms/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
/* #__PURE__ */ console.error(
"[WARN] Importing from 'langchain/llms' is deprecated. Import from eg. 'langchain/llms/openai' instead. See https://js.langchain.com/docs/getting-started/install#updating-from-0052 for upgrade instructions."
);

export { BaseLLM, BaseLLMParams, LLM, SerializedLLM } from "./base.js";
export { OpenAI, PromptLayerOpenAI } from "./openai.js";
export { OpenAIChat } from "./openai-chat.js";
Expand Down
5 changes: 5 additions & 0 deletions langchain/src/retrievers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
/* #__PURE__ */ console.error(
"[WARN] Importing from 'langchain/retrievers' is deprecated. Import from eg. 'langchain/retrievers/remote' instead. See https://js.langchain.com/docs/getting-started/install#updating-from-0052 for upgrade instructions."
);

export { RemoteRetriever } from "./remote/base.js";
export { ChatGPTPluginRetriever } from "./remote/chatgpt-plugin.js";
export {
Expand Down
5 changes: 5 additions & 0 deletions langchain/src/vectorstores/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
/* #__PURE__ */ console.error(
"[WARN] Importing from 'langchain/vectorstores' is deprecated. Import from eg. 'langchain/vectorstores/pinecone' instead. See https://js.langchain.com/docs/getting-started/install#updating-from-0052 for upgrade instructions."
);

export { HNSWLib } from "./hnswlib.js";
export { Chroma } from "./chroma.js";
export { PineconeStore } from "./pinecone.js";
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"precommit": "turbo run precommit",
"docs": "yarn workspace docs start"
},
"author": "Langchain",
"author": "LangChain",
"license": "MIT",
"devDependencies": {
"@tsconfig/recommended": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion test-exports-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"format": "prettier --write src",
"format:check": "prettier --check src"
},
"author": "Langchain",
"author": "LangChain",
"license": "MIT",
"dependencies": {
"d3-dsv": "2",
Expand Down
2 changes: 1 addition & 1 deletion test-exports-cjs/src/import.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
async function test() {
const { default: assert } = await import("assert");
const { OpenAI } = await import("langchain");
const { OpenAI } = await import("langchain/llms/openai");
const { LLMChain } = await import("langchain/chains");
const { ChatPromptTemplate } = await import("langchain/prompts");
const { loadPrompt } = await import("langchain/prompts/load");
Expand Down
2 changes: 1 addition & 1 deletion test-exports-cjs/src/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from "assert";
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { LLMChain } from "langchain/chains";
import { ChatPromptTemplate } from "langchain/prompts";
import { loadPrompt } from "langchain/prompts/load";
Expand Down
2 changes: 1 addition & 1 deletion test-exports-cjs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from "assert";
import { OpenAI } from "langchain";
import { OpenAI } from "langchain/llms/openai";
import { LLMChain } from "langchain/chains";
import { ChatPromptTemplate } from "langchain/prompts";
import { loadPrompt } from "langchain/prompts/load";
Expand Down
2 changes: 1 addition & 1 deletion test-exports-cjs/src/require.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require("assert");
const { OpenAI } = require("langchain");
const { OpenAI } = require("langchain/llms/openai");
const { LLMChain } = require("langchain/chains");
const { ChatPromptTemplate } = require("langchain/prompts");
const { loadPrompt } = require("langchain/prompts/load");
Expand Down
2 changes: 1 addition & 1 deletion test-exports-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"format": "prettier --write src",
"format:check": "prettier --check src"
},
"author": "Langchain",
"author": "LangChain",
"license": "MIT",
"dependencies": {
"d3-dsv": "2",
Expand Down
Loading

0 comments on commit 3f3cdd3

Please sign in to comment.