ArangoDB | 🦜🔗 Langchain

Main:  On this page #ArangoDB [ArangoDB](https://github.com/arangodb/arangodb) is a scalable graph database system to drive value from connected data, faster. Native graphs, an integrated search engine, and JSON support, via a single query language. ArangoDB runs on-prem, in the cloud – anywhere.  ##Dependencies[](#dependencies) Install the [ArangoDB Python Driver](https://github.com/ArangoDB-Community/python-arango) package with  pip install python-arango  ##Graph QA Chain[](#graph-qa-chain) Connect your ArangoDB Database with a chat model to get insights on your data.  See the notebook example [here](/docs/use_cases/graph/graph_arangodb_qa).  from arango import ArangoClient  from langchain.graphs import ArangoGraph from langchain.chains import ArangoGraphQAChain


Argilla | 🦜🔗 Langchain

Main:  On this page #Argilla   [Argilla](https://argilla.io/) is an open-source data curation platform for LLMs. Using Argilla, everyone can build robust language models through faster data curation using both human and machine feedback. We provide support for each step in the MLOps cycle, from data labelling to model monitoring.  ##Installation and Setup[](#installation-and-setup) First, you'll need to install the argilla Python package as follows:  pip install argilla --upgrade  If you already have an Argilla Server running, then you're good to go; but if you don't, follow the next steps to install it.  If you don't you can refer to [Argilla - 🚀 Quickstart](https://docs.argilla.io/en/latest/getting_started/quickstart.html#Running-Argilla-Quickstart) to deploy Argilla either on HuggingFace Spaces, locally, or on a server.  ##Tracking[](#tracking) See a [usage example of ArgillaCallbackHandler](/docs/integrations/callbacks/argilla).  from langchain.callbacks import ArgillaCallbackHandler


Arthur | 🦜🔗 Langchain

Main:  #Arthur [Arthur](https://arthur.ai) is a model monitoring and observability platform.  The following guide shows how to run a registered chat LLM with the Arthur callback handler to automatically log model inferences to Arthur.  If you do not have a model currently onboarded to Arthur, visit our [onboarding guide for generative text models](https://docs.arthur.ai/user-guide/walkthroughs/model-onboarding/generative_text_onboarding.html). For more information about how to use the Arthur SDK, visit our [docs](https://docs.arthur.ai/).  from langchain.callbacks import ArthurCallbackHandler from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler from langchain.chat_models import ChatOpenAI from langchain.schema import HumanMessage  Place Arthur credentials here  arthur_url = "https://app.arthur.ai" arthur_login = "your-arthur-login-username-here" arthur_model_id = "your-arthur-model-id-here"  Create Langchain LLM with Arthur callback handler  def make_langchain_chat_llm():     return ChatOpenAI(         streaming=True,         temperature=0.1,         callbacks=[             StreamingStdOutCallbackHandler(),             ArthurCallbackHandler.from_credentials(                 arthur_model_id, arthur_url=arthur_url, arthur_login=arthur_login             ),         ],     )  chatgpt = make_langchain_chat_llm()      Please enter password for admin: ········  Running the chat LLM with this run function will save the chat history in an ongoing list so that the conversation can reference earlier messages and log each response to the Arthur platform. You can view the history of this model's inferences on your [model dashboard page](https://app.arthur.ai/).  Enter q to quit the run loop  def run(llm):     history = []     while True:         user_input = input("\n>>> input >>>\n>>>: ")         if user_input == "q":             break         history.append(HumanMessage(content=user_input))         history.append(llm(history))  run(chatgpt)           >>> input >>>     >>>: What is a callback handler?     A callback handler, also known as a callback function or callback method, is a piece of code that is executed in response to a specific event or condition. It is commonly used in programming languages that support event-driven or asynchronous programming paradigms.          The purpose of a callback handler is to provide a way for developers to define custom behavior that should be executed when a certain event occurs. Instead of waiting for a result or blocking the execution, the program registers a callback function and continues with other tasks. When the event is triggered, the callback function is invoked, allowing the program to respond accordingly.          Callback handlers are commonly used in various scenarios, such as handling user input, responding to network requests, processing asynchronous operations, and implementing event-driven architectures. They provide a flexible and modular way to handle events and decouple different components of a system.     >>> input >>>     >>>: What do I need to do to get the full benefits of this     To get the full benefits of using a callback handler, you should consider the following:          1. Understand the event or condition: Identify the specific event or condition that you want to respond to with a callback handler. This could be user input, network requests, or any other asynchronous operation.          2. Define the callback function: Create a function that will be executed when the event or condition occurs. This function should contain the desired behavior or actions you want to take in response to the event.          3. Register the callback function: Depending on the programming language or framework you are using, you may need to register or attach the callback function to the appropriate event or condition. This ensures that the callback function is invoked when the event occurs.          4. Handle the callback: Implement the necessary logic within the callback function to handle the event or condition. This could involve updating the user interface, processing data, making further requests, or triggering other actions.          5. Consider error handling: It's important to handle any potential errors or exceptions that may occur within the callback function. This ensures that your program can gracefully handle unexpected situations and prevent crashes or undesired behavior.          6. Maintain code readability and modularity: As your codebase grows, it's crucial to keep your callback handlers organized and maintainable. Consider using design patterns or architectural principles to structure your code in a modular and scalable way.          By following these steps, you can leverage the benefits of callback handlers, such as asynchronous and event-driven programming, improved responsiveness, and modular code design.     >>> input >>>     >>>: q


Arxiv | 🦜🔗 Langchain

Main:  On this page #Arxiv [arXiv](https://arxiv.org/) is an open-access archive for 2 million scholarly articles in the fields of physics, mathematics, computer science, quantitative biology, quantitative finance, statistics, electrical engineering and systems science, and economics.  ##Installation and Setup[](#installation-and-setup) First, you need to install arxiv python package.  pip install arxiv  Second, you need to install PyMuPDF python package which transforms PDF files downloaded from the arxiv.org site into the text format.  pip install pymupdf  ##Document Loader[](#document-loader) See a [usage example](/docs/integrations/document_loaders/arxiv).  from langchain.document_loaders import ArxivLoader  ##Retriever[](#retriever) See a [usage example](/docs/integrations/retrievers/arxiv).  from langchain.retrievers import ArxivRetriever


Astra DB | 🦜🔗 Langchain

Main:  On this page #Astra DB This page lists the integrations available with [Astra DB](https://docs.datastax.com/en/astra/home/astra.html) and [Apache Cassandra®](https://cassandra.apache.org/).  ###Setup[](#setup) Install the following Python package:  pip install "astrapy>=0.5.3"  ##Astra DB[](#astra-db-1) DataStax [Astra DB](https://docs.datastax.com/en/astra/home/astra.html) is a serverless vector-capable database built on Cassandra and made conveniently available through an easy-to-use JSON API.  ###Vector Store[](#vector-store) from langchain.vectorstores import AstraDB vector_store = AstraDB(   embedding=my_embedding,   collection_name="my_store",   api_endpoint="...",   token="...", )  Learn more in the [example notebook](/docs/integrations/vectorstores/astradb).  ###LLM Cache[](#llm-cache) from langchain.globals import set_llm_cache from langchain.cache import AstraDBCache set_llm_cache(AstraDBCache(     api_endpoint="...",     token="...", ))  Learn more in the [example notebook](/docs/integrations/llms/llm_caching) (scroll to the Astra DB section).  ###Semantic LLM Cache[](#semantic-llm-cache) from langchain.globals import set_llm_cache from langchain.cache import AstraDBSemanticCache set_llm_cache(AstraDBSemanticCache(     embedding=my_embedding,     api_endpoint="...",     token="...", ))  Learn more in the [example notebook](/docs/integrations/llms/llm_caching) (scroll to the appropriate section).  ###Chat message history[](#chat-message-history) from langchain.memory import AstraDBChatMessageHistory message_history = AstraDBChatMessageHistory(     session_id="test-session"     api_endpoint="...",     token="...", )  Learn more in the [example notebook](/docs/integrations/memory/astradb_chat_message_history).  ##Apache Cassandra and Astra DB through CQL[](#apache-cassandra-and-astra-db-through-cql) [Cassandra](https://cassandra.apache.org/) is a NoSQL, row-oriented, highly scalable and highly available database. Starting with version 5.0, the database ships with [vector search capabilities](https://cassandra.apache.org/doc/trunk/cassandra/vector-search/overview.html). DataStax [Astra DB through CQL](https://docs.datastax.com/en/astra-serverless/docs/vector-search/quickstart.html) is a managed serverless database built on Cassandra, offering the same interface and strengths.  These databases use the CQL protocol (Cassandra Query Language). Hence, a different set of connectors, outlined below, shall be used.  ###Vector Store[](#vector-store-1) from langchain.vectorstores import Cassandra vector_store = Cassandra(   embedding=my_embedding,   table_name="my_store", )  Learn more in the [example notebook](/docs/integrations/vectorstores/astradb) (scroll down to the CQL-specific section).  ###Memory[](#memory) from langchain.memory import CassandraChatMessageHistory message_history = CassandraChatMessageHistory(session_id="my-session")  Learn more in the [example notebook](/docs/integrations/memory/cassandra_chat_message_history).  ###LLM Cache[](#llm-cache-1) from langchain.cache import CassandraCache langchain.llm_cache = CassandraCache()  Learn more in the [example notebook](/docs/integrations/llms/llm_caching) (scroll to the Cassandra section).  ###Semantic LLM Cache[](#semantic-llm-cache-1) from langchain.cache import CassandraSemanticCache cassSemanticCache = CassandraSemanticCache(   embedding=my_embedding,   table_name="my_store", )  Learn more in the [example notebook](/docs/integrations/llms/llm_caching) (scroll to the appropriate section).


Atlas | 🦜🔗 Langchain

Main:  On this page #Atlas [Nomic Atlas](https://docs.nomic.ai/index.html) is a platform for interacting with both small and internet scale unstructured datasets.  ##Installation and Setup[](#installation-and-setup) - Install the Python package with pip install nomic - Nomic is also included in langchains poetry extras poetry install -E all ##VectorStore[](#vectorstore) See a [usage example](/docs/integrations/vectorstores/atlas).  from langchain.vectorstores import AtlasDB


