mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-07 05:52:15 +00:00
Harrison/stop importing from init (#10690)
This commit is contained in:
@@ -4,7 +4,7 @@ This is accomplished with a specific type of agent (`conversational-react-descri
|
||||
from langchain.agents import Tool
|
||||
from langchain.agents import AgentType
|
||||
from langchain.memory import ConversationBufferMemory
|
||||
from langchain import OpenAI
|
||||
from langchain.llms import OpenAI
|
||||
from langchain.utilities import SerpAPIWrapper
|
||||
from langchain.agents import initialize_agent
|
||||
```
|
||||
|
@@ -5,9 +5,9 @@
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from langchain_experimental.plan_and_execute import PlanAndExecute, load_agent_executor, load_chat_planner
|
||||
from langchain.llms import OpenAI
|
||||
from langchain import SerpAPIWrapper
|
||||
from langchain.utilities import SerpAPIWrapper
|
||||
from langchain.agents.tools import Tool
|
||||
from langchain import LLMMathChain
|
||||
from langchain.chains import LLMMathChain
|
||||
```
|
||||
|
||||
## Tools
|
||||
|
@@ -20,7 +20,7 @@ Do necessary imports, etc.
|
||||
```python
|
||||
from langchain.agents import Tool, AgentExecutor, LLMSingleActionAgent, AgentOutputParser
|
||||
from langchain.prompts import StringPromptTemplate
|
||||
from langchain import OpenAI, SerpAPIWrapper, LLMChain
|
||||
from langchain.llms import OpenAI\nfrom langchain.utilities import SerpAPIWrapper\nfrom langchain.chains import LLMChain
|
||||
from typing import List, Union
|
||||
from langchain.schema import AgentAction, AgentFinish, OutputParserException
|
||||
import re
|
||||
|
@@ -27,7 +27,8 @@ pip install openai
|
||||
```python
|
||||
from langchain.agents import Tool, AgentExecutor, LLMSingleActionAgent, AgentOutputParser
|
||||
from langchain.prompts import BaseChatPromptTemplate
|
||||
from langchain import SerpAPIWrapper, LLMChain
|
||||
from langchain.utilities import SerpAPIWrapper
|
||||
from langchain.chains.llm import LLMChain
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from typing import List, Union
|
||||
from langchain.schema import AgentAction, AgentFinish, HumanMessage
|
||||
|
@@ -1,5 +1,5 @@
|
||||
```python
|
||||
from langchain import LLMMathChain, OpenAI, SerpAPIWrapper, SQLDatabase, SQLDatabaseChain
|
||||
from langchain.chains import LLMMathChain\nfrom langchain.llms import OpenAI\nfrom langchain.utilities import SerpAPIWrapper\nfrom langchain.utilities import SQLDatabase\nfrom langchain_experimental.sql import SQLDatabaseChain
|
||||
from langchain.agents import initialize_agent, Tool
|
||||
from langchain.agents import AgentType
|
||||
```
|
||||
|
@@ -8,7 +8,7 @@ Let's take a look at it in action below, using it to summarize a long document.
|
||||
|
||||
|
||||
```python
|
||||
from langchain import OpenAI
|
||||
from langchain.llms import OpenAI
|
||||
from langchain.chains.summarize import load_summarize_chain
|
||||
|
||||
llm = OpenAI(temperature=0)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
```python
|
||||
from langchain import PromptTemplate, OpenAI, LLMChain
|
||||
from langchain.prompts import PromptTemplate\nfrom langchain.llms import OpenAI\nfrom langchain.chains import LLMChain
|
||||
|
||||
prompt_template = "What is a good name for a company that makes {product}?"
|
||||
|
||||
|
@@ -537,7 +537,7 @@ Sometimes you may not have the luxury of using OpenAI or other service-hosted la
|
||||
import logging
|
||||
import torch
|
||||
from transformers import AutoTokenizer, GPT2TokenizerFast, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM
|
||||
from langchain import HuggingFacePipeline
|
||||
from langchain.llms import HuggingFacePipeline
|
||||
|
||||
# Note: This model requires a large GPU, e.g. an 80GB A100. See documentation for other ways to run private non-OpenAI models.
|
||||
model_id = "google/flan-ul2"
|
||||
@@ -882,7 +882,7 @@ Now that you have some examples (with manually corrected output SQL), you can do
|
||||
|
||||
|
||||
```python
|
||||
from langchain import FewShotPromptTemplate, PromptTemplate
|
||||
from langchain.prompts import FewShotPromptTemplate, PromptTemplate
|
||||
from langchain.chains.sql_database.prompt import _sqlite_prompt, PROMPT_SUFFIX
|
||||
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
||||
from langchain.prompts.example_selector.semantic_similarity import SemanticSimilarityExampleSelector
|
||||
|
@@ -49,7 +49,7 @@ docsearch = Chroma.from_texts(texts, embeddings, metadatas=[{"source": f"{i}-pl"
|
||||
|
||||
```python
|
||||
from langchain.chains import RetrievalQAWithSourcesChain
|
||||
from langchain import OpenAI
|
||||
from langchain.llms import OpenAI
|
||||
|
||||
chain = RetrievalQAWithSourcesChain.from_chain_type(OpenAI(temperature=0), chain_type="stuff", retriever=docsearch.as_retriever())
|
||||
```
|
||||
|
@@ -4,7 +4,7 @@ For convenience, there is a `from_template` method defined on the template. If y
|
||||
|
||||
|
||||
```python
|
||||
from langchain import PromptTemplate
|
||||
from langchain.prompts import PromptTemplate
|
||||
from langchain.prompts.chat import (
|
||||
ChatPromptTemplate,
|
||||
SystemMessagePromptTemplate,
|
||||
|
@@ -8,7 +8,7 @@ By default, `PromptTemplate` uses [Python's str.format](https://docs.python.org/
|
||||
syntax for templating; however other templating syntax is available (e.g., `jinja2`).
|
||||
|
||||
```python
|
||||
from langchain import PromptTemplate
|
||||
from langchain.prompts import PromptTemplate
|
||||
|
||||
prompt_template = PromptTemplate.from_template(
|
||||
"Tell me a {adjective} joke about {content}."
|
||||
@@ -27,7 +27,7 @@ prompt_template.format(adjective="funny", content="chickens")
|
||||
The template supports any number of variables, including no variables:
|
||||
|
||||
```python
|
||||
from langchain import PromptTemplate
|
||||
from langchain.prompts import PromptTemplate
|
||||
|
||||
prompt_template = PromptTemplate.from_template(
|
||||
"Tell me a joke"
|
||||
@@ -40,7 +40,7 @@ will be compared against the variables present in the template string during ins
|
||||
there is a mismatch; for example,
|
||||
|
||||
```python
|
||||
from langchain import PromptTemplate
|
||||
from langchain.prompts import PromptTemplate
|
||||
|
||||
invalid_prompt = PromptTemplate(
|
||||
input_variables=["adjective"],
|
||||
|
Reference in New Issue
Block a user