diff --git a/docs/modules/agents/agent_executors/examples/sharedmemory_for_tools.ipynb b/docs/modules/agents/agent_executors/examples/sharedmemory_for_tools.ipynb index 62d75c655..c6326728a 100644 --- a/docs/modules/agents/agent_executors/examples/sharedmemory_for_tools.ipynb +++ b/docs/modules/agents/agent_executors/examples/sharedmemory_for_tools.ipynb @@ -9,8 +9,8 @@ "\n", "This notebook goes over adding memory to **both** of an Agent and its tools. Before going through this notebook, please walk through the following notebooks, as this will build on top of both of them:\n", "\n", - "- [Adding memory to an LLM Chain](../../memory/examples/adding_memory.ipynb)\n", - "- [Custom Agents](custom_agent.ipynb)\n", + "- [Adding memory to an LLM Chain](../../../memory/examples/adding_memory.ipynb)\n", + "- [Custom Agents](../../agents/custom_agent.ipynb)\n", "\n", "We are going to create a custom Agent. The agent has access to a conversation memory, search tool, and a summarization tool. And, the summarization tool also needs access to the conversation memory." ] diff --git a/docs/modules/agents/how_to_guides.rst b/docs/modules/agents/how_to_guides.rst index e7af4b8f4..9725a9c78 100644 --- a/docs/modules/agents/how_to_guides.rst +++ b/docs/modules/agents/how_to_guides.rst @@ -36,7 +36,7 @@ The first category of how-to guides here cover specific parts of working with ag :glob: :hidden: - ./examples/* + ./agents/examples/* Agent Toolkits @@ -46,26 +46,26 @@ The next set of examples covers agents with toolkits. As opposed to the examples above, these examples are not intended to show off an agent `type`, but rather to show off an agent applied to particular use case. -`SQLDatabase Agent <./agent_toolkits/sql_database.html>`_: This notebook covers how to interact with an arbitrary SQL database using an agent. +`SQLDatabase Agent <./toolkits/sql_database.html>`_: This notebook covers how to interact with an arbitrary SQL database using an agent. -`JSON Agent <./agent_toolkits/json.html>`_: This notebook covers how to interact with a JSON dictionary using an agent. +`JSON Agent <./toolkits/json.html>`_: This notebook covers how to interact with a JSON dictionary using an agent. -`OpenAPI Agent <./agent_toolkits/openapi.html>`_: This notebook covers how to interact with an arbitrary OpenAPI endpoint using an agent. +`OpenAPI Agent <./toolkits/openapi.html>`_: This notebook covers how to interact with an arbitrary OpenAPI endpoint using an agent. -`VectorStore Agent <./agent_toolkits/vectorstore.html>`_: This notebook covers how to interact with VectorStores using an agent. +`VectorStore Agent <./toolkits/vectorstore.html>`_: This notebook covers how to interact with VectorStores using an agent. -`Python Agent <./agent_toolkits/python.html>`_: This notebook covers how to produce and execute python code using an agent. +`Python Agent <./toolkits/python.html>`_: This notebook covers how to produce and execute python code using an agent. -`Pandas DataFrame Agent <./agent_toolkits/pandas.html>`_: This notebook covers how to do question answering over a pandas dataframe using an agent. Under the hood this calls the Python agent.. +`Pandas DataFrame Agent <./toolkits/pandas.html>`_: This notebook covers how to do question answering over a pandas dataframe using an agent. Under the hood this calls the Python agent.. -`CSV Agent <./agent_toolkits/csv.html>`_: This notebook covers how to do question answering over a csv file. Under the hood this calls the Pandas DataFrame agent. +`CSV Agent <./toolkits/csv.html>`_: This notebook covers how to do question answering over a csv file. Under the hood this calls the Pandas DataFrame agent. .. toctree:: :maxdepth: 1 :glob: :hidden: - ./agent_toolkits/* + ./toolkits/* Agent Types diff --git a/docs/modules/chains/generic/async_chain.ipynb b/docs/modules/chains/generic/async_chain.ipynb index 6a99a115a..29d7dcf9b 100644 --- a/docs/modules/chains/generic/async_chain.ipynb +++ b/docs/modules/chains/generic/async_chain.ipynb @@ -9,7 +9,7 @@ "\n", "LangChain provides async support for Chains by leveraging the [asyncio](https://docs.python.org/3/library/asyncio.html) library.\n", "\n", - "Async methods are currently supported in `LLMChain` (through `arun`, `apredict`, `acall`) and `LLMMathChain` (through `arun` and `acall`), `ChatVectorDBChain`, and [QA chains](../indexes/chain_examples/question_answering.html). Async support for other chains is on the roadmap." + "Async methods are currently supported in `LLMChain` (through `arun`, `apredict`, `acall`) and `LLMMathChain` (through `arun` and `acall`), `ChatVectorDBChain`, and [QA chains](../index_examples/question_answering.ipynb). Async support for other chains is on the roadmap." ] }, { @@ -104,7 +104,7 @@ "s = time.perf_counter()\n", "generate_serially()\n", "elapsed = time.perf_counter() - s\n", - "print('\\033[1m' + f\"Serial executed in {elapsed:0.2f} seconds.\" + '\\033[0m')" + "print('\\033[1m' + f\"Serial executed in {elapsed:0.2f} seconds.\" + '\\033[0m')\n" ] } ], diff --git a/docs/modules/indexes/document_loaders.rst b/docs/modules/indexes/document_loaders.rst index 6ac4d9517..ea2ba661e 100644 --- a/docs/modules/indexes/document_loaders.rst +++ b/docs/modules/indexes/document_loaders.rst @@ -88,7 +88,7 @@ We don't need any access permissions to these datasets and services. Proprietary dataset or service loaders ------------------------------- +-------------------------------------- These datasets and services are not from the public domain. These loaders mostly transform data from specific formats of applications or cloud services, for example **Google Drive**. diff --git a/docs/modules/indexes/document_loaders/examples/docugami.ipynb b/docs/modules/indexes/document_loaders/examples/docugami.ipynb index 0191d7af5..9af69e655 100644 --- a/docs/modules/indexes/document_loaders/examples/docugami.ipynb +++ b/docs/modules/indexes/document_loaders/examples/docugami.ipynb @@ -137,7 +137,7 @@ "metadata": {}, "outputs": [], "source": [ - "!poetry run pip -q install openai tiktoken chromadb " + "!poetry run pip -q install openai tiktoken chromadb" ] }, { @@ -317,7 +317,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We can use a [self-querying retriever](../../retrievers/examples/self_query_retriever.ipynb) to improve our query accuracy, using this additional metadata:" + "We can use a [self-querying retriever](../../retrievers/examples/self_query.ipynb) to improve our query accuracy, using this additional metadata:" ] }, { diff --git a/docs/modules/memory/examples/agent_with_memory.ipynb b/docs/modules/memory/examples/agent_with_memory.ipynb index 4f0010a85..c2b7a57ab 100644 --- a/docs/modules/memory/examples/agent_with_memory.ipynb +++ b/docs/modules/memory/examples/agent_with_memory.ipynb @@ -10,7 +10,7 @@ "This notebook goes over adding memory to an Agent. Before going through this notebook, please walkthrough the following notebooks, as this will build on top of both of them:\n", "\n", "- [Adding memory to an LLM Chain](adding_memory.ipynb)\n", - "- [Custom Agents](../../agents/examples/custom_agent.ipynb)\n", + "- [Custom Agents](../../agents/agents/custom_agent.ipynb)\n", "\n", "In order to add a memory to an agent we are going to the the following steps:\n", "\n", diff --git a/docs/modules/memory/examples/agent_with_memory_in_db.ipynb b/docs/modules/memory/examples/agent_with_memory_in_db.ipynb index b96760bbb..cf692824e 100644 --- a/docs/modules/memory/examples/agent_with_memory_in_db.ipynb +++ b/docs/modules/memory/examples/agent_with_memory_in_db.ipynb @@ -10,8 +10,8 @@ "This notebook goes over adding memory to an Agent where the memory uses an external message store. Before going through this notebook, please walkthrough the following notebooks, as this will build on top of both of them:\n", "\n", "- [Adding memory to an LLM Chain](adding_memory.ipynb)\n", - "- [Custom Agents](../../agents/examples/custom_agent.ipynb)\n", - "- [Agent with Memory](agetn_with_memory.ipynb)\n", + "- [Custom Agents](../../agents/agents/custom_agent.ipynb)\n", + "- [Agent with Memory](agent_with_memory.ipynb)\n", "\n", "In order to add a memory with an external message store to an agent we are going to do the following steps:\n", "\n", diff --git a/docs/reference/modules/experimental.rst b/docs/reference/modules/experimental.rst index 22c124b92..e97b4ca56 100644 --- a/docs/reference/modules/experimental.rst +++ b/docs/reference/modules/experimental.rst @@ -1,6 +1,6 @@ -========== +==================== Experimental Modules -========== +==================== This module contains experimental modules and reproductions of existing work using LangChain primitives. diff --git a/langchain/chat_models/anthropic.py b/langchain/chat_models/anthropic.py index 3ac59507c..e913f6c44 100644 --- a/langchain/chat_models/anthropic.py +++ b/langchain/chat_models/anthropic.py @@ -28,6 +28,7 @@ class ChatAnthropic(BaseChatModel, _AnthropicCommon): Example: .. code-block:: python + import anthropic from langchain.llms import Anthropic model = ChatAnthropic(model="", anthropic_api_key="my-api-key") diff --git a/langchain/chat_models/azure_openai.py b/langchain/chat_models/azure_openai.py index 102060493..8b370251f 100644 --- a/langchain/chat_models/azure_openai.py +++ b/langchain/chat_models/azure_openai.py @@ -30,6 +30,7 @@ class AzureChatOpenAI(ChatOpenAI): `35-turbo-dev`, the constructor should look like: .. code-block:: python + AzureChatOpenAI( deployment_name="35-turbo-dev", openai_api_version="2023-03-15-preview", diff --git a/langchain/chat_models/promptlayer_openai.py b/langchain/chat_models/promptlayer_openai.py index 596959946..65865c1dc 100644 --- a/langchain/chat_models/promptlayer_openai.py +++ b/langchain/chat_models/promptlayer_openai.py @@ -20,6 +20,7 @@ class PromptLayerChatOpenAI(ChatOpenAI): All parameters that can be passed to the OpenAI LLM can also be passed here. The PromptLayerChatOpenAI adds to optional + parameters: ``pl_tags``: List of strings to tag the request with. ``return_pl_id``: If True, the PromptLayer request ID will be diff --git a/langchain/embeddings/aleph_alpha.py b/langchain/embeddings/aleph_alpha.py index f6ca5008e..e5e9664ee 100644 --- a/langchain/embeddings/aleph_alpha.py +++ b/langchain/embeddings/aleph_alpha.py @@ -149,6 +149,7 @@ class AlephAlphaSymmetricSemanticEmbedding(AlephAlphaAsymmetricSemanticEmbedding queries are embedded with a SemanticRepresentation.Symmetric Example: .. code-block:: python + from aleph_alpha import AlephAlphaSymmetricSemanticEmbedding embeddings = AlephAlphaAsymmetricSemanticEmbedding() diff --git a/langchain/embeddings/elasticsearch.py b/langchain/embeddings/elasticsearch.py index 9d3b11923..7574a39b1 100644 --- a/langchain/embeddings/elasticsearch.py +++ b/langchain/embeddings/elasticsearch.py @@ -66,30 +66,32 @@ class ElasticsearchEmbeddings(Embeddings): es_user: (str, optional): Elasticsearch username. es_password: (str, optional): Elasticsearch password. - Example Usage: - from langchain.embeddings import ElasticsearchEmbeddings + Example: + .. code-block:: python - # Define the model ID and input field name (if different from default) - model_id = "your_model_id" - # Optional, only if different from 'text_field' - input_field = "your_input_field" + from langchain.embeddings import ElasticsearchEmbeddings - # Credentials can be passed in two ways. Either set the env vars - # ES_CLOUD_ID, ES_USER, ES_PASSWORD and they will be automatically pulled - # in, or pass them in directly as kwargs. - embeddings = ElasticsearchEmbeddings.from_credentials( - model_id, - input_field=input_field, - # es_cloud_id="foo", - # es_user="bar", - # es_password="baz", - ) + # Define the model ID and input field name (if different from default) + model_id = "your_model_id" + # Optional, only if different from 'text_field' + input_field = "your_input_field" - documents = [ - "This is an example document.", - "Another example document to generate embeddings for.", - ] - embeddings_generator.embed_documents(documents) + # Credentials can be passed in two ways. Either set the env vars + # ES_CLOUD_ID, ES_USER, ES_PASSWORD and they will be automatically + # pulled in, or pass them in directly as kwargs. + embeddings = ElasticsearchEmbeddings.from_credentials( + model_id, + input_field=input_field, + # es_cloud_id="foo", + # es_user="bar", + # es_password="baz", + ) + + documents = [ + "This is an example document.", + "Another example document to generate embeddings for.", + ] + embeddings_generator.embed_documents(documents) """ try: from elasticsearch import Elasticsearch @@ -135,32 +137,35 @@ class ElasticsearchEmbeddings(Embeddings): Returns: ElasticsearchEmbeddings: An instance of the ElasticsearchEmbeddings class. - Example Usage: - from elasticsearch import Elasticsearch - from langchain.embeddings import ElasticsearchEmbeddings + Example: + .. code-block:: python - # Define the model ID and input field name (if different from default) - model_id = "your_model_id" - # Optional, only if different from 'text_field' - input_field = "your_input_field" + from elasticsearch import Elasticsearch - # Create Elasticsearch connection - es_connection = Elasticsearch( - hosts=["localhost:9200"], http_auth=("user", "password") - ) + from langchain.embeddings import ElasticsearchEmbeddings - # Instantiate ElasticsearchEmbeddings using the existing connection - embeddings = ElasticsearchEmbeddings.from_es_connection( - model_id, - es_connection, - input_field=input_field, - ) + # Define the model ID and input field name (if different from default) + model_id = "your_model_id" + # Optional, only if different from 'text_field' + input_field = "your_input_field" - documents = [ - "This is an example document.", - "Another example document to generate embeddings for.", - ] - embeddings_generator.embed_documents(documents) + # Create Elasticsearch connection + es_connection = Elasticsearch( + hosts=["localhost:9200"], http_auth=("user", "password") + ) + + # Instantiate ElasticsearchEmbeddings using the existing connection + embeddings = ElasticsearchEmbeddings.from_es_connection( + model_id, + es_connection, + input_field=input_field, + ) + + documents = [ + "This is an example document.", + "Another example document to generate embeddings for.", + ] + embeddings_generator.embed_documents(documents) """ # Importing MlClient from elasticsearch.client within the method to # avoid unnecessary import if the method is not used diff --git a/langchain/llms/anthropic.py b/langchain/llms/anthropic.py index a6cf9ce93..e9da0ae6b 100644 --- a/langchain/llms/anthropic.py +++ b/langchain/llms/anthropic.py @@ -107,6 +107,7 @@ class Anthropic(LLM, _AnthropicCommon): Example: .. code-block:: python + import anthropic from langchain.llms import Anthropic model = Anthropic(model="", anthropic_api_key="my-api-key") diff --git a/langchain/llms/anyscale.py b/langchain/llms/anyscale.py index 972957d7c..0128b6515 100644 --- a/langchain/llms/anyscale.py +++ b/langchain/llms/anyscale.py @@ -18,6 +18,7 @@ class Anyscale(LLM): Example: .. code-block:: python + from langchain.llms import Anyscale anyscale = Anyscale(anyscale_service_url="SERVICE_URL", anyscale_service_route="SERVICE_ROUTE", diff --git a/langchain/llms/bananadev.py b/langchain/llms/bananadev.py index 353c9dca9..d0d604539 100644 --- a/langchain/llms/bananadev.py +++ b/langchain/llms/bananadev.py @@ -23,6 +23,7 @@ class Banana(LLM): Example: .. code-block:: python + from langchain.llms import Banana banana = Banana(model_key="") """ diff --git a/langchain/llms/beam.py b/langchain/llms/beam.py index fd58309b8..d7d3f27ca 100644 --- a/langchain/llms/beam.py +++ b/langchain/llms/beam.py @@ -31,24 +31,28 @@ class Beam(LLM): The wrapper can then be called as follows, where the name, cpu, memory, gpu, python version, and python packages can be updated accordingly. Once deployed, the instance can be called. - llm = Beam(model_name="gpt2", - name="langchain-gpt2", - cpu=8, - memory="32Gi", - gpu="A10G", - python_version="python3.8", - python_packages=[ - "diffusers[torch]>=0.10", - "transformers", - "torch", - "pillow", - "accelerate", - "safetensors", - "xformers",], - max_length=50) - llm._deploy() - call_result = llm._call(input) + Example: + .. code-block:: python + + llm = Beam(model_name="gpt2", + name="langchain-gpt2", + cpu=8, + memory="32Gi", + gpu="A10G", + python_version="python3.8", + python_packages=[ + "diffusers[torch]>=0.10", + "transformers", + "torch", + "pillow", + "accelerate", + "safetensors", + "xformers",], + max_length=50) + llm._deploy() + call_result = llm._call(input) + """ model_name: str = "" diff --git a/langchain/llms/cerebriumai.py b/langchain/llms/cerebriumai.py index 3da3dfbc7..dac1f48a1 100644 --- a/langchain/llms/cerebriumai.py +++ b/langchain/llms/cerebriumai.py @@ -23,6 +23,7 @@ class CerebriumAI(LLM): Example: .. code-block:: python + from langchain.llms import CerebriumAI cerebrium = CerebriumAI(endpoint_url="") diff --git a/langchain/llms/gooseai.py b/langchain/llms/gooseai.py index e1a3f8db2..0271d039e 100644 --- a/langchain/llms/gooseai.py +++ b/langchain/llms/gooseai.py @@ -22,6 +22,7 @@ class GooseAI(LLM): Example: .. code-block:: python + from langchain.llms import GooseAI gooseai = GooseAI(model_name="gpt-neo-20b") diff --git a/langchain/llms/llamacpp.py b/langchain/llms/llamacpp.py index 8be51aa38..ff10f4180 100644 --- a/langchain/llms/llamacpp.py +++ b/langchain/llms/llamacpp.py @@ -172,7 +172,7 @@ class LlamaCpp(LLM): def _get_parameters(self, stop: Optional[List[str]] = None) -> Dict[str, Any]: """ - Performs sanity check, preparing paramaters in format needed by llama_cpp. + Performs sanity check, preparing parameters in format needed by llama_cpp. Args: stop (Optional[List[str]]): List of stop sequences for llama_cpp. @@ -238,7 +238,7 @@ class LlamaCpp(LLM): ) -> Generator[Dict, None, None]: """Yields results objects as they are generated in real time. - BETA: this is a beta feature while we figure out the right abstraction: + BETA: this is a beta feature while we figure out the right abstraction. Once that happens, this interface could change. It also calls the callback manager's on_llm_new_token event with diff --git a/langchain/llms/modal.py b/langchain/llms/modal.py index 53f112f70..338a6b42f 100644 --- a/langchain/llms/modal.py +++ b/langchain/llms/modal.py @@ -22,6 +22,7 @@ class Modal(LLM): Example: .. code-block:: python + from langchain.llms import Modal modal = Modal(endpoint_url="") diff --git a/langchain/llms/petals.py b/langchain/llms/petals.py index 293d240ce..f407bcf28 100644 --- a/langchain/llms/petals.py +++ b/langchain/llms/petals.py @@ -23,6 +23,7 @@ class Petals(LLM): Example: .. code-block:: python + from langchain.llms import petals petals = Petals() diff --git a/langchain/llms/pipelineai.py b/langchain/llms/pipelineai.py index 3a29d64ec..677504056 100644 --- a/langchain/llms/pipelineai.py +++ b/langchain/llms/pipelineai.py @@ -23,6 +23,7 @@ class PipelineAI(LLM, BaseModel): Example: .. code-block:: python + from langchain import PipelineAI pipeline = PipelineAI(pipeline_key="") """ diff --git a/langchain/llms/predictionguard.py b/langchain/llms/predictionguard.py index 003e284cf..ee2a9d4b7 100644 --- a/langchain/llms/predictionguard.py +++ b/langchain/llms/predictionguard.py @@ -19,8 +19,10 @@ class PredictionGuard(LLM): it as a named parameter to the constructor. To use Prediction Guard's API along with OpenAI models, set the environment variable ``OPENAI_API_KEY`` with your OpenAI API key as well. + Example: .. code-block:: python + pgllm = PredictionGuard(model="MPT-7B-Instruct", token="my-access-token", output={ diff --git a/langchain/llms/promptlayer_openai.py b/langchain/llms/promptlayer_openai.py index 77df80517..6454ed804 100644 --- a/langchain/llms/promptlayer_openai.py +++ b/langchain/llms/promptlayer_openai.py @@ -20,6 +20,7 @@ class PromptLayerOpenAI(OpenAI): All parameters that can be passed to the OpenAI LLM can also be passed here. The PromptLayerOpenAI LLM adds two optional + parameters: ``pl_tags``: List of strings to tag the request with. ``return_pl_id``: If True, the PromptLayer request ID will be @@ -124,6 +125,7 @@ class PromptLayerOpenAIChat(OpenAIChat): All parameters that can be passed to the OpenAIChat LLM can also be passed here. The PromptLayerOpenAIChat adds two optional + parameters: ``pl_tags``: List of strings to tag the request with. ``return_pl_id``: If True, the PromptLayer request ID will be diff --git a/langchain/llms/replicate.py b/langchain/llms/replicate.py index 117d8dde4..10c727bdd 100644 --- a/langchain/llms/replicate.py +++ b/langchain/llms/replicate.py @@ -23,6 +23,7 @@ class Replicate(LLM): Example: .. code-block:: python + from langchain.llms import Replicate replicate = Replicate(model="stability-ai/stable-diffusion: \ 27b93a2413e7f36cd83da926f365628\ diff --git a/langchain/memory/chat_message_histories/cassandra.py b/langchain/memory/chat_message_histories/cassandra.py index 0b468dca1..7f50bf3d7 100644 --- a/langchain/memory/chat_message_histories/cassandra.py +++ b/langchain/memory/chat_message_histories/cassandra.py @@ -20,6 +20,7 @@ DEFAULT_PORT = 9042 class CassandraChatMessageHistory(BaseChatMessageHistory): """Chat message history that stores history in Cassandra. + Args: contact_points: list of ips to connect to Cassandra cluster session_id: arbitrary key that is used to store the messages diff --git a/langchain/tools/zapier/tool.py b/langchain/tools/zapier/tool.py index cb1fc2954..9709f5bb4 100644 --- a/langchain/tools/zapier/tool.py +++ b/langchain/tools/zapier/tool.py @@ -27,7 +27,7 @@ This quick start will focus on the server-side use case for brevity. Review [full docs](https://nla.zapier.com/api/v1/docs) or reach out to nla@zapier.com for user-facing oauth developer support. -Typically you'd use SequentialChain, here's a basic example: +Typically, you'd use SequentialChain, here's a basic example: 1. Use NLA to find an email in Gmail 2. Use LLMChain to generate a draft reply to (1) @@ -100,6 +100,7 @@ class ZapierNLARunAction(BaseTool): params: a dict, optional. Any params provided will *override* AI guesses from `instructions` (see "understanding the AI guessing flow" here: https://nla.zapier.com/api/v1/docs) + """ api_wrapper: ZapierNLAWrapper = Field(default_factory=ZapierNLAWrapper) @@ -160,6 +161,7 @@ class ZapierNLAListActions(BaseTool): """ Args: None + """ name = "Zapier NLA: List Actions" diff --git a/langchain/utilities/arxiv.py b/langchain/utilities/arxiv.py index e9e96bc89..ce0c3f9a0 100644 --- a/langchain/utilities/arxiv.py +++ b/langchain/utilities/arxiv.py @@ -29,6 +29,7 @@ class ArxivAPIWrapper(BaseModel): if True: the `metadata` of the loaded Documents gets all available meta info (see https://lukasschwab.me/arxiv.py/index.html#Result), if False: the `metadata` gets only the most informative fields. + """ arxiv_client: Any #: :meta private: diff --git a/langchain/utilities/google_search.py b/langchain/utilities/google_search.py index 7846c72a3..e02b0b975 100644 --- a/langchain/utilities/google_search.py +++ b/langchain/utilities/google_search.py @@ -33,7 +33,7 @@ class GoogleSearchAPIWrapper(BaseModel): - That’s all you have to fill up, the rest doesn’t matter. In the left-side menu, click Edit search engine → {your search engine name} → Setup Set Search the entire web to ON. Remove the URL you added from - the list of Sites to search. + the list of Sites to search. - Under Search engine ID you’ll find the search-engine-ID. 4. Enable the Custom Search API diff --git a/langchain/utilities/searx_search.py b/langchain/utilities/searx_search.py index 4c780f277..8feb6c76d 100644 --- a/langchain/utilities/searx_search.py +++ b/langchain/utilities/searx_search.py @@ -3,11 +3,11 @@ SearxNG is a privacy-friendly free metasearch engine that aggregates results from `multiple search engines `_ and databases and -supports the `OpenSearch +supports the `OpenSearch `_ specification. -More detailes on the installtion instructions `here. <../../integrations/searx.html>`_ +More details on the installation instructions `here. <../../integrations/searx.html>`_ For the search API refer to https://docs.searxng.org/dev/search_api.html @@ -40,7 +40,7 @@ Searching Use the :meth:`run() ` and :meth:`results() ` methods to query the searx API. -Other methods are are available for convenience. +Other methods are available for convenience. :class:`SearxResults` is a convenience wrapper around the raw json result. @@ -415,33 +415,22 @@ class SearxSearchWrapper(BaseModel): Args: query: The query to search for. - query_suffix: Extra suffix appended to the query. - num_results: Limit the number of results to return. - engines: List of engines to use for the query. - categories: List of categories to use for the query. - **kwargs: extra parameters to pass to the searx API. Returns: Dict with the following keys: - { snippet: The description of the result. - title: The title of the result. - link: The link to the result. - engines: The engines used for the result. - category: Searx category of the result. } - """ _params = { "q": query, diff --git a/langchain/vectorstores/analyticdb.py b/langchain/vectorstores/analyticdb.py index bb32549b4..be45c1a55 100644 --- a/langchain/vectorstores/analyticdb.py +++ b/langchain/vectorstores/analyticdb.py @@ -121,6 +121,7 @@ class AnalyticDB(VectorStore): - `pre_delete_collection` if True, will delete the collection if it exists. (default: False) - Useful for testing. + """ def __init__( diff --git a/langchain/vectorstores/base.py b/langchain/vectorstores/base.py index 6b689cd14..a789d358b 100644 --- a/langchain/vectorstores/base.py +++ b/langchain/vectorstores/base.py @@ -52,7 +52,6 @@ class VectorStore(ABC): Args: documents (List[Document]: Documents to add to the vectorstore. - Returns: List[str]: List of IDs of the added texts. """ diff --git a/langchain/vectorstores/chroma.py b/langchain/vectorstores/chroma.py index b10a81ed9..39577b0cf 100644 --- a/langchain/vectorstores/chroma.py +++ b/langchain/vectorstores/chroma.py @@ -244,6 +244,7 @@ class Chroma(VectorStore): """Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. + Args: embedding: Embedding to look up documents similar to. k: Number of Documents to return. Defaults to 4. @@ -253,6 +254,7 @@ class Chroma(VectorStore): to maximum diversity and 1 to minimum diversity. Defaults to 0.5. filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None. + Returns: List of Documents selected by maximal marginal relevance. """ @@ -287,6 +289,7 @@ class Chroma(VectorStore): """Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. + Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. @@ -296,6 +299,7 @@ class Chroma(VectorStore): to maximum diversity and 1 to minimum diversity. Defaults to 0.5. filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None. + Returns: List of Documents selected by maximal marginal relevance. """ diff --git a/langchain/vectorstores/deeplake.py b/langchain/vectorstores/deeplake.py index 01ed62df1..62ae2a572 100644 --- a/langchain/vectorstores/deeplake.py +++ b/langchain/vectorstores/deeplake.py @@ -391,6 +391,7 @@ class DeepLake(VectorStore): Args: embedding: Embedding to look up documents similar to. k: Number of Documents to return. Defaults to 4. + Returns: List of Documents most similar to the query vector. """ @@ -412,6 +413,7 @@ class DeepLake(VectorStore): Defaults to `L2`. k (int): Number of results to return. Defaults to 4. filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None. + Returns: List[Tuple[Document, float]]: List of documents most similar to the query text with distance in float. @@ -435,14 +437,16 @@ class DeepLake(VectorStore): """Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. + Args: embedding: Embedding to look up documents similar to. k: Number of Documents to return. Defaults to 4. fetch_k: Number of Documents to fetch to pass to MMR algorithm. lambda_mult: Number between 0 and 1 that determines the degree - of diversity among the results with 0 corresponding - to maximum diversity and 1 to minimum diversity. - Defaults to 0.5. + of diversity among the results with 0 corresponding + to maximum diversity and 1 to minimum diversity. + Defaults to 0.5. + Returns: List of Documents selected by maximal marginal relevance. """ @@ -514,7 +518,7 @@ class DeepLake(VectorStore): - AWS S3 path of the form ``s3://bucketname/path/to/dataset``. Credentials are required in either the environment - Google Cloud Storage path of the form - ``gcs://bucketname/path/to/dataset``Credentials are required + ``gcs://bucketname/path/to/dataset`` Credentials are required in either the environment - Local file system path of the form ``./path/to/dataset`` or ``~/path/to/dataset`` or ``path/to/dataset``. diff --git a/langchain/vectorstores/myscale.py b/langchain/vectorstores/myscale.py index 3ae8d275d..cc43aa7ee 100644 --- a/langchain/vectorstores/myscale.py +++ b/langchain/vectorstores/myscale.py @@ -30,7 +30,7 @@ class MyScaleSettings(BaseSettings): myscale_host (str) : An URL to connect to MyScale backend. Defaults to 'localhost'. myscale_port (int) : URL port to connect with HTTP. Defaults to 8443. - username (str) : Usernamed to login. Defaults to None. + username (str) : Username to login. Defaults to None. password (str) : Password to login. Defaults to None. index_type (str): index type string. index_param (dict): index build parameter. @@ -43,14 +43,16 @@ class MyScaleSettings(BaseSettings): semantics. Must have keys: `text`, `id`, `vector`, must be same size to number of columns. For example: .. code-block:: python - { - 'id': 'text_id', - 'vector': 'text_embedding', - 'text': 'text_plain', - 'metadata': 'metadata_dictionary_in_json', - } + + { + 'id': 'text_id', + 'vector': 'text_embedding', + 'text': 'text_plain', + 'metadata': 'metadata_dictionary_in_json', + } Defaults to identity map. + """ host: str = "localhost" diff --git a/langchain/vectorstores/qdrant.py b/langchain/vectorstores/qdrant.py index ce6a1b782..c3fead145 100644 --- a/langchain/vectorstores/qdrant.py +++ b/langchain/vectorstores/qdrant.py @@ -382,10 +382,10 @@ class Qdrant(VectorStore): Additional arguments passed directly into REST client initialization This is a user-friendly interface that: - 1. Creates embeddings, one for each text - 2. Initializes the Qdrant database as an in-memory docstore by default - (and overridable to a remote docstore) - 3. Adds the text embeddings to the Qdrant database + 1. Creates embeddings, one for each text + 2. Initializes the Qdrant database as an in-memory docstore by default + (and overridable to a remote docstore) + 3. Adds the text embeddings to the Qdrant database This is intended to be a quick way to get started. diff --git a/langchain/vectorstores/supabase.py b/langchain/vectorstores/supabase.py index d6d5b0275..72a062de6 100644 --- a/langchain/vectorstores/supabase.py +++ b/langchain/vectorstores/supabase.py @@ -298,8 +298,9 @@ class SupabaseVectorStore(VectorStore): List of Documents selected by maximal marginal relevance. `max_marginal_relevance_search` requires that `query_name` returns matched - embeddings alongside the match documents. The following function function + embeddings alongside the match documents. The following function demonstrates how to do this: + ```sql CREATE FUNCTION match_documents_embeddings(query_embedding vector(1536), match_count int) @@ -326,7 +327,8 @@ class SupabaseVectorStore(VectorStore): docstore.embedding <=> query_embedding LIMIT match_count; END; - $$;``` + $$; + ``` """ embedding = self._embedding.embed_documents([query]) docs = self.max_marginal_relevance_search_by_vector(