AwaDB | 🦜🔗 Langchain

Main:  On this page #AwaDB [AwaDB](https://github.com/awa-ai/awadb) is an AI Native database for the search and storage of embedding vectors used by LLM Applications.  ##Installation and Setup[](#installation-and-setup) pip install awadb  ##Vector Store[](#vector-store) from langchain.vectorstores import AwaDB  See a [usage example](/docs/integrations/vectorstores/awadb).  ##Text Embedding Model[](#text-embedding-model) from langchain.embeddings import AwaEmbeddings  See a [usage example](/docs/integrations/text_embedding/awadb).


AWS | 🦜🔗 Langchain

Main:  On this page #AWS All functionality related to [Amazon AWS](https://aws.amazon.com/) platform  ##LLMs[](#llms) ###Bedrock[](#bedrock) See a [usage example](/docs/integrations/llms/bedrock).  from langchain.llms.bedrock import Bedrock  ###Amazon API Gateway[](#amazon-api-gateway) [Amazon API Gateway](https://aws.amazon.com/api-gateway/) is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. APIs act as the "front door" for applications to access data, business logic, or functionality from your backend services. Using API Gateway, you can create RESTful APIs and WebSocket APIs that enable real-time two-way communication applications. API Gateway supports containerized and serverless workloads, as well as web applications.  API Gateway handles all the tasks involved in accepting and processing up to hundreds of thousands of concurrent API calls, including traffic management, CORS support, authorization and access control, throttling, monitoring, and API version management. API Gateway has no minimum fees or startup costs. You pay for the API calls you receive and the amount of data transferred out and, with the API Gateway tiered pricing model, you can reduce your cost as your API usage scales.  See a [usage example](/docs/integrations/llms/amazon_api_gateway_example).  from langchain.llms import AmazonAPIGateway  api_url = "https://<api_gateway_id>.execute-api.<region>.amazonaws.com/LATEST/HF" # These are sample parameters for Falcon 40B Instruct Deployed from Amazon SageMaker JumpStart model_kwargs = {     "max_new_tokens": 100,     "num_return_sequences": 1,     "top_k": 50,     "top_p": 0.95,     "do_sample": False,     "return_full_text": True,     "temperature": 0.2, } llm = AmazonAPIGateway(api_url=api_url, model_kwargs=model_kwargs)  ###SageMaker Endpoint[](#sagemaker-endpoint) [Amazon SageMaker](https://aws.amazon.com/sagemaker/) is a system that can build, train, and deploy machine learning (ML) models with fully managed infrastructure, tools, and workflows.  We use SageMaker to host our model and expose it as the SageMaker Endpoint.  See a [usage example](/docs/integrations/llms/sagemaker).  from langchain.llms import SagemakerEndpoint from langchain.llms.sagemaker_endpoint import LLMContentHandler  ##Text Embedding Models[](#text-embedding-models) ###Bedrock[](#bedrock-1) See a [usage example](/docs/integrations/text_embedding/bedrock).  from langchain.embeddings import BedrockEmbeddings  ###SageMaker Endpoint[](#sagemaker-endpoint-1) See a [usage example](/docs/integrations/text_embedding/sagemaker-endpoint).  from langchain.embeddings import SagemakerEndpointEmbeddings from langchain.llms.sagemaker_endpoint import ContentHandlerBase  ##Document loaders[](#document-loaders) ###AWS S3 Directory and File[](#aws-s3-directory-and-file) [Amazon Simple Storage Service (Amazon S3)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-folders.html) is an object storage service. [AWS S3 Directory](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-folders.html) [AWS S3 Buckets](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingBucket.html)  See a [usage example for S3DirectoryLoader](/docs/integrations/document_loaders/aws_s3_directory).  See a [usage example for S3FileLoader](/docs/integrations/document_loaders/aws_s3_file).  from langchain.document_loaders import S3DirectoryLoader, S3FileLoader  ##Memory[](#memory) ###AWS DynamoDB[](#aws-dynamodb) [AWS DynamoDB](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/index.html) is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability.  We have to configure the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html).  We need to install the boto3 library.  pip install boto3  See a [usage example](/docs/integrations/memory/aws_dynamodb).  from langchain.memory import DynamoDBChatMessageHistory


AZLyrics | 🦜🔗 Langchain

Main:  On this page #AZLyrics [AZLyrics](https://www.azlyrics.com/) is a large, legal, every day growing collection of lyrics.  ##Installation and Setup[](#installation-and-setup) There isn't any special setup for it.  ##Document Loader[](#document-loader) See a [usage example](/docs/integrations/document_loaders/azlyrics).  from langchain.document_loaders import AZLyricsLoader


BagelDB | 🦜🔗 Langchain

Main:  On this page #BagelDB [BagelDB](https://www.bageldb.ai/) (Open Vector Database for AI), is like GitHub for AI data. It is a collaborative platform where users can create, share, and manage vector datasets. It can support private projects for independent developers, internal collaborations for enterprises, and public contributions for data DAOs.  ##Installation and Setup[](#installation-and-setup) pip install betabageldb  ##VectorStore[](#vectorstore) See a [usage example](/docs/integrations/vectorstores/bageldb).  from langchain.vectorstores import Bagel


Banana | 🦜🔗 Langchain

Main:  On this page #Banana Banana provided serverless GPU inference for AI models, including a CI/CD build pipeline and a simple Python framework (Potassium) to server your models.  This page covers how to use the [Banana](https://www.banana.dev) ecosystem within LangChain.  It is broken into two parts:  - installation and setup, - and then references to specific Banana wrappers. ##Installation and Setup[](#installation-and-setup) - Install with pip install banana-dev - Get an Banana api key from the [Banana.dev dashboard](https://app.banana.dev) and set it as an environment variable (BANANA_API_KEY) - Get your model's key and url slug from the model's details page ##Define your Banana Template[](#define-your-banana-template) You'll need to set up a Github repo for your Banana app. You can get started in 5 minutes using [this guide](https://docs.banana.dev/banana-docs/).  Alternatively, for a ready-to-go LLM example, you can check out Banana's [CodeLlama-7B-Instruct-GPTQ](https://github.com/bananaml/demo-codellama-7b-instruct-gptq) GitHub repository. Just fork it and deploy it within Banana.  Other starter repos are available [here](https://github.com/orgs/bananaml/repositories?q=demo-&type=all&language=&sort=).  ##Build the Banana app[](#build-the-banana-app) To use Banana apps within Langchain, they must include the outputs key in the returned json, and the value must be a string.  # Return the results as a dictionary result = {'outputs': result}  An example inference function would be:  @app.handler("/") def handler(context: dict, request: Request) -> Response:     """Handle a request to generate code from a prompt."""     model = context.get("model")     tokenizer = context.get("tokenizer")     max_new_tokens = request.json.get("max_new_tokens", 512)     temperature = request.json.get("temperature", 0.7)     prompt = request.json.get("prompt")     prompt_template=f'''[INST] Write code to solve the following coding problem that obeys the constraints and passes the example test cases. Please wrap your code answer using ```:     {prompt}     [/INST]     '''     input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()     output = model.generate(inputs=input_ids, temperature=temperature, max_new_tokens=max_new_tokens)     result = tokenizer.decode(output[0])     return Response(json={"outputs": result}, status=200)  This example is from the app.py file in [CodeLlama-7B-Instruct-GPTQ](https://github.com/bananaml/demo-codellama-7b-instruct-gptq).  ##Wrappers[](#wrappers) ###LLM[](#llm) Within Langchain, there exists a Banana LLM wrapper, which you can access with  from langchain.llms import Banana  You need to provide a model key and model url slug, which you can get from the model's details page in the [Banana.dev dashboard](https://app.banana.dev).  llm = Banana(model_key="YOUR_MODEL_KEY", model_url_slug="YOUR_MODEL_URL_SLUG")


Baseten | 🦜🔗 Langchain

Main:  On this page #Baseten Learn how to use LangChain with models deployed on Baseten.  ##Installation and setup[](#installation-and-setup) - Create a [Baseten](https://baseten.co) account and [API key](https://docs.baseten.co/settings/api-keys). - Install the Baseten Python client with pip install baseten - Use your API key to authenticate with baseten login ##Invoking a model[](#invoking-a-model) Baseten integrates with LangChain through the LLM module, which provides a standardized and interoperable interface for models that are deployed on your Baseten workspace.  You can deploy foundation models like WizardLM and Alpaca with one click from the [Baseten model library](https://app.baseten.co/explore/) or if you have your own model, [deploy it with this tutorial](https://docs.baseten.co/deploying-models/deploy).  In this example, we'll work with WizardLM. [Deploy WizardLM here](https://app.baseten.co/explore/wizardlm) and follow along with the deployed [model's version ID](https://docs.baseten.co/managing-models/manage).  from langchain.llms import Baseten  wizardlm = Baseten(model="MODEL_VERSION_ID", verbose=True)  wizardlm("What is the difference between a Wizard and a Sorcerer?")


Beam | 🦜🔗 Langchain

Main:  On this page #Beam This page covers how to use Beam within LangChain. It is broken into two parts: installation and setup, and then references to specific Beam wrappers.  ##Installation and Setup[](#installation-and-setup) - [Create an account](https://www.beam.cloud/) - Install the Beam CLI with curl https://raw.githubusercontent.com/slai-labs/get-beam/main/get-beam.sh -sSfL | sh - Register API keys with beam configure - Set environment variables (BEAM_CLIENT_ID) and (BEAM_CLIENT_SECRET) - Install the Beam SDK pip install beam-sdk ##Wrappers[](#wrappers) ###LLM[](#llm) There exists a Beam LLM wrapper, which you can access with  from langchain.llms.beam import Beam  ##Define your Beam app.[](#define-your-beam-app) This is the environment you’ll be developing against once you start the app. It's also used to define the maximum response length from the model.  llm = Beam(model_name="gpt2",            name="langchain-gpt2-test",            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",            verbose=False)  ##Deploy your Beam app[](#deploy-your-beam-app) Once defined, you can deploy your Beam app by calling your model's _deploy() method.  llm._deploy()  ##Call your Beam app[](#call-your-beam-app) Once a beam model is deployed, it can be called by callying your model's _call() method. This returns the GPT2 text response to your prompt.  response = llm._call("Running machine learning on a remote GPU")  An example script which deploys the model and calls it would be:  from langchain.llms.beam import Beam import time  llm = Beam(model_name="gpt2",            name="langchain-gpt2-test",            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",            verbose=False)  llm._deploy()  response = llm._call("Running machine learning on a remote GPU")  print(response)


