The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
cleanup (#1274)
Harrison Chase96db6ed073be
diff --git a/docs/modules/document_loaders/examples/notebook.ipynb b/docs/modules/document_loaders/examples/notebook.ipynbindex db1a4fdce5..07cb4ef616 100644--- a/docs/modules/document_loaders/examples/notebook.ipynb+++ b/docs/modules/document_loaders/examples/notebook.ipynb@@ -1,7 +1,6 @@{"cells": [{- "attachments": {},"cell_type": "markdown","metadata": {},"source": [@@ -12,7 +11,7 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 1,"metadata": {},"outputs": [],"source": [@@ -21,15 +20,14 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 4,"metadata": {},"outputs": [],"source": [- "loader = NotebookLoader(\"example_data/notebook.ipynb\")"+ "loader = NotebookLoader(\"example_data/notebook.ipynb\", include_outputs=True, max_output_length=20, remove_newline=True)"]},{- "attachments": {},"cell_type": "markdown","metadata": {},"source": [@@ -45,17 +43,35 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 5,"metadata": {},- "outputs": [],+ "outputs": [+ {+ "data": {+ "text/plain": [+ "[Document(page_content='\\'markdown\\' cell: \\'[\\'# Notebook\\', \\'\\', \\'This notebook covers how to load data from an .ipynb notebook into a format suitable by LangChain.\\']\\'\\n\\n \\'code\\' cell: \\'[\\'from langchain.document_loaders import NotebookLoader\\']\\'\\n\\n \\'code\\' cell: \\'[\\'loader = NotebookLoader(\"example_data/notebook.ipynb\")\\']\\'\\n\\n \\'markdown\\' cell: \\'[\\'`NotebookLoader.load()` loads the `.ipynb` notebook file into a `Document` object.\\', \\'\\', \\'**Parameters**:\\', \\'\\', \\'* `include_outputs` (bool): whether to include cell outputs in the resulting document (default is False).\\', \\'* `max_output_length` (int): the maximum number of characters to include from each cell output (default is 10).\\', \\'* `remove_newline` (bool): whether to remove newline characters from the cell sources and outputs (default is False).\\', \\'* `traceback` (bool): whether to include full traceback (default is False).\\']\\'\\n\\n \\'code\\' cell: \\'[\\'loader.load(include_outputs=True, max_output_length=20, remove_newline=True)\\']\\'\\n\\n', lookup_str='', metadata={'source': 'example_data/notebook.ipynb'}, lookup_index=0)]"+ ]+ },+ "execution_count": 5,+ "metadata": {},+ "output_type": "execute_result"+ }+ ],"source": [- "loader.load(include_outputs=True, max_output_length=20, remove_newline=True)"+ "loader.load()"]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": []}],"metadata": {"kernelspec": {- "display_name": "Python 3",+ "display_name": "Python 3 (ipykernel)","language": "python","name": "python3"},@@ -69,9 +85,8 @@"name": "python","nbconvert_exporter": "python","pygments_lexer": "ipython3",- "version": "3.11.1"+ "version": "3.9.1"},- "orig_nbformat": 4,"vscode": {"interpreter": {"hash": "981b6680a42bdb5eb22187741e1607b3aae2cf73db800d1af1f268d1de6a1f70"diff --git a/langchain/document_loaders/notebook.py b/langchain/document_loaders/notebook.pyindex 53ca5a72c4..5db545ffc8 100644--- a/langchain/document_loaders/notebook.py+++ b/langchain/document_loaders/notebook.py@@ -61,16 +61,23 @@ def remove_newlines(x: Any) -> Any:class NotebookLoader(BaseLoader):"""Loader that loads .ipynb notebook files."""- def __init__(self, path: str):- """Initialize with path."""- self.file_path = path-- def load(+ def __init__(self,+ path: str,include_outputs: bool = False,max_output_length: int = 10,remove_newline: bool = False,traceback: bool = False,+ ):+ """Initialize with path."""+ self.file_path = path+ self.include_outputs = include_outputs+ self.max_output_length = max_output_length+ self.remove_newline = remove_newline+ self.traceback = traceback++ def load(+ self,) -> List[Document]:"""Load documents."""try:@@ -87,12 +94,12 @@ class NotebookLoader(BaseLoader):data = pd.json_normalize(d["cells"])filtered_data = data[["cell_type", "source", "outputs"]]- if remove_newline:+ if self.remove_newline:filtered_data = filtered_data.applymap(remove_newlines)text = filtered_data.apply(lambda x: concatenate_cells(- x, include_outputs, max_output_length, traceback+ x, self.include_outputs, self.max_output_length, self.traceback),axis=1,).str.cat(sep=" ")diff --git a/langchain/llms/anthropic.py b/langchain/llms/anthropic.pyindex f2e1df4d5d..a5c57a94c6 100644--- a/langchain/llms/anthropic.py+++ b/langchain/llms/anthropic.py@@ -18,7 +18,7 @@ class Anthropic(LLM, BaseModel):Example:.. code-block:: pythonimport anthropic- from langchain import Anthropic+ from langchain.llms import Anthropicmodel = Anthropic(model="<model_name>", anthropic_api_key="my-api-key")# Simplest invocation, automatically wrapped with HUMAN_PROMPTdiff --git a/langchain/llms/bananadev.py b/langchain/llms/bananadev.pyindex 9444044112..03d336c28d 100644--- a/langchain/llms/bananadev.py+++ b/langchain/llms/bananadev.py@@ -22,8 +22,8 @@ class Banana(LLM, BaseModel):Example:.. code-block:: python- from langchain import Banana- cerebrium = Banana(model_key="")+ from langchain.llms import Banana+ banana = Banana(model_key="")"""model_key: str = ""diff --git a/langchain/llms/cerebriumai.py b/langchain/llms/cerebriumai.pyindex ca219be1b7..29f0d2fc21 100644--- a/langchain/llms/cerebriumai.py+++ b/langchain/llms/cerebriumai.py@@ -22,7 +22,7 @@ class CerebriumAI(LLM, BaseModel):Example:.. code-block:: python- from langchain import CerebriumAI+ from langchain.llms import CerebriumAIcerebrium = CerebriumAI(endpoint_url="")"""diff --git a/langchain/llms/cohere.py b/langchain/llms/cohere.pyindex de246e22ef..66bff40eb8 100644--- a/langchain/llms/cohere.py+++ b/langchain/llms/cohere.py@@ -21,7 +21,7 @@ class Cohere(LLM, BaseModel):Example:.. code-block:: python- from langchain import Cohere+ from langchain.llms import Coherecohere = Cohere(model="gptd-instruct-tft", cohere_api_key="my-api-key")"""diff --git a/langchain/llms/deepinfra.py b/langchain/llms/deepinfra.pyindex c1dce50fd3..8993a4bf3b 100644--- a/langchain/llms/deepinfra.py+++ b/langchain/llms/deepinfra.py@@ -23,7 +23,7 @@ class DeepInfra(LLM, BaseModel):Example:.. code-block:: python- from langchain import DeepInfra+ from langchain.llms import DeepInfradi = DeepInfra(model_id="google/flan-t5-xl",deepinfra_api_token="my-api-key")"""diff --git a/langchain/llms/forefrontai.py b/langchain/llms/forefrontai.pyindex f76003b6fc..806bcd8545 100644--- a/langchain/llms/forefrontai.py+++ b/langchain/llms/forefrontai.py@@ -18,7 +18,7 @@ class ForefrontAI(LLM, BaseModel):Example:.. code-block:: python- from langchain import ForefrontAI+ from langchain.llms import ForefrontAIforefrontai = ForefrontAI(endpoint_url="")"""diff --git a/langchain/llms/gooseai.py b/langchain/llms/gooseai.pyindex 891d511f5e..89f17f18d3 100644--- a/langchain/llms/gooseai.py+++ b/langchain/llms/gooseai.py@@ -21,7 +21,7 @@ class GooseAI(LLM, BaseModel):Example:.. code-block:: python- from langchain import GooseAI+ from langchain.llms import GooseAIgooseai = GooseAI(model_name="gpt-neo-20b")"""diff --git a/langchain/llms/huggingface_hub.py b/langchain/llms/huggingface_hub.pyindex ef53275ddd..b9c4098879 100644--- a/langchain/llms/huggingface_hub.py+++ b/langchain/llms/huggingface_hub.py@@ -23,7 +23,7 @@ class HuggingFaceHub(LLM, BaseModel):Example:.. code-block:: python- from langchain import HuggingFaceHub+ from langchain.llms import HuggingFaceHubhf = HuggingFaceHub(repo_id="gpt2", huggingfacehub_api_token="my-api-key")"""diff --git a/langchain/llms/huggingface_pipeline.py b/langchain/llms/huggingface_pipeline.pyindex ee5678c6fc..1138839cf6 100644--- a/langchain/llms/huggingface_pipeline.py+++ b/langchain/llms/huggingface_pipeline.py@@ -25,14 +25,14 @@ class HuggingFacePipeline(LLM, BaseModel):Example using from_model_id:.. code-block:: python- from langchain.llms.huggingface_pipeline import HuggingFacePipeline+ from langchain.llms import HuggingFacePipelinehf = HuggingFacePipeline.from_model_id(model_id="gpt2", task="text-generation")Example passing pipeline in directly:.. code-block:: python- from langchain.llms.huggingface_pipeline import HuggingFacePipeline+ from langchain.llms import HuggingFacePipelinefrom transformers import AutoModelForCausalLM, AutoTokenizer, pipelinemodel_id = "gpt2"diff --git a/langchain/llms/modal.py b/langchain/llms/modal.pyindex b1bd513281..5037858a31 100644--- a/langchain/llms/modal.py+++ b/langchain/llms/modal.py@@ -21,7 +21,7 @@ class Modal(LLM, BaseModel):Example:.. code-block:: python- from langchain import Modal+ from langchain.llms import Modalmodal = Modal(endpoint_url="")"""diff --git a/langchain/llms/nlpcloud.py b/langchain/llms/nlpcloud.pyindex 94f0df7de0..2c04c41960 100644--- a/langchain/llms/nlpcloud.py+++ b/langchain/llms/nlpcloud.py@@ -16,7 +16,7 @@ class NLPCloud(LLM, BaseModel):Example:.. code-block:: python- from langchain import NLPCloud+ from langchain.llms import NLPCloudnlpcloud = NLPCloud(model="gpt-neox-20b")"""diff --git a/langchain/llms/openai.py b/langchain/llms/openai.pyindex 4f2b37bde0..728d50873a 100644--- a/langchain/llms/openai.py+++ b/langchain/llms/openai.py@@ -75,7 +75,7 @@ class BaseOpenAI(BaseLLM, BaseModel):Example:.. code-block:: python- from langchain import OpenAI+ from langchain.llms import OpenAIopenai = OpenAI(model_name="text-davinci-003")"""diff --git a/langchain/llms/petals.py b/langchain/llms/petals.pyindex 535d5d1b1d..bffe59ba81 100644--- a/langchain/llms/petals.py+++ b/langchain/llms/petals.py@@ -22,7 +22,7 @@ class Petals(LLM, BaseModel):Example:.. code-block:: python- from langchain import petals+ from langchain.llms import petalspetals = Petals()"""diff --git a/langchain/llms/promptlayer_openai.py b/langchain/llms/promptlayer_openai.pyindex 23cba853df..2704218e4e 100644--- a/langchain/llms/promptlayer_openai.py+++ b/langchain/llms/promptlayer_openai.py@@ -23,7 +23,7 @@ class PromptLayerOpenAI(OpenAI, BaseModel):Example:.. code-block:: python- from langchain import OpenAI+ from langchain.llms import OpenAIopenai = OpenAI(model_name="text-davinci-003")"""diff --git a/langchain/llms/stochasticai.py b/langchain/llms/stochasticai.pyindex 6f2d8b75d4..21c32b2167 100644--- a/langchain/llms/stochasticai.py+++ b/langchain/llms/stochasticai.py@@ -22,8 +22,8 @@ class StochasticAI(LLM, BaseModel):Example:.. code-block:: python- from langchain import StochasticAI- forefrontai = StochasticAI(api_url="")+ from langchain.llms import StochasticAI+ stochasticai = StochasticAI(api_url="")"""api_url: str = ""