id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
0991de107780-0
.ipynb .pdf Retrieval Question/Answering Contents Chain Type Custom Prompts Return Source Documents Retrieval Question/Answering# This example showcases question answering over an index. from langchain.embeddings.openai import OpenAIEmbeddings from langchain.vectorstores import Chroma from langchain.text_splitter imp...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa.html
0991de107780-1
There are two ways to load different chain types. First, you can specify the chain type argument in the from_chain_type method. This allows you to pass in the name of the chain type you want to use. For example, in the below we change the chain type to map_reduce. qa = RetrievalQA.from_chain_type(llm=OpenAI(), chain_ty...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa.html
0991de107780-2
query = "What did the president say about Ketanji Brown Jackson" qa.run(query) " The president said that Ketanji Brown Jackson is one of the nation's top legal minds, a former top litigator in private practice, a former federal public defender, and from a family of public school educators and police officers. He also s...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa.html
0991de107780-3
Return Source Documents# Additionally, we can return the source documents used to answer the question by specifying an optional parameter when constructing the chain. qa = RetrievalQA.from_chain_type(llm=OpenAI(), chain_type="stuff", retriever=docsearch.as_retriever(), return_source_documents=True) query = "What did th...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa.html
0991de107780-4
Document(page_content='A former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa.html
0991de107780-5
Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa.html
0991de107780-6
Document(page_content='Tonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. \n\nAnd as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. \n\nThat ends on my watch. \n\nMedicare is going to set higher standards ...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa.html
90b69c3b04f6-0
.ipynb .pdf Vector DB Text Generation Contents Prepare Data Set Up Vector DB Set Up LLM Chain with Custom Prompt Generate Text Vector DB Text Generation# This notebook walks through how to use LangChain for text generation over a vector index. This is useful if we want to generate text that is able to draw from a lar...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_text_generation.html
90b69c3b04f6-1
relative_path = markdown_file.relative_to(repo_path) github_url = f"https://github.com/{repo_owner}/{repo_name}/blob/{git_sha}/{relative_path}" yield Document(page_content=f.read(), metadata={"source": github_url}) sources = get_github_docs("yirenlu92", "deno-manual-forked") source_chunk...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_text_generation.html
90b69c3b04f6-2
chain = LLMChain(llm=llm, prompt=PROMPT) Generate Text# Finally, we write a function to apply our inputs to the chain. The function takes an input parameter topic. We find the documents in the vector index that correspond to that topic, and use them as additional context in our simple LLM chain. def generate_blog_post(...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_text_generation.html
90b69c3b04f6-3
[{'text': '\n\nEnvironment variables are a great way to store and access sensitive information in your Deno applications. Deno offers built-in support for environment variables with `Deno.env`, and you can also use a `.env` file to store and access environment variables.\n\nUsing `Deno.env` is simple. It has getter and...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_text_generation.html
90b69c3b04f6-4
into the code. This makes it easier to change settings without having to modify the code.\n\nIn Deno, environment variables can be set in a few different ways. The most common way is to use the `VAR=value` syntax. This will set the environment variable `VAR` to the value `value`. This can be used to set any number of e...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_text_generation.html
90b69c3b04f6-5
to hard-code it into their applications. In Deno, you can access environment variables using the `Deno.env.get()` function.\n\nFor example, if you wanted to access the `HOME` environment variable, you could do so like this:\n\n```js\n// env.js\nDeno.env.get("HOME");\n```\n\nWhen running this code, you\'ll need to grant...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_text_generation.html
90b69c3b04f6-6
variables are an important part of any programming language, and Deno is no exception. Deno is a secure JavaScript and TypeScript runtime built on the V8 JavaScript engine, and it recently added support for environment variables. This feature was added in Deno version 1.6.0, and it is now available for use in Deno appl...
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_text_generation.html
90b69c3b04f6-7
example, if you wanted to set the `FOO` environment variable to `bar`, you would use the following code:\n\n```'}]
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_text_generation.html
90b69c3b04f6-8
previous Retrieval Question Answering with Sources next API Chains Contents Prepare Data Set Up Vector DB Set Up LLM Chain with Custom Prompt Generate Text By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_text_generation.html
23fa040f4e69-0
.ipynb .pdf FLARE Contents Imports Retriever FLARE Chain FLARE# This notebook is an implementation of Forward-Looking Active REtrieval augmented generation (FLARE). Please see the original repo here. The basic idea is: Start answering a question If you start generating tokens the model is uncertain about, look up rel...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-1
min_prob: Any tokens generated with probability below this will be considered uncertain Imports# import os os.environ["SERPER_API_KEY"] = "" import re import numpy as np from langchain.schema import BaseRetriever from langchain.utilities import GoogleSerperAPIWrapper from langchain.embeddings import OpenAIEmbeddings fr...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-2
>>> RESPONSE: > Entering new QuestionGeneratorChain chain... Prompt after formatting: Given a user input and an existing partial response as context, ask a question to which the answer is the given term/entity/phrase: >>> USER INPUT: explain in great detail the difference between the langchain framework and baby agi >...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-3
Baby AGI, on the other hand, is an artificial general intelligence (AGI) platform. It uses a combination of deep learning and reinforcement learning to create an AI system that can learn and adapt to new tasks. Baby AGI is designed to be a general-purpose AI system that can be used for a variety of applications, includ...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-4
>>> USER INPUT: explain in great detail the difference between the langchain framework and baby agi >>> EXISTING PARTIAL RESPONSE: The Langchain Framework is a decentralized platform for natural language processing (NLP) applications. It uses a blockchain-based distributed ledger to store and process data, allowing f...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-5
Baby AGI, on the other hand, is an artificial general intelligence (AGI) platform. It uses a combination of deep learning and reinforcement learning to create an AI system that can learn and adapt to new tasks. Baby AGI is designed to be a general-purpose AI system that can be used for a variety of applications, includ...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-6
>>> USER INPUT: explain in great detail the difference between the langchain framework and baby agi >>> EXISTING PARTIAL RESPONSE: The Langchain Framework is a decentralized platform for natural language processing (NLP) applications. It uses a blockchain-based distributed ledger to store and process data, allowing f...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-7
Baby AGI, on the other hand, is an artificial general intelligence (AGI) platform. It uses a combination of deep learning and reinforcement learning to create an AI system that can learn and adapt to new tasks. Baby AGI is designed to be a general-purpose AI system that can be used for a variety of applications, includ...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-8
>>> CONTEXT: LangChain: Software. LangChain is a software development framework designed to simplify the creation of applications using large language models. LangChain Initial release date: October 2022. LangChain Programming languages: Python and JavaScript. LangChain Developer(s): Harrison Chase. LangChain License: ...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-9
LangChain is a framework for including AI from large language models inside data pipelines and applications. This tutorial provides an overview of what you ... Missing: secure | Must include:secure. Blockchain is the best way to secure the data of the shared community. Utilizing the capabilities of the blockchain nobod...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-10
LangChain is a framework for including AI from large language models inside data pipelines and applications. This tutorial provides an overview of what you ... LangChain is an intuitive framework created to assist in developing applications driven by a language model, such as OpenAI or Hugging Face. This documentation ...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-11
Blockchain is one type of a distributed ledger. Distributed ledgers use independent computers (referred to as nodes) to record, share and ... Missing: Langchain | Must include:Langchain. Blockchain is used in distributed storage software where huge data is broken down into chunks. This is available in encrypted data ac...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-12
LangChain is an intuitive framework created to assist in developing applications driven by a language model, such as OpenAI or Hugging Face. Missing: decentralized | Must include:decentralized. LangChain, created by Harrison Chase, is a Python library that provides out-of-the-box support to build NLP applications using...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-13
LangChain is a powerful tool that can be used to work with Large Language ... If an API key has been provided, create an OpenAI language model instance At its core, LangChain is a framework built around LLMs. We can use it for chatbots, Generative Question-Answering (GQA), summarization, and much more. A tutorial of th...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-14
At its core, LangChain is a framework built around LLMs. We can use it for chatbots, Generative Question-Answering (GQA), summarization, and much more. The core idea of the library is that we can “chain” together different components to create more advanced use cases around LLMs. >>> USER INPUT: explain in great detail...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-15
llm = OpenAI() llm(query) '\n\nThe Langchain framework and Baby AGI are both artificial intelligence (AI) frameworks that are used to create intelligent agents. The Langchain framework is a supervised learning system that is based on the concept of “language chains”. It uses a set of rules to map natural language input...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-16
>>> USER INPUT: how are the origin stories of langchain and bitcoin similar or different? >>> EXISTING PARTIAL RESPONSE: Langchain and Bitcoin have very different origin stories. Bitcoin was created by the mysterious Satoshi Nakamoto in 2008 as a decentralized digital currency. Langchain, on the other hand, was creat...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-17
FINISHED The question to which the answer is the term/entity/phrase " developers as a platform for creating and managing decentralized language learning applications." is: > Finished chain. Generated Questions: ['How would you describe the origin stories of Langchain and Bitcoin in terms of their similarities or differ...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-18
>>> CONTEXT: Bitcoin and Ethereum have many similarities but different long-term visions and limitations. Ethereum changed from proof of work to proof of ... Bitcoin will be around for many years and examining its white paper origins is a great exercise in understanding why. Satoshi Nakamoto's blueprint describes ... B...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
23fa040f4e69-19
At its core, LangChain is a framework built around LLMs. We can use it for chatbots, Generative Question-Answering (GQA), summarization, and much more. The core idea of the library is that we can “chain” together different components to create more advanced use cases around LLMs. >>> USER INPUT: how are the origin stor...
https://python.langchain.com/en/latest/modules/chains/examples/flare.html
a86ecf73effd-0
.ipynb .pdf OpenAPI Chain Contents Load the spec Select the Operation Construct the chain Return raw response Example POST message OpenAPI Chain# This notebook shows an example of using an OpenAPI chain to call an endpoint in natural language, and get back a response in natural language. from langchain.tools import O...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-1
llm, requests=Requests(), verbose=True, return_intermediate_steps=True # Return request and response text ) output = chain("whats the most expensive shirt?") > Entering new OpenAPIEndpointChain chain... > Entering new APIRequesterChain chain... Prompt after formatting: You are a helpful AI Assistant. Plea...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-2
ARGS: ```json {valid json conforming to API_SCHEMA} ``` Example ----- ARGS: ```json {"foo": "bar", "baz": {"qux": "quux"}} ``` The block must be no more than 1 line long, and all arguments must be valid JSON. All string arguments must be wrapped in double quotes. You MUST strictly comply to the types indicated by the p...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-3
You attempted to call an API, which resulted in: API_RESPONSE: {"products":[{"name":"Burberry Check Poplin Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201810981/Clothing/Burberry-Check-Poplin-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$360.00","attributes":["Material:Cotton","Target Grou...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-4
'response_text': '{"products":[{"name":"Burberry Check Poplin Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201810981/Clothing/Burberry-Check-Poplin-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$360.00","attributes":["Material:Cotton","Target Group:Man","Color:Gray,Blue,Beige","Properties:Po...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-5
q: string, /* number of products returned */ size?: number, /* (Optional) Minimum price in local currency for the product searched for. Either explicitly stated by the user or implicitly inferred from a combination of the user's request and the kind of product searched for. */ min_price?: number, /* (Optional) Maxi...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-6
{"products":[{"name":"Burberry Check Poplin Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201810981/Clothing/Burberry-Check-Poplin-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$360.00","attributes":["Material:Cotton","Target Group:Man","Color:Gray,Blue,Beige","Properties:Pockets","Pattern:Ch...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-7
Somerton Check Shirt - Camel","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201112728/Clothing/Burberry-Somerton-Check-Shirt-Camel/?utm_source=openai&ref-site=openai_plugin","price":"$450.00","attributes":["Material:Elastane/Lycra/Spandex,Cotton","Target Group:Man","Color:Beige"]},{"name":"Magellan Outdoors Lag...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-8
> Finished chain. output {'instructions': 'whats the most expensive shirt?',
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-9
'output': '{"products":[{"name":"Burberry Check Poplin Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201810981/Clothing/Burberry-Check-Poplin-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$360.00","attributes":["Material:Cotton","Target Group:Man","Color:Gray,Blue,Beige","Properties:Pockets",...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-10
Somerton Check Shirt - Camel","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201112728/Clothing/Burberry-Somerton-Check-Shirt-Camel/?utm_source=openai&ref-site=openai_plugin","price":"$450.00","attributes":["Material:Elastane/Lycra/Spandex,Cotton","Target Group:Man","Color:Beige"]},{"name":"Magellan Outdoors Lag...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-11
'intermediate_steps': {'request_args': '{"q": "shirt", "max_price": null}',
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-12
'response_text': '{"products":[{"name":"Burberry Check Poplin Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201810981/Clothing/Burberry-Check-Poplin-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$360.00","attributes":["Material:Cotton","Target Group:Man","Color:Gray,Blue,Beige","Properties:Po...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-13
Somerton Check Shirt - Camel","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201112728/Clothing/Burberry-Somerton-Check-Shirt-Camel/?utm_source=openai&ref-site=openai_plugin","price":"$450.00","attributes":["Material:Elastane/Lycra/Spandex,Cotton","Target Group:Man","Color:Beige"]},{"name":"Magellan Outdoors Lag...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-14
Example POST message# For this demo, we will interact with the speak API. spec = OpenAPISpec.from_url("https://api.speak.com/openapi.yaml") Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support. Attempting to load an OpenAPI 3.0.1 ...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-15
learning_language?: string, /* The user's native language. Infer this value from the language the user asked their question in. Always use the full name of the language (e.g. Spanish, French). */ native_language?: string, /* A description of any additional context in the user's question that could affect the explanat...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-16
{"explanation":"<what-to-say language=\"Hindi\" context=\"None\">\nऔर चाय लाओ। (Aur chai lao.) \n</what-to-say>\n\n<alternatives context=\"None\">\n1. \"चाय थोड़ी ज्यादा मिल सकती है?\" *(Chai thodi zyada mil sakti hai? - Polite, asking if more tea is available)*\n2. \"मुझे महसूस हो रहा है कि मुझे कुछ अन्य प्रकार की चाय...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-17
tone, asking for an extra serving of milk or tea powder)*\n</alternatives>\n\n<usage-notes>\nIn India and Indian culture, serving guests with food and beverages holds great importance in hospitality. You will find people always offering drinks like water or tea to their guests as soon as they arrive at their house or o...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-18
an issue or leave feedback](https://speak.com/chatgpt?rid=d4mcapbkopo164pqpbk321oc})*","extra_response_instructions":"Use all information in the API response and fully render all Markdown.\nAlways end your response with a link to report an issue or leave feedback on the plugin."}
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-19
> Entering new APIResponderChain chain... Prompt after formatting: You are a helpful AI assistant trained to answer user queries from API responses. You attempted to call an API, which resulted in:
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-20
API_RESPONSE: {"explanation":"<what-to-say language=\"Hindi\" context=\"None\">\nऔर चाय लाओ। (Aur chai lao.) \n</what-to-say>\n\n<alternatives context=\"None\">\n1. \"चाय थोड़ी ज्यादा मिल सकती है?\" *(Chai thodi zyada mil sakti hai? - Polite, asking if more tea is available)*\n2. \"मुझे महसूस हो रहा है कि मुझे कुछ अन्य...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-21
tone, asking for an extra serving of milk or tea powder)*\n</alternatives>\n\n<usage-notes>\nIn India and Indian culture, serving guests with food and beverages holds great importance in hospitality. You will find people always offering drinks like water or tea to their guests as soon as they arrive at their house or o...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-22
an issue or leave feedback](https://speak.com/chatgpt?rid=d4mcapbkopo164pqpbk321oc})*","extra_response_instructions":"Use all information in the API response and fully render all Markdown.\nAlways end your response with a link to report an issue or leave feedback on the plugin."}
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-23
USER_COMMENT: "How would ask for more tea in Delhi?" If the API_RESPONSE can answer the USER_COMMENT respond with the following markdown json block: Response: ```json {"response": "Concise response to USER_COMMENT based on API_RESPONSE."} ``` Otherwise respond with the following markdown json block: Response Error: ```...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-24
'{"explanation":"<what-to-say language=\\"Hindi\\" context=\\"None\\">\\nऔर चाय लाओ। (Aur chai lao.) \\n</what-to-say>\\n\\n<alternatives context=\\"None\\">\\n1. \\"चाय थोड़ी ज्यादा मिल सकती है?\\" *(Chai thodi zyada mil sakti hai? - Polite, asking if more tea is available)*\\n2. \\"मुझे महसूस हो रहा है कि मुझे कुछ अन...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-25
- Very informal/casual tone, asking for an extra serving of milk or tea powder)*\\n</alternatives>\\n\\n<usage-notes>\\nIn India and Indian culture, serving guests with food and beverages holds great importance in hospitality. You will find people always offering drinks like water or tea to their guests as soon as they...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-26
add a little extra in the quantity of tea as well.)\\n</example-convo>\\n\\n*[Report an issue or leave feedback](https://speak.com/chatgpt?rid=d4mcapbkopo164pqpbk321oc})*","extra_response_instructions":"Use all information in the API response and fully render all Markdown.\\nAlways end your response with a link to repo...
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
a86ecf73effd-27
previous Router Chains: Selecting from multiple prompts with MultiRetrievalQAChain next PAL Contents Load the spec Select the Operation Construct the chain Return raw response Example POST message By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/chains/examples/openapi.html
ebfa2f468e90-0
.ipynb .pdf LLMRequestsChain LLMRequestsChain# Using the request library to get HTML results from a URL and then an LLM to parse results from langchain.llms import OpenAI from langchain.chains import LLMRequestsChain, LLMChain from langchain.prompts import PromptTemplate template = """Between >>> and <<< are the raw se...
https://python.langchain.com/en/latest/modules/chains/examples/llm_requests.html
a1310cdddb40-0
.ipynb .pdf LLM Math LLM Math# This notebook showcases using LLMs and Python REPLs to do complex word math problems. from langchain import OpenAI, LLMMathChain llm = OpenAI(temperature=0) llm_math = LLMMathChain.from_llm(llm, verbose=True) llm_math.run("What is 13 raised to the .3432 power?") > Entering new LLMMathChai...
https://python.langchain.com/en/latest/modules/chains/examples/llm_math.html
103f2f2b4055-0
.ipynb .pdf Router Chains: Selecting from multiple prompts with MultiRetrievalQAChain Router Chains: Selecting from multiple prompts with MultiRetrievalQAChain# This notebook demonstrates how to use the RouterChain paradigm to create a chain that dynamically selects which Retrieval system to use. Specifically we show h...
https://python.langchain.com/en/latest/modules/chains/examples/multi_retrieval_qa_router.html
103f2f2b4055-1
"retriever": sou_retriever }, { "name": "pg essay", "description": "Good for answer quesitons about Paul Graham's essay on his career", "retriever": pg_retriever }, { "name": "personal", "description": "Good for answering questions about me", "retrieve...
https://python.langchain.com/en/latest/modules/chains/examples/multi_retrieval_qa_router.html
103f2f2b4055-2
> Finished chain. Your background is Peruvian. print(chain.run("What year was the Internet created in?")) > Entering new MultiRetrievalQAChain chain... None: {'query': 'What year was the Internet created in?'} > Finished chain. The Internet was created in 1969 through a project called ARPANET, which was funded by the ...
https://python.langchain.com/en/latest/modules/chains/examples/multi_retrieval_qa_router.html
66c566c16780-0
.ipynb .pdf SQL Chain example Contents Use Query Checker Customize Prompt Return Intermediate Steps Choosing how to limit the number of rows returned Adding example rows from each table Custom Table Info SQLDatabaseSequentialChain Using Local Language Models SQL Chain example# This example demonstrates the use of the...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-1
db_chain.run("How many employees are there?") > Entering new SQLDatabaseChain chain... How many employees are there? SQLQuery: /workspace/langchain/langchain/sql_database.py:191: SAWarning: Dialect sqlite+pysqlite does *not* support Decimal objects natively, and SQLAlchemy must convert from floating point - rounding er...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-2
Use the following format: Question: "Question here" SQLQuery: "SQL Query to run" SQLResult: "Result of the SQLQuery" Answer: "Final answer here" Only use the following tables: {table_info} If someone asks for the table foobar, they really mean the employee table. Question: {input}""" PROMPT = PromptTemplate( input_...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-3
Answer:There are 8 employees in the foobar table. > Finished chain. [{'input': 'How many employees are there in the foobar table?\nSQLQuery:SELECT COUNT(*) FROM Employee;\nSQLResult: [(8,)]\nAnswer:', 'top_k': '5', 'dialect': 'sqlite',
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-4
'table_info': '\nCREATE TABLE "Artist" (\n\t"ArtistId" INTEGER NOT NULL, \n\t"Name" NVARCHAR(120), \n\tPRIMARY KEY ("ArtistId")\n)\n\n/*\n3 rows from Artist table:\nArtistId\tName\n1\tAC/DC\n2\tAccept\n3\tAerosmith\n*/\n\n\nCREATE TABLE "Employee" (\n\t"EmployeeId" INTEGER NOT NULL, \n\t"LastName" NVARCHAR(20) NOT NULL...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-5
Manager\tNone\t1962-02-18 00:00:00\t2002-08-14 00:00:00\t11120 Jasper Ave NW\tEdmonton\tAB\tCanada\tT5K 2N1\t+1 (780) 428-9482\t+1 (780) 428-3457\tandrew@chinookcorp.com\n2\tEdwards\tNancy\tSales Manager\t1\t1958-12-08 00:00:00\t2002-05-01 00:00:00\t825 8 Ave SW\tCalgary\tAB\tCanada\tT2P 2T3\t+1 (403) 262-3443\t+1 (403...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-6
TABLE "MediaType" (\n\t"MediaTypeId" INTEGER NOT NULL, \n\t"Name" NVARCHAR(120), \n\tPRIMARY KEY ("MediaTypeId")\n)\n\n/*\n3 rows from MediaType table:\nMediaTypeId\tName\n1\tMPEG audio file\n2\tProtected AAC audio file\n3\tProtected MPEG-4 video file\n*/\n\n\nCREATE TABLE "Playlist" (\n\t"PlaylistId" INTEGER NOT NULL,...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-7
NVARCHAR(40) NOT NULL, \n\t"LastName" NVARCHAR(20) NOT NULL, \n\t"Company" NVARCHAR(80), \n\t"Address" NVARCHAR(70), \n\t"City" NVARCHAR(40), \n\t"State" NVARCHAR(40), \n\t"Country" NVARCHAR(40), \n\t"PostalCode" NVARCHAR(10), \n\t"Phone" NVARCHAR(24), \n\t"Fax" NVARCHAR(24), \n\t"Email" NVARCHAR(60) NOT NULL, \n\t"Sup...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-8
34\tStuttgart\tNone\tGermany\t70174\t+49 0711 2842222\tNone\tleonekohler@surfeu.de\t5\n3\tFrançois\tTremblay\tNone\t1498 rue Bélanger\tMontréal\tQC\tCanada\tH2G 1A7\t+1 (514) 721-4711\tNone\tftremblay@gmail.com\t3\n*/\n\n\nCREATE TABLE "Invoice" (\n\t"InvoiceId" INTEGER NOT NULL, \n\t"CustomerId" INTEGER NOT NULL, \n\t...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-9
00:00:00\tUllevålsveien 14\tOslo\tNone\tNorway\t0171\t3.96\n3\t8\t2009-01-03 00:00:00\tGrétrystraat 63\tBrussels\tNone\tBelgium\t1000\t5.94\n*/\n\n\nCREATE TABLE "Track" (\n\t"TrackId" INTEGER NOT NULL, \n\t"Name" NVARCHAR(200) NOT NULL, \n\t"AlbumId" INTEGER, \n\t"MediaTypeId" INTEGER NOT NULL, \n\t"GenreId" INTEGER, ...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-10
to the Wall\t2\t2\t1\tNone\t342562\t5510424\t0.99\n3\tFast As a Shark\t3\t2\t1\tF. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman\t230619\t3990994\t0.99\n*/\n\n\nCREATE TABLE "InvoiceLine" (\n\t"InvoiceLineId" INTEGER NOT NULL, \n\t"InvoiceId" INTEGER NOT NULL, \n\t"TrackId" INTEGER NOT NULL, \n\t"UnitPrice" NUMERIC(...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-11
\n\tFOREIGN KEY("PlaylistId") REFERENCES "Playlist" ("PlaylistId")\n)\n\n/*\n3 rows from PlaylistTrack table:\nPlaylistId\tTrackId\n1\t3402\n1\t3389\n1\t3390\n*/',
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-12
'stop': ['\nSQLResult:']}, 'SELECT COUNT(*) FROM Employee;', {'query': 'SELECT COUNT(*) FROM Employee;', 'dialect': 'sqlite'}, 'SELECT COUNT(*) FROM Employee;', '[(8,)]'] Choosing how to limit the number of rows returned# If you are querying for several rows of a table you can select the maximum number of results y...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-13
> Finished chain. 'Examples of tracks by Johann Sebastian Bach are Concerto for 2 Violins in D Minor, BWV 1043: I. Vivace, Aria Mit 30 Veränderungen, BWV 988 "Goldberg Variations": Aria, and Suite for Solo Cello No. 1 in G Major, BWV 1007: I. Prélude.' Adding example rows from each table# Sometimes, the format of the d...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-14
FOREIGN KEY("GenreId") REFERENCES "Genre" ("GenreId"), FOREIGN KEY("AlbumId") REFERENCES "Album" ("AlbumId") ) /* 2 rows from Track table: TrackId Name AlbumId MediaTypeId GenreId Composer Milliseconds Bytes UnitPrice 1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 111...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-15
Answer:Tracks by Bach include 'American Woman', 'Concerto for 2 Violins in D Minor, BWV 1043: I. Vivace', 'Aria Mit 30 Veränderungen, BWV 988 "Goldberg Variations": Aria', 'Suite for Solo Cello No. 1 in G Major, BWV 1007: I. Prélude', and 'Toccata and Fugue in D Minor, BWV 565: I. Toccata'. > Finished chain. 'Tracks by...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-16
"Track": """CREATE TABLE Track ( "TrackId" INTEGER NOT NULL, "Name" NVARCHAR(200) NOT NULL, "Composer" NVARCHAR(220), PRIMARY KEY ("TrackId") ) /* 3 rows from Track table: TrackId Name Composer 1 For Those About To Rock (We Salute You) Angus Young, Malcolm Young, Brian Johnson 2 Balls to the Wall None 3 My favorit...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-17
db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True) db_chain.run("What are some example tracks by Bach?") > Entering new SQLDatabaseChain chain... What are some example tracks by Bach? SQLQuery:SELECT "Name" FROM Track WHERE "Composer" LIKE '%Bach%' LIMIT 5; SQLResult: [('American Woman',), ('Concerto for 2 Vio...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-18
Answer:text='You are a SQLite expert. Given an input question, first create a syntactically correct SQLite query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most 5 results usin...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-19
use the following tables:\n\nCREATE TABLE "Playlist" (\n\t"PlaylistId" INTEGER NOT NULL, \n\t"Name" NVARCHAR(120), \n\tPRIMARY KEY ("PlaylistId")\n)\n\n/*\n2 rows from Playlist table:\nPlaylistId\tName\n1\tMusic\n2\tMovies\n*/\n\nCREATE TABLE Track (\n\t"TrackId" INTEGER NOT NULL, \n\t"Name" NVARCHAR(200) NOT NULL,\n\t...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-20
(\'Suite for Solo Cello No. 1 in G Major, BWV 1007: I. Prélude\',), (\'Toccata and Fugue in D Minor, BWV 565: I. Toccata\',)]\nAnswer:'
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-21
You are a SQLite expert. Given an input question, first create a syntactically correct SQLite query to run, then look at the results of the query and return the answer to the input question. Unless the user specifies in the question a specific number of examples to obtain, query for at most 5 results using the LIMIT cl...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-22
*/ Question: What are some example tracks by Bach? SQLQuery:SELECT "Name" FROM Track WHERE "Composer" LIKE '%Bach%' LIMIT 5; SQLResult: [('American Woman',), ('Concerto for 2 Violins in D Minor, BWV 1043: I. Vivace',), ('Aria Mit 30 Veränderungen, BWV 988 "Goldberg Variations": Aria',), ('Suite for Solo Cello No. 1 in ...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-23
Answer: {'input': 'What are some example tracks by Bach?\nSQLQuery:SELECT "Name" FROM Track WHERE "Composer" LIKE \'%Bach%\' LIMIT 5;\nSQLResult: [(\'American Woman\',), (\'Concerto for 2 Violins in D Minor, BWV 1043: I. Vivace\',), (\'Aria Mit 30 Veränderungen, BWV 988 "Goldberg Variations": Aria\',), (\'Suite for Sol...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-24
Examples of tracks by Bach include "American Woman", "Concerto for 2 Violins in D Minor, BWV 1043: I. Vivace", "Aria Mit 30 Veränderungen, BWV 988 'Goldberg Variations': Aria", "Suite for Solo Cello No. 1 in G Major, BWV 1007: I. Prélude", and "Toccata and Fugue in D Minor, BWV 565: I. Toccata". > Finished chain. 'Exam...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-25
> Entering new SQLDatabaseChain chain... How many employees are also customers? SQLQuery:SELECT COUNT(*) FROM Employee e INNER JOIN Customer c ON e.EmployeeId = c.SupportRepId; SQLResult: [(59,)] Answer:59 employees are also customers. > Finished chain. > Finished chain. '59 employees are also customers.' Using Local L...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-26
local_llm = HuggingFacePipeline(pipeline=pipe) /workspace/langchain/.venv/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html from .autonotebook import tqdm as notebook_tqdm Loading check...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-27
SELECT count(*) FROM Customer SQLResult: [(59,)] Answer: /workspace/langchain/.venv/lib/python3.9/site-packages/transformers/pipelines/base.py:1070: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset warnings.warn( [59] > Finished chain. {'query':...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-28
'table_info': '\nCREATE TABLE "Customer" (\n\t"CustomerId" INTEGER NOT NULL, \n\t"FirstName" NVARCHAR(40) NOT NULL, \n\t"LastName" NVARCHAR(20) NOT NULL, \n\t"Company" NVARCHAR(80), \n\t"Address" NVARCHAR(70), \n\t"City" NVARCHAR(40), \n\t"State" NVARCHAR(40), \n\t"Country" NVARCHAR(40), \n\t"PostalCode" NVARCHAR(10), ...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-29
(12) 3923-5555\t+55 (12) 3923-5566\tluisg@embraer.com.br\t3\n2\tLeonie\tKöhler\tNone\tTheodor-Heuss-Straße 34\tStuttgart\tNone\tGermany\t70174\t+49 0711 2842222\tNone\tleonekohler@surfeu.de\t5\n3\tFrançois\tTremblay\tNone\t1498 rue Bélanger\tMontréal\tQC\tCanada\tH2G 1A7\t+1 (514) 721-4711\tNone\tftremblay@gmail.com\t3...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html
66c566c16780-30
'stop': ['\nSQLResult:']}, 'SELECT count(*) FROM Customer', {'query': 'SELECT count(*) FROM Customer', 'dialect': 'sqlite'}, 'SELECT count(*) FROM Customer', '[(59,)]']} Even this relatively large model will most likely fail to generate more complicated SQL by itself. However, you can log its inputs and outputs...
https://python.langchain.com/en/latest/modules/chains/examples/sqlite.html