Beautiful Soup | 🦜🔗 Langchain

Main:  On this page #Beautiful Soup [Beautiful Soup](https://www.crummy.com/software/BeautifulSoup/) is a Python package for parsing HTML and XML documents (including having malformed markup, i.e. non-closed tags, so named after tag soup). It creates a parse tree for parsed pages that can be used to extract data from HTML,[3] which is useful for web scraping.  ##Installation and Setup[](#installation-and-setup) pip install beautifulsoup4  ##Document Transformer[](#document-transformer) See a [usage example](/docs/integrations/document_transformers/beautiful_soup).  from langchain.document_loaders import BeautifulSoupTransformer


BiliBili | 🦜🔗 Langchain

Main:  On this page #BiliBili [Bilibili](https://www.bilibili.tv/) is one of the most beloved long-form video sites in China.  ##Installation and Setup[](#installation-and-setup) pip install bilibili-api-python  ##Document Loader[](#document-loader) See a [usage example](/docs/integrations/document_loaders/bilibili).  from langchain.document_loaders import BiliBiliLoader


NIBittensor | 🦜🔗 Langchain

Main:  On this page #NIBittensor This page covers how to use the BittensorLLM inference runtime within LangChain. It is broken into two parts: installation and setup, and then examples of NIBittensorLLM usage.  ##Installation and Setup[](#installation-and-setup) - Install the Python package with pip install langchain ##Wrappers[](#wrappers) ###LLM[](#llm) There exists a NIBittensor LLM wrapper, which you can access with:  from langchain.llms import NIBittensorLLM  It provides a unified interface for all models:  llm = NIBittensorLLM(system_prompt="Your task is to provide concise and accurate response based on user prompt")  print(llm('Write a fibonacci function in python with golder ratio'))  Multiple responses from top miners can be accessible using the top_responses parameter:  multi_response_llm = NIBittensorLLM(top_responses=10) multi_resp = multi_response_llm("What is Neural Network Feeding Mechanism?") json_multi_resp = json.loads(multi_resp)  print(json_multi_resp)


Blackboard | 🦜🔗 Langchain

Main:  On this page #Blackboard [Blackboard Learn](https://en.wikipedia.org/wiki/Blackboard_Learn) (previously the Blackboard Learning Management System) is a web-based virtual learning environment and learning management system developed by Blackboard Inc. The software features course management, customizable open architecture, and scalable design that allows integration with student information systems and authentication protocols. It may be installed on local servers, hosted by Blackboard ASP Solutions, or provided as Software as a Service hosted on Amazon Web Services. Its main purposes are stated to include the addition of online elements to courses traditionally delivered face-to-face and development of completely online courses with few or no face-to-face meetings.  ##Installation and Setup[](#installation-and-setup) There isn't any special setup for it.  ##Document Loader[](#document-loader) See a [usage example](/docs/integrations/document_loaders/blackboard).  from langchain.document_loaders import BlackboardLoader


Brave Search | 🦜🔗 Langchain

Main:  On this page #Brave Search [Brave Search](https://en.wikipedia.org/wiki/Brave_Search) is a search engine developed by Brave Software.  - Brave Search uses its own web index. As of May 2022, it covered over 10 billion pages and was used to serve 92% of search results without relying on any third-parties, with the remainder being retrieved server-side from the Bing API or (on an opt-in basis) client-side from Google. According to Brave, the index was kept "intentionally smaller than that of Google or Bing" in order to help avoid spam and other low-quality content, with the disadvantage that "Brave Search is not yet as good as Google in recovering long-tail queries." - Brave Search Premium: As of April 2023 Brave Search is an ad-free website, but it will eventually switch to a new model that will include ads and premium users will get an ad-free experience. User data including IP addresses won't be collected from its users by default. A premium account will be required for opt-in data-collection. ##Installation and Setup[](#installation-and-setup) To get access to the Brave Search API, you need to [create an account and get an API key](https://api.search.brave.com/app/dashboard).  ##Document Loader[](#document-loader) See a [usage example](/docs/integrations/document_loaders/brave_search).  from langchain.document_loaders import BraveSearchLoader  ##Tool[](#tool) See a [usage example](/docs/integrations/tools/brave_search).  from langchain.tools import BraveSearch


CerebriumAI | 🦜🔗 Langchain

Main:  On this page #CerebriumAI This page covers how to use the CerebriumAI ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific CerebriumAI wrappers.  ##Installation and Setup[](#installation-and-setup) - Install with pip install cerebrium - Get an CerebriumAI api key and set it as an environment variable (CEREBRIUMAI_API_KEY) ##Wrappers[](#wrappers) ###LLM[](#llm) There exists an CerebriumAI LLM wrapper, which you can access with  from langchain.llms import CerebriumAI


Chaindesk | 🦜🔗 Langchain

Main:  On this page #Chaindesk [Chaindesk](https://chaindesk.ai) is an [open-source](https://github.com/gmpetrov/databerry) document retrieval platform that helps to connect your personal data with Large Language Models.  ##Installation and Setup[](#installation-and-setup) We need to sign up for Chaindesk, create a datastore, add some data and get your datastore api endpoint url. We need the [API Key](https://docs.chaindesk.ai/api-reference/authentication).  ##Retriever[](#retriever) See a [usage example](/docs/integrations/retrievers/chaindesk).  from langchain.retrievers import ChaindeskRetriever


Chroma | 🦜🔗 Langchain

Main:  On this page #Chroma [Chroma](https://docs.trychroma.com/getting-started) is a database for building AI applications with embeddings.  ##Installation and Setup[](#installation-and-setup) pip install chromadb  ##VectorStore[](#vectorstore) There exists a wrapper around Chroma vector databases, allowing you to use it as a vectorstore, whether for semantic search or example selection.  from langchain.vectorstores import Chroma  For a more detailed walkthrough of the Chroma wrapper, see [this notebook](/docs/integrations/vectorstores/chroma)  ##Retriever[](#retriever) See a [usage example](/docs/modules/data_connection/retrievers/how_to/self_query/chroma_self_query).  from langchain.retrievers import SelfQueryRetriever


Clarifai | 🦜🔗 Langchain

Main:  On this page #Clarifai [Clarifai](https://clarifai.com) is one of first deep learning platforms having been founded in 2013. Clarifai provides an AI platform with the full AI lifecycle for data exploration, data labeling, model training, evaluation and inference around images, video, text and audio data. In the LangChain ecosystem, as far as we're aware, Clarifai is the only provider that supports LLMs, embeddings and a vector store in one production scale platform, making it an excellent choice to operationalize your LangChain implementations.  ##Installation and Setup[](#installation-and-setup) - Install the Python SDK: pip install clarifai  [Sign-up](https://clarifai.com/signup) for a Clarifai account, then get a personal access token to access the Clarifai API from your [security settings](https://clarifai.com/settings/security) and set it as an environment variable (CLARIFAI_PAT).  ##Models[](#models) Clarifai provides 1,000s of AI models for many different use cases. You can [explore them here](https://clarifai.com/explore) to find the one most suited for your use case. These models include those created by other providers such as OpenAI, Anthropic, Cohere, AI21, etc. as well as state of the art from open source such as Falcon, InstructorXL, etc. so that you build the best in AI into your products. You'll find these organized by the creator's user_id and into projects we call applications denoted by their app_id. Those IDs will be needed in additional to the model_id and optionally the version_id, so make note of all these IDs once you found the best model for your use case!  Also note that given there are many models for images, video, text and audio understanding, you can build some interested AI agents that utilize the variety of AI models as experts to understand those data types.  ###LLMs[](#llms) To find the selection of LLMs in the Clarifai platform you can select the text to text model type [here](https://clarifai.com/explore/models?filterData=%5B%7B%22field%22%3A%22model_type_id%22%2C%22value%22%3A%5B%22text-to-text%22%5D%7D%5D&page=1&perPage=24).  from langchain.llms import Clarifai llm = Clarifai(pat=CLARIFAI_PAT, user_id=USER_ID, app_id=APP_ID, model_id=MODEL_ID)  For more details, the docs on the Clarifai LLM wrapper provide a [detailed walkthrough](/docs/integrations/llms/clarifai).  ###Text Embedding Models[](#text-embedding-models) To find the selection of text embeddings models in the Clarifai platform you can select the text to embedding model type [here](https://clarifai.com/explore/models?page=1&perPage=24&filterData=%5B%7B%22field%22%3A%22model_type_id%22%2C%22value%22%3A%5B%22text-embedder%22%5D%7D%5D).  There is a Clarifai Embedding model in LangChain, which you can access with:  from langchain.embeddings import ClarifaiEmbeddings embeddings = ClarifaiEmbeddings(pat=CLARIFAI_PAT, user_id=USER_ID, app_id=APP_ID, model_id=MODEL_ID)  For more details, the docs on the Clarifai Embeddings wrapper provide a [detailed walkthrough](/docs/integrations/text_embedding/clarifai).  ##Vectorstore[](#vectorstore) Clarifai's vector DB was launched in 2016 and has been optimized to support live search queries. With workflows in the Clarifai platform, you data is automatically indexed by am embedding model and optionally other models as well to index that information in the DB for search. You can query the DB not only via the vectors but also filter by metadata matches, other AI predicted concepts, and even do geo-coordinate search. Simply create an application, select the appropriate base workflow for your type of data, and upload it (through the API as [documented here](https://docs.clarifai.com/api-guide/data/create-get-update-delete) or the UIs at clarifai.com).  You can also add data directly from LangChain as well, and the auto-indexing will take place for you. You'll notice this is a little different than other vectorstores where you need to provide an embedding model in their constructor and have LangChain coordinate getting the embeddings from text and writing those to the index. Not only is it more convenient, but it's much more scalable to use Clarifai's distributed cloud to do all the index in the background.  from langchain.vectorstores import Clarifai clarifai_vector_db = Clarifai.from_texts(user_id=USER_ID, app_id=APP_ID, texts=texts, pat=CLARIFAI_PAT, number_of_docs=NUMBER_OF_DOCS, metadatas = metadatas)  For more details, the docs on the Clarifai vector store provide a [detailed walkthrough](/docs/integrations/vectorstores/clarifai).


ClearML | 🦜🔗 Langchain

Main:  Skip to main content  🦜🔗 LangChain  Search CTRLK ProvidersMoreClearML On this page ClearML ClearML is a ML/DL development and production suite, it contains 5 main modules:  Experiment Manager - Automagical experiment tracking, environments and results MLOps - Orchestration, Automation & Pipelines solution for ML/DL jobs (K8s / Cloud / bare-metal) Data-Management - Fully differentiable data management & version control solution on top of object-storage (S3 / GS / Azure / NAS) Model-Serving - cloud-ready Scalable model serving solution! Deploy new model endpoints in under 5 minutes Includes optimized GPU serving support backed by Nvidia-Triton with out-of-the-box Model Monitoring Fire Reports - Create and share rich MarkDown documents supporting embeddable online content In order to properly keep track of your langchain experiments and their results, you can enable the ClearML integration. We use the ClearML Experiment Manager that neatly tracks and organizes all your experiment runs.   Installation and Setup pip install clearml pip install pandas pip install textstat pip install spacy python -m spacy download en_core_web_sm  Getting API Credentials We'll be using quite some APIs in this notebook, here is a list and where to get them:  ClearML: https://app.clear.ml/settings/workspace-configuration OpenAI: https://platform.openai.com/account/api-keys SerpAPI (google search): https://serpapi.com/dashboard import os  os.environ["CLEARML_API_ACCESS_KEY"] = "" os.environ["CLEARML_API_SECRET_KEY"] = ""  os.environ["OPENAI_API_KEY"] = "" os.environ["SERPAPI_API_KEY"] = ""  Callbacks from langchain.callbacks import ClearMLCallbackHandler  from langchain.callbacks import StdOutCallbackHandler from langchain.llms import OpenAI  # Setup and use the ClearML Callback clearml_callback = ClearMLCallbackHandler(     task_type="inference",     project_name="langchain_callback_demo",     task_name="llm",     tags=["test"],     # Change the following parameters based on the amount of detail you want tracked     visualize=True,     complexity_metrics=True,     stream_logs=True, ) callbacks = [StdOutCallbackHandler(), clearml_callback] # Get the OpenAI model ready to go llm = OpenAI(temperature=0, callbacks=callbacks)      The clearml callback is currently in beta and is subject to change based on updates to `langchain`. Please report any issues to https://github.com/allegroai/clearml/issues with the tag `langchain`.  Scenario 1: Just an LLM First, let's just run a single LLM a few times and capture the resulting prompt-answer conversation in ClearML  # SCENARIO 1 - LLM llm_result = llm.generate(["Tell me a joke", "Tell me a poem"] * 3) # After every generation run, use flush to make sure all the metrics # prompts and other output are properly saved separately clearml_callback.flush_tracker(langchain_asset=llm, name="simple_sequential")      {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 3, 'starts': 2, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'prompts': 'Tell me a joke'}     {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 3, 'starts': 2, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'prompts': 'Tell me a poem'}     {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 3, 'starts': 2, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'prompts': 'Tell me a joke'}     {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 3, 'starts': 2, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'prompts': 'Tell me a poem'}     {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 3, 'starts': 2, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'prompts': 'Tell me a joke'}     {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 3, 'starts': 2, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'prompts': 'Tell me a poem'}     {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'text': '\n\nQ: What did the fish say when it hit the wall?\nA: Dam!', 'generation_info_finish_reason': 'stop', 'generation_info_logprobs': None, 'flesch_reading_ease': 109.04, 'flesch_kincaid_grade': 1.3, 'smog_index': 0.0, 'coleman_liau_index': -1.24, 'automated_readability_index': 0.3, 'dale_chall_readability_score': 5.5, 'difficult_words': 0, 'linsear_write_formula': 5.5, 'gunning_fog': 5.2, 'text_standard': '5th and 6th grade', 'fernandez_huerta': 133.58, 'szigriszt_pazos': 131.54, 'gutierrez_polini': 62.3, 'crawford': -0.2, 'gulpease_index': 79.8, 'osman': 116.91}     {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'text': '\n\nRoses are red,\nViolets are blue,\nSugar is sweet,\nAnd so are you.', 'generation_info_finish_reason': 'stop', 'generation_info_l


ClearML | 🦜🔗 Langchain

ogprobs': None, 'flesch_reading_ease': 83.66, 'flesch_kincaid_grade': 4.8, 'smog_index': 0.0, 'coleman_liau_index': 3.23, 'automated_readability_index': 3.9, 'dale_chall_readability_score': 6.71, 'difficult_words': 2, 'linsear_write_formula': 6.5, 'gunning_fog': 8.28, 'text_standard': '6th and 7th grade', 'fernandez_huerta': 115.58, 'szigriszt_pazos': 112.37, 'gutierrez_polini': 54.83, 'crawford': 1.4, 'gulpease_index': 72.1, 'osman': 100.17}     {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'text': '\n\nQ: What did the fish say when it hit the wall?\nA: Dam!', 'generation_info_finish_reason': 'stop', 'generation_info_logprobs': None, 'flesch_reading_ease': 109.04, 'flesch_kincaid_grade': 1.3, 'smog_index': 0.0, 'coleman_liau_index': -1.24, 'automated_readability_index': 0.3, 'dale_chall_readability_score': 5.5, 'difficult_words': 0, 'linsear_write_formula': 5.5, 'gunning_fog': 5.2, 'text_standard': '5th and 6th grade', 'fernandez_huerta': 133.58, 'szigriszt_pazos': 131.54, 'gutierrez_polini': 62.3, 'crawford': -0.2, 'gulpease_index': 79.8, 'osman': 116.91}     {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'text': '\n\nRoses are red,\nViolets are blue,\nSugar is sweet,\nAnd so are you.', 'generation_info_finish_reason': 'stop', 'generation_info_logprobs': None, 'flesch_reading_ease': 83.66, 'flesch_kincaid_grade': 4.8, 'smog_index': 0.0, 'coleman_liau_index': 3.23, 'automated_readability_index': 3.9, 'dale_chall_readability_score': 6.71, 'difficult_words': 2, 'linsear_write_formula': 6.5, 'gunning_fog': 8.28, 'text_standard': '6th and 7th grade', 'fernandez_huerta': 115.58, 'szigriszt_pazos': 112.37, 'gutierrez_polini': 54.83, 'crawford': 1.4, 'gulpease_index': 72.1, 'osman': 100.17}     {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'text': '\n\nQ: What did the fish say when it hit the wall?\nA: Dam!', 'generation_info_finish_reason': 'stop', 'generation_info_logprobs': None, 'flesch_reading_ease': 109.04, 'flesch_kincaid_grade': 1.3, 'smog_index': 0.0, 'coleman_liau_index': -1.24, 'automated_readability_index': 0.3, 'dale_chall_readability_score': 5.5, 'difficult_words': 0, 'linsear_write_formula': 5.5, 'gunning_fog': 5.2, 'text_standard': '5th and 6th grade', 'fernandez_huerta': 133.58, 'szigriszt_pazos': 131.54, 'gutierrez_polini': 62.3, 'crawford': -0.2, 'gulpease_index': 79.8, 'osman': 116.91}     {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'text': '\n\nRoses are red,\nViolets are blue,\nSugar is sweet,\nAnd so are you.', 'generation_info_finish_reason': 'stop', 'generation_info_logprobs': None, 'flesch_reading_ease': 83.66, 'flesch_kincaid_grade': 4.8, 'smog_index': 0.0, 'coleman_liau_index': 3.23, 'automated_readability_index': 3.9, 'dale_chall_readability_score': 6.71, 'difficult_words': 2, 'linsear_write_formula': 6.5, 'gunning_fog': 8.28, 'text_standard': '6th and 7th grade', 'fernandez_huerta': 115.58, 'szigriszt_pazos': 112.37, 'gutierrez_polini': 54.83, 'crawford': 1.4, 'gulpease_index': 72.1, 'osman': 100.17}     {'action_records':           action    name  step  starts  ends  errors  text_ctr  chain_starts  \     0   on_llm_start  OpenAI     1       1     0       0         0             0        1   on_llm_start  OpenAI     1       1     0       0         0             0        2   on_llm_start  OpenAI     1       1     0       0         0             0        3   on_llm_start  OpenAI     1       1     0       0         0             0        4   on_llm_start  OpenAI     1       1     0       0         0             0        5   on_llm_start  OpenAI     1       1     0       0         0             0        6     on_llm_end     NaN     2       1     1       0         0             0        7     on_llm_end     NaN     2       1     1       0         0             0        8     on_llm_end     NaN     2       1     1       0         0             0        9     on_llm_end     NaN     2       1     1       0         0             0        10    on_llm_end     NaN     2       1     1       0         0             0        11    on_llm_end     NaN     2       1     1       0         0             0        12  on_llm_start  OpenAI     3       2     1       0         0             0        13  on_llm_start  OpenAI     3       2     1       0         0             0        14  on_llm_start  OpenAI     3       2     1       0         0             0        15  on_llm_start  OpenAI     3       2     1       0         0             0        16  on_llm_start  OpenAI     3       2     1       0         0             0        17  on_llm_start  OpenAI     3       2     1       0         0             0        18    on_llm_end     NaN     4       2     2       0         0             0        19    on_llm_end     NaN     4       2     2


ClearML | 🦜🔗 Langchain

0         0             0        20    on_llm_end     NaN     4       2     2       0         0             0        21    on_llm_end     NaN     4       2     2       0         0             0        22    on_llm_end     NaN     4       2     2       0         0             0        23    on_llm_end     NaN     4       2     2       0         0             0                 chain_ends  llm_starts  ...  difficult_words  linsear_write_formula  \     0            0           1  ...              NaN                    NaN        1            0           1  ...              NaN                    NaN        2            0           1  ...              NaN                    NaN        3            0           1  ...              NaN                    NaN        4            0           1  ...              NaN                    NaN        5            0           1  ...              NaN                    NaN        6            0           1  ...              0.0                    5.5        7            0           1  ...              2.0                    6.5        8            0           1  ...              0.0                    5.5        9            0           1  ...              2.0                    6.5        10           0           1  ...              0.0                    5.5        11           0           1  ...              2.0                    6.5        12           0           2  ...              NaN                    NaN        13           0           2  ...              NaN                    NaN        14           0           2  ...              NaN                    NaN        15           0           2  ...              NaN                    NaN        16           0           2  ...              NaN                    NaN        17           0           2  ...              NaN                    NaN        18           0           2  ...              0.0                    5.5        19           0           2  ...              2.0                    6.5        20           0           2  ...              0.0                    5.5        21           0           2  ...              2.0                    6.5        22           0           2  ...              0.0                    5.5        23           0           2  ...              2.0                    6.5                 gunning_fog      text_standard  fernandez_huerta szigriszt_pazos  \     0           NaN                NaN               NaN             NaN        1           NaN                NaN               NaN             NaN        2           NaN                NaN               NaN             NaN        3           NaN                NaN               NaN             NaN        4           NaN                NaN               NaN             NaN        5           NaN                NaN               NaN             NaN        6          5.20  5th and 6th grade            133.58          131.54        7          8.28  6th and 7th grade            115.58          112.37        8          5.20  5th and 6th grade            133.58          131.54        9          8.28  6th and 7th grade            115.58          112.37        10         5.20  5th and 6th grade            133.58          131.54        11         8.28  6th and 7th grade            115.58          112.37        12          NaN                NaN               NaN             NaN        13          NaN                NaN               NaN             NaN        14          NaN                NaN               NaN             NaN        15          NaN                NaN               NaN             NaN        16          NaN                NaN               NaN             NaN        17          NaN                NaN               NaN             NaN        18         5.20  5th and 6th grade            133.58          131.54        19         8.28  6th and 7th grade            115.58          112.37        20         5.20  5th and 6th grade            133.58          131.54        21         8.28  6th and 7th grade            115.58          112.37        22         5.20  5th and 6th grade            133.58          131.54        23         8.28  6th and 7th grade            115.58          112.37                 gutierrez_polini  crawford  gulpease_index   osman       0                NaN       NaN             NaN     NaN       1                NaN       NaN             NaN     NaN       2                NaN       NaN             NaN     NaN       3                NaN       NaN             NaN     NaN       4                NaN       NaN             NaN     NaN       5                NaN       NaN             NaN     NaN       6              62.30      -0.2            79.8  116.91       7              54.83       1.4            72.1  100.17       8              62.30      -0.2            79.8  116.91       9              54.83       1.4            72.1  100.17       10             62.30      -0.2            79.8  116.91       11             54.83       1.4            72.1  100.17       12               NaN       NaN             NaN     NaN       13               NaN       NaN             NaN     NaN       14               NaN       NaN             NaN     NaN       15               NaN       NaN             NaN     NaN       16               NaN       NaN             NaN     NaN       17               NaN       NaN             NaN     NaN       18             62.30      -0.2            79.8  116.91       19             54.83       1.4            72.1  100.17       20             62.30      -0.2            79.8  116.91       21             54.83       1.4            72.1  100.17       22             62.30      -0.2            79.8  116.91       23             54.83       1.4            72.1  100.17            [24 rows x 39 columns], 'session_analysis':     prompt_step         prompts    name  output_step  \     0             1  Tell me a joke  OpenAI            2        1             1  Tell me a poem  OpenAI


ClearML | 🦜🔗 Langchain

2        2             1  Tell me a joke  OpenAI            2        3             1  Tell me a poem  OpenAI            2        4             1  Tell me a joke  OpenAI            2        5             1  Tell me a poem  OpenAI            2        6             3  Tell me a joke  OpenAI            4        7             3  Tell me a poem  OpenAI            4        8             3  Tell me a joke  OpenAI            4        9             3  Tell me a poem  OpenAI            4        10            3  Tell me a joke  OpenAI            4        11            3  Tell me a poem  OpenAI            4                                                            output  \     0   \n\nQ: What did the fish say when it hit the w...        1   \n\nRoses are red,\nViolets are blue,\nSugar i...        2   \n\nQ: What did the fish say when it hit the w...        3   \n\nRoses are red,\nViolets are blue,\nSugar i...        4   \n\nQ: What did the fish say when it hit the w...        5   \n\nRoses are red,\nViolets are blue,\nSugar i...        6   \n\nQ: What did the fish say when it hit the w...        7   \n\nRoses are red,\nViolets are blue,\nSugar i...        8   \n\nQ: What did the fish say when it hit the w...        9   \n\nRoses are red,\nViolets are blue,\nSugar i...        10  \n\nQ: What did the fish say when it hit the w...        11  \n\nRoses are red,\nViolets are blue,\nSugar i...                 token_usage_total_tokens  token_usage_prompt_tokens  \     0                        162                         24        1                        162                         24        2                        162                         24        3                        162                         24        4                        162                         24        5                        162                         24        6                        162                         24        7                        162                         24        8                        162                         24        9                        162                         24        10                       162                         24        11                       162                         24                 token_usage_completion_tokens  flesch_reading_ease  flesch_kincaid_grade  \     0                             138               109.04                   1.3        1                             138                83.66                   4.8        2                             138               109.04                   1.3        3                             138                83.66                   4.8        4                             138               109.04                   1.3        5                             138                83.66                   4.8        6                             138               109.04                   1.3        7                             138                83.66                   4.8        8                             138               109.04                   1.3        9                             138                83.66                   4.8        10                            138               109.04                   1.3        11                            138                83.66                   4.8                 ...  difficult_words  linsear_write_formula  gunning_fog  \     0   ...                0                    5.5         5.20        1   ...                2                    6.5         8.28        2   ...                0                    5.5         5.20        3   ...                2                    6.5         8.28        4   ...                0                    5.5         5.20        5   ...                2                    6.5         8.28        6   ...                0                    5.5         5.20        7   ...                2                    6.5         8.28        8   ...                0                    5.5         5.20        9   ...                2                    6.5         8.28        10  ...                0                    5.5         5.20        11  ...                2                    6.5         8.28                     text_standard  fernandez_huerta  szigriszt_pazos  gutierrez_polini  \     0   5th and 6th grade            133.58           131.54             62.30        1   6th and 7th grade            115.58           112.37             54.83        2   5th and 6th grade            133.58           131.54             62.30        3   6th and 7th grade            115.58           112.37             54.83        4   5th and 6th grade            133.58           131.54             62.30        5   6th and 7th grade            115.58           112.37             54.83        6   5th and 6th grade            133.58           131.54             62.30        7   6th and 7th grade            115.58           112.37             54.83        8   5th and 6th grade            133.58           131.54             62.30        9   6th and 7th grade            115.58           112.37             54.83        10  5th and 6th grade            133.58           131.54             62.30        11  6th and 7th grade            115.58           112.37             54.83                crawford  gulpease_index   osman       0      -0.2            79.8  116.91       1       1.4            72.1  100.17       2      -0.2            79.8  116.91       3       1.4            72.1  100.17       4      -0.2            79.8  116.91       5       1.4            72.1  100.17       6      -0.2            79.8  116.91       7       1.4            72.1  100.17       8      -0.2            79.8  116.91       9       1.4            72.1  100.17       10     -0.2            79.8  116.91       11      1.4            72.1  100.17            [12 rows x 24 columns]}     2023-03-29 14:00:25,948 - clearml.Task - INFO - Completed model upload to https://files.clear.ml/langchain_callback_demo/ll


ClearML | 🦜🔗 Langchain

m.988bd727b0e94a29a3ac0ee526813545/models/simple_sequential  At this point you can already go to https://app.clear.ml and take a look at the resulting ClearML Task that was created.  Among others, you should see that this notebook is saved along with any git information. The model JSON that contains the used parameters is saved as an artifact, there are also console logs and under the plots section, you'll find tables that represent the flow of the chain.  Finally, if you enabled visualizations, these are stored as HTML files under debug samples.  Scenario 2: Creating an agent with tools To show a more advanced workflow, let's create an agent with access to tools. The way ClearML tracks the results is not different though, only the table will look slightly different as there are other types of actions taken when compared to the earlier, simpler example.  You can now also see the use of the finish=True keyword, which will fully close the ClearML Task, instead of just resetting the parameters and prompts for a new conversation.  from langchain.agents import AgentType, initialize_agent, load_tools  # SCENARIO 2 - Agent with Tools tools = load_tools(["serpapi", "llm-math"], llm=llm, callbacks=callbacks) agent = initialize_agent(     tools,     llm,     agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,     callbacks=callbacks, ) agent.run("Who is the wife of the person who sang summer of 69?") clearml_callback.flush_tracker(     langchain_asset=agent, name="Agent with Tools", finish=True )                > Entering new AgentExecutor chain...     {'action': 'on_chain_start', 'name': 'AgentExecutor', 'step': 1, 'starts': 1, 'ends': 0, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 0, 'llm_ends': 0, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'input': 'Who is the wife of the person who sang summer of 69?'}     {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 2, 'starts': 2, 'ends': 0, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 1, 'llm_ends': 0, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'prompts': 'Answer the following questions as best you can. You have access to the following tools:\n\nSearch: A search engine. Useful for when you need to answer questions about current events. Input should be a search query.\nCalculator: Useful for when you need to answer questions about math.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [Search, Calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is the wife of the person who sang summer of 69?\nThought:'}     {'action': 'on_llm_end', 'token_usage_prompt_tokens': 189, 'token_usage_completion_tokens': 34, 'token_usage_total_tokens': 223, 'model_name': 'text-davinci-003', 'step': 3, 'starts': 2, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 1, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'text': ' I need to find out who sang summer of 69 and then find out who their wife is.\nAction: Search\nAction Input: "Who sang summer of 69"', 'generation_info_finish_reason': 'stop', 'generation_info_logprobs': None, 'flesch_reading_ease': 91.61, 'flesch_kincaid_grade': 3.8, 'smog_index': 0.0, 'coleman_liau_index': 3.41, 'automated_readability_index': 3.5, 'dale_chall_readability_score': 6.06, 'difficult_words': 2, 'linsear_write_formula': 5.75, 'gunning_fog': 5.4, 'text_standard': '3rd and 4th grade', 'fernandez_huerta': 121.07, 'szigriszt_pazos': 119.5, 'gutierrez_polini': 54.91, 'crawford': 0.9, 'gulpease_index': 72.7, 'osman': 92.16}      I need to find out who sang summer of 69 and then find out who their wife is.     Action: Search     Action Input: "Who sang summer of 69"{'action': 'on_agent_action', 'tool': 'Search', 'tool_input': 'Who sang summer of 69', 'log': ' I need to find out who sang summer of 69 and then find out who their wife is.\nAction: Search\nAction Input: "Who sang summer of 69"', 'step': 4, 'starts': 3, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 1, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 1, 'tool_ends': 0, 'agent_ends': 0}     {'action': 'on_tool_start', 'input_str': 'Who sang summer of 69', 'name': 'Search', 'description': 'A search engine. Useful for when you need to answer questions about current events. Input should be a search query.', 'step': 5, 'starts': 4, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 1, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 2, 'tool_ends': 0, 'agent_ends': 0}          Observation: Bryan Adams - Summer Of 69 (Official Music Video).     Thought:{'action': 'on_tool_end', 'output': 'Bryan Adams - Summer Of 69 (Official Music Video).', 'step': 6, 'starts': 4, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 1, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 2, 'tool_ends': 1, 'agent_ends': 0}     {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 7, 'starts': 5, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 2, 'tool_ends': 1, 'agent_ends': 0, 'prompts': 'Answer the following questions as best you can. You have access to the following tools:\n\nSearch: A search engine. Useful for when you need to answer questions about current events. Input should be a search query.\nCalculator: Useful for when you need to answer questions about math.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always t


ClearML | 🦜🔗 Langchain

hink about what to do\nAction: the action to take, should be one of [Search, Calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is the wife of the person who sang summer of 69?\nThought: I need to find out who sang summer of 69 and then find out who their wife is.\nAction: Search\nAction Input: "Who sang summer of 69"\nObservation: Bryan Adams - Summer Of 69 (Official Music Video).\nThought:'}     {'action': 'on_llm_end', 'token_usage_prompt_tokens': 242, 'token_usage_completion_tokens': 28, 'token_usage_total_tokens': 270, 'model_name': 'text-davinci-003', 'step': 8, 'starts': 5, 'ends': 3, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 2, 'tool_ends': 1, 'agent_ends': 0, 'text': ' I need to find out who Bryan Adams is married to.\nAction: Search\nAction Input: "Who is Bryan Adams married to"', 'generation_info_finish_reason': 'stop', 'generation_info_logprobs': None, 'flesch_reading_ease': 94.66, 'flesch_kincaid_grade': 2.7, 'smog_index': 0.0, 'coleman_liau_index': 4.73, 'automated_readability_index': 4.0, 'dale_chall_readability_score': 7.16, 'difficult_words': 2, 'linsear_write_formula': 4.25, 'gunning_fog': 4.2, 'text_standard': '4th and 5th grade', 'fernandez_huerta': 124.13, 'szigriszt_pazos': 119.2, 'gutierrez_polini': 52.26, 'crawford': 0.7, 'gulpease_index': 74.7, 'osman': 84.2}      I need to find out who Bryan Adams is married to.     Action: Search     Action Input: "Who is Bryan Adams married to"{'action': 'on_agent_action', 'tool': 'Search', 'tool_input': 'Who is Bryan Adams married to', 'log': ' I need to find out who Bryan Adams is married to.\nAction: Search\nAction Input: "Who is Bryan Adams married to"', 'step': 9, 'starts': 6, 'ends': 3, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 3, 'tool_ends': 1, 'agent_ends': 0}     {'action': 'on_tool_start', 'input_str': 'Who is Bryan Adams married to', 'name': 'Search', 'description': 'A search engine. Useful for when you need to answer questions about current events. Input should be a search query.', 'step': 10, 'starts': 7, 'ends': 3, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 4, 'tool_ends': 1, 'agent_ends': 0}          Observation: Bryan Adams has never married. In the 1990s, he was in a relationship with Danish model Cecilie Thomsen. In 2011, Bryan and Alicia Grimaldi, his ...     Thought:{'action': 'on_tool_end', 'output': 'Bryan Adams has never married. In the 1990s, he was in a relationship with Danish model Cecilie Thomsen. In 2011, Bryan and Alicia Grimaldi, his ...', 'step': 11, 'starts': 7, 'ends': 4, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 4, 'tool_ends': 2, 'agent_ends': 0}     {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 12, 'starts': 8, 'ends': 4, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 3, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 4, 'tool_ends': 2, 'agent_ends': 0, 'prompts': 'Answer the following questions as best you can. You have access to the following tools:\n\nSearch: A search engine. Useful for when you need to answer questions about current events. Input should be a search query.\nCalculator: Useful for when you need to answer questions about math.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [Search, Calculator]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Who is the wife of the person who sang summer of 69?\nThought: I need to find out who sang summer of 69 and then find out who their wife is.\nAction: Search\nAction Input: "Who sang summer of 69"\nObservation: Bryan Adams - Summer Of 69 (Official Music Video).\nThought: I need to find out who Bryan Adams is married to.\nAction: Search\nAction Input: "Who is Bryan Adams married to"\nObservation: Bryan Adams has never married. In the 1990s, he was in a relationship with Danish model Cecilie Thomsen. In 2011, Bryan and Alicia Grimaldi, his ...\nThought:'}     {'action': 'on_llm_end', 'token_usage_prompt_tokens': 314, 'token_usage_completion_tokens': 18, 'token_usage_total_tokens': 332, 'model_name': 'text-davinci-003', 'step': 13, 'starts': 8, 'ends': 5, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 3, 'llm_ends': 3, 'llm_streams': 0, 'tool_starts': 4, 'tool_ends': 2, 'agent_ends': 0, 'text': ' I now know the final answer.\nFinal Answer: Bryan Adams has never been married.', 'generation_info_finish_reason': 'stop', 'generation_info_logprobs': None, 'flesch_reading_ease': 81.29, 'flesch_kincaid_grade': 3.7, 'smog_index': 0.0, 'coleman_liau_index': 5.75, 'automated_readability_index': 3.9, 'dale_chall_readability_score': 7.37, 'difficult_words': 1, 'linsear_write_formula': 2.5, 'gunning_fog': 2.8, 'text_standard': '3rd and 4th grade', 'fernandez_huerta': 115.7, 'szigriszt_pazos': 110.84, 'gutierrez_polini': 49.79, 'crawford': 0.7, 'gulpease_index': 85.4, 'osman': 83.14}      I now know the final answer.     Final Answer: Bryan Adams has never been married.     {'action': 'on_agent_finish', 'output': 'Bryan Adams has never been married.', 'log': ' I now know the final answer.\nFinal Answer: Bryan Adams has never been married.', 'step': 14, 'starts': 8, '


ClearML | 🦜🔗 Langchain

ends': 6, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 3, 'llm_ends': 3, 'llm_streams': 0, 'tool_starts': 4, 'tool_ends': 2, 'agent_ends': 1}          > Finished chain.     {'action': 'on_chain_end', 'outputs': 'Bryan Adams has never been married.', 'step': 15, 'starts': 8, 'ends': 7, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 1, 'llm_starts': 3, 'llm_ends': 3, 'llm_streams': 0, 'tool_starts': 4, 'tool_ends': 2, 'agent_ends': 1}     {'action_records':              action    name  step  starts  ends  errors  text_ctr  \     0      on_llm_start  OpenAI     1       1     0       0         0        1      on_llm_start  OpenAI     1       1     0       0         0        2      on_llm_start  OpenAI     1       1     0       0         0        3      on_llm_start  OpenAI     1       1     0       0         0        4      on_llm_start  OpenAI     1       1     0       0         0        ..              ...     ...   ...     ...   ...     ...       ...        66      on_tool_end     NaN    11       7     4       0         0        67     on_llm_start  OpenAI    12       8     4       0         0        68       on_llm_end     NaN    13       8     5       0         0        69  on_agent_finish     NaN    14       8     6       0         0        70     on_chain_end     NaN    15       8     7       0         0                 chain_starts  chain_ends  llm_starts  ...  gulpease_index  osman  input  \     0              0           0           1  ...             NaN    NaN    NaN        1              0           0           1  ...             NaN    NaN    NaN        2              0           0           1  ...             NaN    NaN    NaN        3              0           0           1  ...             NaN    NaN    NaN        4              0           0           1  ...             NaN    NaN    NaN        ..           ...         ...         ...  ...             ...    ...    ...        66             1           0           2  ...             NaN    NaN    NaN        67             1           0           3  ...             NaN    NaN    NaN        68             1           0           3  ...            85.4  83.14    NaN        69             1           0           3  ...             NaN    NaN    NaN        70             1           1           3  ...             NaN    NaN    NaN                 tool  tool_input                                                log  \     0    NaN         NaN                                                NaN        1    NaN         NaN                                                NaN        2    NaN         NaN                                                NaN        3    NaN         NaN                                                NaN        4    NaN         NaN                                                NaN        ..   ...         ...                                                ...        66   NaN         NaN                                                NaN        67   NaN         NaN                                                NaN        68   NaN         NaN                                                NaN        69   NaN         NaN   I now know the final answer.\nFinal Answer: B...        70   NaN         NaN                                                NaN                 input_str  description                                             output  \     0         NaN          NaN                                                NaN        1         NaN          NaN                                                NaN        2         NaN          NaN                                                NaN        3         NaN          NaN                                                NaN        4         NaN          NaN                                                NaN        ..        ...          ...                                                ...        66        NaN          NaN  Bryan Adams has never married. In the 1990s, h...        67        NaN          NaN                                                NaN        68        NaN          NaN                                                NaN        69        NaN          NaN                Bryan Adams has never been married.        70        NaN          NaN                                                NaN                                             outputs       0                                   NaN       1                                   NaN       2                                   NaN       3                                   NaN       4                                   NaN       ..                                  ...       66                                  NaN       67                                  NaN       68                                  NaN       69                                  NaN       70  Bryan Adams has never been married.            [71 rows x 47 columns], 'session_analysis':    prompt_step                                            prompts    name  \     0            2  Answer the following questions as best you can...  OpenAI        1            7  Answer the following questions as best you can...  OpenAI        2           12  Answer the following questions as best you can...  OpenAI                output_step                                             output  \     0            3   I need to find out who sang summer of 69 and ...        1            8   I need to find out who Bryan Adams is married...        2           13   I now know the final answer.\nFinal Answer: B...                token_usage_total_tokens  token_usage_prompt_tokens  \     0                       223                        189        1                       270                        242        2                       332                        314                token_usage_completion_tokens  flesch_reading_ease  flesch_kincaid_grade  \     0                             34                91.61


ClearML | 🦜🔗 Langchain

3.8        1                             28                94.66                   2.7        2                             18                81.29                   3.7                ...  difficult_words  linsear_write_formula  gunning_fog  \     0  ...                2                   5.75          5.4        1  ...                2                   4.25          4.2        2  ...                1                   2.50          2.8                    text_standard  fernandez_huerta  szigriszt_pazos  gutierrez_polini  \     0  3rd and 4th grade            121.07           119.50             54.91        1  4th and 5th grade            124.13           119.20             52.26        2  3rd and 4th grade            115.70           110.84             49.79               crawford  gulpease_index  osman       0      0.9            72.7  92.16       1      0.7            74.7  84.20       2      0.7            85.4  83.14            [3 rows x 24 columns]}       Could not update last created model in Task 988bd727b0e94a29a3ac0ee526813545, Task status 'completed' cannot be updated  Tips and Next Steps Make sure you always use a unique name argument for the clearml_callback.flush_tracker function. If not, the model parameters used for a run will override the previous run!  If you close the ClearML Callback using clearml_callback.flush_tracker(..., finish=True) the Callback cannot be used anymore. Make a new one if you want to keep logging.  Check out the rest of the open-source ClearML ecosystem, there is a data version manager, a remote execution agent, automated pipelines and much more!  Previous Clarifai Next ClickHouse Community Discord Twitter GitHub Python JS/TS More Homepage Blog Copyright © 2023 LangChain, Inc.


ClickHouse | 🦜🔗 Langchain

Main:  On this page #ClickHouse [ClickHouse](https://clickhouse.com/) is the fast and resource efficient open-source database for real-time apps and analytics with full SQL support and a wide range of functions to assist users in writing analytical queries. It has data structures and distance search functions (like L2Distance) as well as [approximate nearest neighbor search indexes](https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/annindexes) That enables ClickHouse to be used as a high performance and scalable vector database to store and search vectors with SQL.  ##Installation and Setup[](#installation-and-setup) We need to install clickhouse-connect python package.  pip install clickhouse-connect  ##Vector Store[](#vector-store) See a [usage example](/docs/integrations/vectorstores/clickhouse).  from langchain.vectorstores import Clickhouse, ClickhouseSettings


CnosDB | 🦜🔗 Langchain

Main:  On this page #CnosDB [CnosDB](https://github.com/cnosdb/cnosdb) is an open-source distributed time series database with high performance, high compression rate and high ease of use.  ##Installation and Setup[](#installation-and-setup) pip install cnos-connector  ##Connecting to CnosDB[](#connecting-to-cnosdb) You can connect to CnosDB using the SQLDatabase.from_cnosdb() method.  ###Syntax[](#syntax) def SQLDatabase.from_cnosdb(url: str = "127.0.0.1:8902",                               user: str = "root",                               password: str = "",                               tenant: str = "cnosdb",                               database: str = "public")  Args:  - url (str): The HTTP connection host name and port number of the CnosDB service, excluding "http://" or "https://", with a default value of "127.0.0.1:8902". - user (str): The username used to connect to the CnosDB service, with a default value of "root". - password (str): The password of the user connecting to the CnosDB service, with a default value of "". - tenant (str): The name of the tenant used to connect to the CnosDB service, with a default value of "cnosdb". - database (str): The name of the database in the CnosDB tenant. ##Examples[](#examples) # Connecting to CnosDB with SQLDatabase Wrapper from langchain.utilities import SQLDatabase  db = SQLDatabase.from_cnosdb()  # Creating a OpenAI Chat LLM Wrapper from langchain.chat_models import ChatOpenAI  llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo")  ###SQL Database Chain[](#sql-database-chain) This example demonstrates the use of the SQL Chain for answering a question over a CnosDB.  from langchain.utilities import SQLDatabaseChain  db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True)  db_chain.run(     "What is the average temperature of air at station XiaoMaiDao between October 19, 2022 and Occtober 20, 2022?" )  > Entering new  chain... What is the average temperature of air at station XiaoMaiDao between October 19, 2022 and Occtober 20, 2022? SQLQuery:SELECT AVG(temperature) FROM air WHERE station = 'XiaoMaiDao' AND time >= '2022-10-19' AND time < '2022-10-20' SQLResult: [(68.0,)] Answer:The average temperature of air at station XiaoMaiDao between October 19, 2022 and October 20, 2022 is 68.0. > Finished chain.  ###SQL Database Agent[](#sql-database-agent) This example demonstrates the use of the SQL Database Agent for answering questions over a CnosDB.  from langchain.agents import create_sql_agent from langchain.agents.agent_toolkits import SQLDatabaseToolkit  toolkit = SQLDatabaseToolkit(db=db, llm=llm) agent = create_sql_agent(llm=llm, toolkit=toolkit, verbose=True)  agent.run(     "What is the average temperature of air at station XiaoMaiDao between October 19, 2022 and Occtober 20, 2022?" )  > Entering new  chain... Action: sql_db_list_tables Action Input: "" Observation: air Thought:The "air" table seems relevant to the question. I should query the schema of the "air" table to see what columns are available. Action: sql_db_schema Action Input: "air" Observation: CREATE TABLE air (     pressure FLOAT,     station STRING,     temperature FLOAT,     time TIMESTAMP,     visibility FLOAT )  /* 3 rows from air table: pressure    station temperature time    visibility 75.0    XiaoMaiDao  67.0    2022-10-19T03:40:00 54.0 77.0    XiaoMaiDao  69.0    2022-10-19T04:40:00 56.0 76.0    XiaoMaiDao  68.0    2022-10-19T05:40:00 55.0 */ Thought:The "temperature" column in the "air" table is relevant to the question. I can query the average temperature between the specified dates. Action: sql_db_query Action Input: "SELECT AVG(temperature) FROM air WHERE station = 'XiaoMaiDao' AND time >= '2022-10-19' AND time <= '2022-10-20'" Observation: [(68.0,)] Thought:The average temperature of air at station XiaoMaiDao between October 19, 2022 and October 20, 2022 is 68.0. Final Answer: 68.0  > Finished chain.


Cohere | 🦜🔗 Langchain

Main:  On this page #Cohere [Cohere](https://cohere.ai/about) is a Canadian startup that provides natural language processing models that help companies improve human-machine interactions.  ##Installation and Setup[](#installation-and-setup) - Install the Python SDK : pip install cohere  Get a [Cohere api key](https://dashboard.cohere.ai/) and set it as an environment variable (COHERE_API_KEY)  ##LLM[](#llm) There exists an Cohere LLM wrapper, which you can access with See a [usage example](/docs/integrations/llms/cohere).  from langchain.llms import Cohere  ##Text Embedding Model[](#text-embedding-model) There exists an Cohere Embedding model, which you can access with  from langchain.embeddings import CohereEmbeddings  For a more detailed walkthrough of this, see [this notebook](/docs/integrations/text_embedding/cohere)  ##Retriever[](#retriever) See a [usage example](/docs/integrations/retrievers/cohere-reranker).  from langchain.retrievers.document_compressors import CohereRerank


College Confidential | 🦜🔗 Langchain

Main:  On this page #College Confidential [College Confidential](https://www.collegeconfidential.com/) gives information on 3,800+ colleges and universities.  ##Installation and Setup[](#installation-and-setup) There isn't any special setup for it.  ##Document Loader[](#document-loader) See a [usage example](/docs/integrations/document_loaders/college_confidential).  from langchain.document_loaders import CollegeConfidentialLoader


Comet | 🦜🔗 Langchain

Main:  On this page #Comet   In this guide we will demonstrate how to track your Langchain Experiments, Evaluation Metrics, and LLM Sessions with [Comet](https://www.comet.com/site/?utm_source=langchain&utm_medium=referral&utm_campaign=comet_notebook).  [](https://colab.research.google.com/github/hwchase17/langchain/blob/master/docs/ecosystem/comet_tracking) Example Project: [Comet with LangChain](https://www.comet.com/examples/comet-example-langchain/view/b5ZThK6OFdhKWVSP3fDfRtrNF/panels?utm_source=langchain&utm_medium=referral&utm_campaign=comet_notebook)    ###Install Comet and Dependencies[](#install-comet-and-dependencies) {sys.executable} -m spacy download en_core_web_sm  ###Initialize Comet and Set your Credentials[](#initialize-comet-and-set-your-credentials) You can grab your [Comet API Key here](https://www.comet.com/signup?utm_source=langchain&utm_medium=referral&utm_campaign=comet_notebook) or click the link after initializing Comet  import comet_ml  comet_ml.init(project_name="comet-example-langchain")  ###Set OpenAI and SerpAPI credentials[](#set-openai-and-serpapi-credentials) You will need an [OpenAI API Key](https://platform.openai.com/account/api-keys) and a [SerpAPI API Key](https://serpapi.com/dashboard) to run the following examples  import os  os.environ["OPENAI_API_KEY"] = "..." # os.environ["OPENAI_ORGANIZATION"] = "..." os.environ["SERPAPI_API_KEY"] = "..."  ###Scenario 1: Using just an LLM[](#scenario-1-using-just-an-llm) from langchain.callbacks import CometCallbackHandler, StdOutCallbackHandler from langchain.llms import OpenAI  comet_callback = CometCallbackHandler(     project_name="comet-example-langchain",     complexity_metrics=True,     stream_logs=True,     tags=["llm"],     visualizations=["dep"], ) callbacks = [StdOutCallbackHandler(), comet_callback] llm = OpenAI(temperature=0.9, callbacks=callbacks, verbose=True)  llm_result = llm.generate(["Tell me a joke", "Tell me a poem", "Tell me a fact"] * 3) print("LLM result", llm_result) comet_callback.flush_tracker(llm, finish=True)  ###Scenario 2: Using an LLM in a Chain[](#scenario-2-using-an-llm-in-a-chain) from langchain.callbacks import CometCallbackHandler, StdOutCallbackHandler from langchain.chains import LLMChain from langchain.llms import OpenAI from langchain.prompts import PromptTemplate  comet_callback = CometCallbackHandler(     complexity_metrics=True,     project_name="comet-example-langchain",     stream_logs=True,     tags=["synopsis-chain"], ) callbacks = [StdOutCallbackHandler(), comet_callback] llm = OpenAI(temperature=0.9, callbacks=callbacks)  template = """You are a playwright. Given the title of play, it is your job to write a synopsis for that title. Title: {title} Playwright: This is a synopsis for the above play:""" prompt_template = PromptTemplate(input_variables=["title"], template=template) synopsis_chain = LLMChain(llm=llm, prompt=prompt_template, callbacks=callbacks)  test_prompts = [{"title": "Documentary about Bigfoot in Paris"}] print(synopsis_chain.apply(test_prompts)) comet_callback.flush_tracker(synopsis_chain, finish=True)  ###Scenario 3: Using An Agent with Tools[](#scenario-3-using-an-agent-with-tools) from langchain.agents import initialize_agent, load_tools from langchain.callbacks import CometCallbackHandler, StdOutCallbackHandler from langchain.llms import OpenAI  comet_callback = CometCallbackHandler(     project_name="comet-example-langchain",     complexity_metrics=True,     stream_logs=True,     tags=["agent"], ) callbacks = [StdOutCallbackHandler(), comet_callback] llm = OpenAI(temperature=0.9, callbacks=callbacks)  tools = load_tools(["serpapi", "llm-math"], llm=llm, callbacks=callbacks) agent = initialize_agent(     tools,     llm,     agent="zero-shot-react-description",     callbacks=callbacks,     verbose=True, ) agent.run(     "Who is Leo DiCaprio's girlfriend? What is her current age raised to the 0.43 power?" ) comet_callback.flush_tracker(agent, finish=True)  ###Scenario 4: Using Custom Evaluation Metrics[](#scenario-4-using-custom-evaluation-metrics) The CometCallbackManager also allows you to define and use Custom Evaluation Metrics to assess generated outputs from your model. Let's take a look at how this works.  In the snippet below, we will use the [ROUGE](https://huggingface.co/spaces/evaluate-metric/rouge) metric to evaluate the quality of a generated summary of an input prompt.  %pip install rouge-score  from langchain.callbacks import CometCallbackHandler, StdOutCallbackHandler from langchain.chains import LLMChain from langchain.llms import OpenAI from langchain.prompts import PromptTemplate from rouge_score import rouge_scorer   class Rouge:     def __init__(self, reference):         self.reference = reference         self.scorer = rouge_scorer.RougeScorer(["rougeLsum"], use_stemmer=True)      def compute_metric(self, generation, prompt_idx, gen_idx):         prediction = generation.text         results = self.scorer.score(target=self.reference, prediction=prediction)          return {             "rougeLsum_score": results["rougeLsum"].fmeasure,             "reference": self.reference,         }   reference = """ The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building. It was the first structure to reach a height of 300 metres.  It is now taller than the Chrysler Building in New York City by 5.2 metres (17 ft) Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France . """ rouge_score = Rouge(reference=reference)  template = """Given the following article, it is your job to write a summary. Article: {article} Summary: This is the summary for the above article:""" prompt_template = PromptTemplate(input_variables=["article"], template=template)  comet_callback = CometCallbackHandler(     project_name="comet-example-langchain",     complexity_metrics=False,     stream_logs=True,     tags=["custom_metrics"],     custom_metrics=rouge_score.compute_metric, ) callba


Comet | 🦜🔗 Langchain

cks = [StdOutCallbackHandler(), comet_callback] llm = OpenAI(temperature=0.9)  synopsis_chain = LLMChain(llm=llm, prompt=prompt_template)  test_prompts = [     {         "article": """                  The tower is 324 metres (1,063 ft) tall, about the same height as                  an 81-storey building, and the tallest structure in Paris. Its base is square,                  measuring 125 metres (410 ft) on each side.                  During its construction, the Eiffel Tower surpassed the                  Washington Monument to become the tallest man-made structure in the world,                  a title it held for 41 years until the Chrysler Building                  in New York City was finished in 1930.                   It was the first structure to reach a height of 300 metres.                  Due to the addition of a broadcasting aerial at the top of the tower in 1957,                  it is now taller than the Chrysler Building by 5.2 metres (17 ft).                   Excluding transmitters, the Eiffel Tower is the second tallest                  free-standing structure in France after the Millau Viaduct.                  """     } ] print(synopsis_chain.apply(test_prompts, callbacks=callbacks)) comet_callback.flush_tracker(synopsis_chain, finish=True)


Confident AI | 🦜🔗 Langchain

Main:  On this page #Confident AI   [DeepEval](https://confident-ai.com) package for unit testing LLMs. Using Confident, everyone can build robust language models through faster iterations using both unit testing and integration testing. We provide support for each step in the iteration from synthetic data creation to testing.  ##Installation and Setup[](#installation-and-setup) First, you'll need to install the DeepEval Python package as follows:  pip install deepeval  Afterwards, you can get started in as little as a few lines of code.  from langchain.callbacks import DeepEvalCallback


Confluence | 🦜🔗 Langchain

Main:  On this page #Confluence [Confluence](https://www.atlassian.com/software/confluence) is a wiki collaboration platform that saves and organizes all of the project-related material. Confluence is a knowledge base that primarily handles content management activities.  ##Installation and Setup[](#installation-and-setup) pip install atlassian-python-api  We need to set up username/api_key or Oauth2 login. See [instructions](https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/).  ##Document Loader[](#document-loader) See a [usage example](/docs/integrations/document_loaders/confluence).  from langchain.document_loaders import ConfluenceLoader


C Transformers | 🦜🔗 Langchain

Main:  On this page #C Transformers This page covers how to use the [C Transformers](https://github.com/marella/ctransformers) library within LangChain. It is broken into two parts: installation and setup, and then references to specific C Transformers wrappers.  ##Installation and Setup[](#installation-and-setup) - Install the Python package with pip install ctransformers - Download a supported [GGML model](https://huggingface.co/TheBloke) (see [Supported Models](https://github.com/marella/ctransformers#supported-models)) ##Wrappers[](#wrappers) ###LLM[](#llm) There exists a CTransformers LLM wrapper, which you can access with:  from langchain.llms import CTransformers  It provides a unified interface for all models:  llm = CTransformers(model='/path/to/ggml-gpt-2.bin', model_type='gpt2')  print(llm('AI is going to'))  If you are getting illegal instruction error, try using lib='avx' or lib='basic':  llm = CTransformers(model='/path/to/ggml-gpt-2.bin', model_type='gpt2', lib='avx')  It can be used with models hosted on the Hugging Face Hub:  llm = CTransformers(model='marella/gpt-2-ggml')  If a model repo has multiple model files (.bin files), specify a model file using:  llm = CTransformers(model='marella/gpt-2-ggml', model_file='ggml-model.bin')  Additional parameters can be passed using the config parameter:  config = {'max_new_tokens': 256, 'repetition_penalty': 1.1}  llm = CTransformers(model='marella/gpt-2-ggml', config=config)  See [Documentation](https://github.com/marella/ctransformers#config) for a list of available parameters.  For a more detailed walkthrough of this, see [this notebook](/docs/integrations/llms/ctransformers).


DashVector | 🦜🔗 Langchain

Main:  On this page #DashVector [DashVector](https://help.aliyun.com/document_detail/2510225.html) is a fully-managed vectorDB service that supports high-dimension dense and sparse vectors, real-time insertion and filtered search. It is built to scale automatically and can adapt to different application requirements.  This document demonstrates to leverage DashVector within the LangChain ecosystem. In particular, it shows how to install DashVector, and how to use it as a VectorStore plugin in LangChain. It is broken into two parts: installation and setup, and then references to specific DashVector wrappers.  ##Installation and Setup[](#installation-and-setup) Install the Python SDK:  pip install dashvector  ##VectorStore[](#vectorstore) A DashVector Collection is wrapped as a familiar VectorStore for native usage within LangChain, which allows it to be readily used for various scenarios, such as semantic search or example selection.  You may import the vectorstore by:  from langchain.vectorstores import DashVector  For a detailed walkthrough of the DashVector wrapper, please refer to [this notebook](/docs/integrations/vectorstores/dashvector)