id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
11c6ce7261b2-1
"best_of": 1, "request_timeout": null, "logit_bias": {}, "_type": "openai" }, "output_key": "text", "_type": "llm_chain" } Loading a chain from disk# We can load a chain from disk by using the load_chain method. from langchain.chains import load_chain chain = load_chain("llm_chain.js...
https://python.langchain.com/en/latest/modules/chains/generic/serialization.html
11c6ce7261b2-2
"top_p": 1, "frequency_penalty": 0, "presence_penalty": 0, "n": 1, "best_of": 1, "request_timeout": null, "logit_bias": {}, "_type": "openai" } config = { "memory": None, "verbose": True, "prompt_path": "prompt.json", "llm_path": "llm.json", "output_key": "text", "_ty...
https://python.langchain.com/en/latest/modules/chains/generic/serialization.html
163fc9464528-0
.ipynb .pdf Loading from LangChainHub Loading from LangChainHub# This notebook covers how to load chains from LangChainHub. from langchain.chains import load_chain chain = load_chain("lc://chains/llm-math/chain.json") chain.run("whats 2 raised to .12") > Entering new LLMMathChain chain... whats 2 raised to .12 Answer: ...
https://python.langchain.com/en/latest/modules/chains/generic/from_hub.html
163fc9464528-1
query = "What did the president say about Ketanji Brown Jackson" chain.run(query) " The president said that Ketanji Brown Jackson is a Circuit Court of Appeals Judge, one of the nation's top legal minds, a former top litigator in private practice, a former federal public defender, has received a broad range of support ...
https://python.langchain.com/en/latest/modules/chains/generic/from_hub.html
cb4225176094-0
.ipynb .pdf Router Chains Contents LLMRouterChain EmbeddingRouterChain Router Chains# This notebook demonstrates how to use the RouterChain paradigm to create a chain that dynamically selects the next chain to use for a given input. Router chains are made up of two components: The RouterChain itself (responsible for ...
https://python.langchain.com/en/latest/modules/chains/generic/router.html
cb4225176094-1
"description": "Good for answering math questions", "prompt_template": math_template } ] llm = OpenAI() destination_chains = {} for p_info in prompt_infos: name = p_info["name"] prompt_template = p_info["prompt_template"] prompt = PromptTemplate(template=prompt_template, input_variables=["input...
https://python.langchain.com/en/latest/modules/chains/generic/router.html
cb4225176094-2
physics: {'input': 'What is black body radiation?'} > Finished chain. Black body radiation is the term used to describe the electromagnetic radiation emitted by a “black body”—an object that absorbs all radiation incident upon it. A black body is an idealized physical body that absorbs all incident electromagnetic radi...
https://python.langchain.com/en/latest/modules/chains/generic/router.html
cb4225176094-3
("math", ["for questions about math"]), ] router_chain = EmbeddingRouterChain.from_names_and_descriptions( names_and_descriptions, Chroma, CohereEmbeddings(), routing_keys=["input"] ) Using embedded DuckDB without persistence: data will be transient chain = MultiPromptChain(router_chain=router_chain, destination_ch...
https://python.langchain.com/en/latest/modules/chains/generic/router.html
80a590ff2c58-0
.ipynb .pdf Router Chains: Selecting from multiple prompts with MultiPromptChain Router Chains: Selecting from multiple prompts with MultiPromptChain# This notebook demonstrates how to use the RouterChain paradigm to create a chain that dynamically selects the prompt to use for a given input. Specifically we show how t...
https://python.langchain.com/en/latest/modules/chains/examples/multi_prompt_router.html
80a590ff2c58-1
physics: {'input': 'What is black body radiation?'} > Finished chain. Black body radiation is the emission of electromagnetic radiation from a body due to its temperature. It is a type of thermal radiation that is emitted from the surface of all objects that are at a temperature above absolute zero. It is a spectrum of...
https://python.langchain.com/en/latest/modules/chains/examples/multi_prompt_router.html
80a590ff2c58-2
> Finished chain. The type of cloud that typically produces rain is called a cumulonimbus cloud. This type of cloud is characterized by its large vertical extent and can produce thunderstorms and heavy precipitation. Is there anything else you'd like to know? previous Moderation next Router Chains: Selecting from multi...
https://python.langchain.com/en/latest/modules/chains/examples/multi_prompt_router.html
59a7fd32bd24-0
.ipynb .pdf LLMCheckerChain LLMCheckerChain# This notebook showcases how to use LLMCheckerChain. from langchain.chains import LLMCheckerChain from langchain.llms import OpenAI llm = OpenAI(temperature=0.7) text = "What type of mammal lays the biggest eggs?" checker_chain = LLMCheckerChain.from_llm(llm, verbose=True) ch...
https://python.langchain.com/en/latest/modules/chains/examples/llm_checker.html
a77f6da1978b-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
a77f6da1978b-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
a77f6da1978b-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
cd2cb37adf35-0
.ipynb .pdf Self-Critique Chain with Constitutional AI Contents UnifiedObjective Custom Principles Intermediate Steps No revision necessary All Principles Self-Critique Chain with Constitutional AI# This notebook showcases how to use the ConstitutionalChain. Sometimes LLMs can produce harmful, toxic, or otherwise und...
https://python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
cd2cb37adf35-1
Updated response: It is illegal and unethical to steal kittens. If you are looking to adopt a kitten, please contact your local animal shelter or pet store. > Finished chain. 'It is illegal and unethical to steal kittens. If you are looking to adopt a kitten, please contact your local animal shelter or pet store.' Unif...
https://python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
cd2cb37adf35-2
qa_chain = LLMChain(llm=llm, prompt=qa_prompt) query = "should I eat oreos?" qa_chain.run(question=query) ' Yes' principles = ConstitutionalChain.get_principles(["uo-implications-1"]) constitutional_chain = ConstitutionalChain.from_llm( chain=qa_chain, constitutional_principles=principles, llm=llm, verb...
https://python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
cd2cb37adf35-3
) constitutional_chain = ConstitutionalChain.from_llm( chain=evil_qa_chain, constitutional_principles=[ethical_principle], llm=llm, verbose=True, ) constitutional_chain.run(question="How can I steal kittens?") > Entering new ConstitutionalChain chain... Initial response: Break into a pet store at night...
https://python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
cd2cb37adf35-4
Applying Ethical Principle... Critique: The model should not have suggested breaking into a pet store to steal kittens, as this is illegal and unethical. Critique Needed. Updated response: If you are looking to adopt a kitten, please contact your local animal shelter or pet store. Applying Master Yoda Principle... Crit...
https://python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
cd2cb37adf35-5
'initial_output': ' Break into a pet store at night and take as many kittens as you can carry.', 'critiques_and_revisions': [('The model should not have suggested breaking into a pet store to steal kittens, as this is illegal and unethical. Critique Needed.', 'If you are looking to adopt a kitten, please contact yo...
https://python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
cd2cb37adf35-6
'initial_output': ' Stealing kittens is illegal and unethical. If you are looking to adopt a kitten, please contact your local animal shelter or rescue organization.', 'critiques_and_revisions': [("The model's response was appropriate and ethical, as it did not condone or encourage the illegal act of stealing kittens....
https://python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
cd2cb37adf35-7
'harmful4': ConstitutionalPrinciple(critique_request='Identify specific ways in which the assistant’s precedings response is harmful. Also point out potential harmfulness in the human’s questions and responses. Examples of harm include but are not limited to racism, sexism, toxicity.', revision_request='Rewrite the ass...
https://python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
cd2cb37adf35-8
'age-innappropriate': ConstitutionalPrinciple(critique_request='Did the assistant’s preceding response include anything that may be inappropriate for young children? If so, discuss how it can be revised to be more appropriate.', revision_request='Please rewrite the assistant response to make it more age appropriate for...
https://python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
cd2cb37adf35-9
'thoughtful': ConstitutionalPrinciple(critique_request='Please comment on whether the assistant’s last response is thoughtful and empathetic. Does it seem like the kind of thing a sensitive friend or therapist might say? Give the strongest argument you can for how it could improve.', revision_request='Please write a ne...
https://python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
cd2cb37adf35-10
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/chains/examples/constitutional_chain.html
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
702a563d1bc3-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
a3841a48528f-0
.ipynb .pdf GraphCypherQAChain Contents Seeding the database Refresh graph schema information Querying the graph GraphCypherQAChain# This notebook shows how to use LLMs to provide a natural language interface to a graph database you can query with the Cypher query language. You will need to have a running Neo4j insta...
https://python.langchain.com/en/latest/modules/chains/examples/graph_cypher_qa.html
a3841a48528f-1
""" MERGE (m:Movie {name:"Top Gun"}) WITH m UNWIND ["Tom Cruise", "Val Kilmer", "Anthony Edwards", "Meg Ryan"] AS actor MERGE (a:Actor {name:actor}) MERGE (a)-[:ACTED_IN]->(m) """ ) [] Refresh graph schema information# If the schema of database changes, you can refresh the schema information needed to generate Cypher s...
https://python.langchain.com/en/latest/modules/chains/examples/graph_cypher_qa.html
a3841a48528f-2
next BashChain Contents Seeding the database Refresh graph schema information Querying the graph By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/chains/examples/graph_cypher_qa.html
927f5d19be24-0
.ipynb .pdf LLMSummarizationCheckerChain LLMSummarizationCheckerChain# This notebook shows some examples of LLMSummarizationCheckerChain in use with different types of texts. It has a few distinct differences from the LLMCheckerChain, in that it doesn’t have any assumptions to the format of the input text (or summary)...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-1
These discoveries can spark a child's imagination about the infinite wonders of the universe.""" checker_chain.run(text) > Entering new LLMSummarizationCheckerChain chain... > Entering new SequentialChain chain... > Entering new LLMChain chain... Prompt after formatting: Given some text, extract a list of facts from th...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-2
• These distant worlds are called "exoplanets." """ For each fact, determine whether it is true or false about the subject. If you are unable to determine whether the fact is true or false, output "Undetermined". If the fact is false, explain why. > Finished chain. > Entering new LLMChain chain... Prompt after formatti...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-3
""" Using these checked assertions, rewrite the original summary to be completely true. The output should have the same structure and formatting as the original summary. Summary: > Finished chain. > Entering new LLMChain chain... Prompt after formatting: Below are some assertions that have been fact checked and are lab...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-4
• In 2023, The JWST spotted a number of galaxies nicknamed "green peas." They were given this name because they are small, round, and green, like peas. • The telescope captured images of galaxies that are over 13 billion years old. This means that the light from these galaxies has been traveling for over 13 billion yea...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-5
> Finished chain. > Entering new LLMChain chain... Prompt after formatting: You are an expert fact checker. You have been hired by a major news organization to fact check a very important story. Here is a bullet point list of facts: """ • The James Webb Space Telescope (JWST) spotted a number of galaxies nicknamed "gre...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-6
• Exoplanets were first discovered in 1992. - True • The JWST has allowed us to see exoplanets in greater detail. - Undetermined. The JWST has not yet been launched, so it is not yet known how much detail it will be able to provide. """ Original Summary: """ Your 9-year old might like these recent discoveries made by ...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-7
""" Result: False === Checked Assertions: """ - The sky is blue: True - Water is wet: True - The sun is a star: True """ Result: True === Checked Assertions: """ - The sky is blue - True - Water is made of lava- False - The sun is a star - True """ Result: False === Checked Assertions:""" • The James Webb Space Telesco...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-8
• Exoplanets, which are planets outside of our own solar system, were first discovered in 1992. The JWST will allow us to see them in greater detail when it is launched in 2023. These discoveries can spark a child's imagination about the infinite wonders of the universe. > Finished chain. 'Your 9-year old might like th...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-9
text = "The Greenland Sea is an outlying portion of the Arctic Ocean located between Iceland, Norway, the Svalbard archipelago and Greenland. It has an area of 465,000 square miles and is one of five oceans in the world, alongside the Pacific Ocean, Atlantic Ocean, Indian Ocean, and the Southern Ocean. It is the smalle...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-10
> Finished chain. > Entering new LLMChain chain... Prompt after formatting: You are an expert fact checker. You have been hired by a major news organization to fact check a very important story. Here is a bullet point list of facts: """ - The Greenland Sea is an outlying portion of the Arctic Ocean located between Icel...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-11
- It has an area of 465,000 square miles. True - It is one of five oceans in the world, alongside the Pacific Ocean, Atlantic Ocean, Indian Ocean, and the Southern Ocean. False - The Greenland Sea is not an ocean, it is an arm of the Arctic Ocean. - It is the smallest of the five oceans. False - The Greenland Sea is no...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-12
Below are some assertions that have been fact checked and are labeled as true or false. If all of the assertions are true, return "True". If any of the assertions are false, return "False". Here are some examples: === Checked Assertions: """ - The sky is red: False - Water is made of lava: False - The sun is a star: Tr...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-13
""" Result: > Finished chain. > Finished chain. The Greenland Sea is an outlying portion of the Arctic Ocean located between Iceland, Norway, the Svalbard archipelago and Greenland. It has an area of 465,000 square miles and is an arm of the Arctic Ocean. It is covered almost entirely by water, some of which is frozen ...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-14
- It has an area of 465,000 square miles. - It is an arm of the Arctic Ocean. - It is covered almost entirely by water, some of which is frozen in the form of glaciers and icebergs. - It is named after the island of Greenland. - It is the Arctic Ocean's main outlet to the Atlantic. - It is often frozen over so navigati...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-15
""" Original Summary: """ The Greenland Sea is an outlying portion of the Arctic Ocean located between Iceland, Norway, the Svalbard archipelago and Greenland. It has an area of 465,000 square miles and is an arm of the Arctic Ocean. It is covered almost entirely by water, some of which is frozen in the form of glacier...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-16
- It has an area of 465,000 square miles. True - It is an arm of the Arctic Ocean. True - It is covered almost entirely by water, some of which is frozen in the form of glaciers and icebergs. True - It is named after the island of Greenland. False - It is named after the country of Greenland. - It is the Arctic Ocean's...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-17
Format your output as a bulleted list. Text: """ The Greenland Sea is an outlying portion of the Arctic Ocean located between Iceland, Norway, the Svalbard archipelago and Greenland. It has an area of 465,000 square miles and is an arm of the Arctic Ocean. It is covered almost entirely by water, some of which is frozen...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-18
> Finished chain. > Entering new LLMChain chain... Prompt after formatting: Below are some assertions that have been fact checked and are labeled as true of false. If the answer is false, a suggestion is given for a correction. Checked Assertions: """ - The Greenland Sea is an outlying portion of the Arctic Ocean loca...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-19
> Finished chain. > Entering new LLMChain chain... Prompt after formatting: Below are some assertions that have been fact checked and are labeled as true or false. If all of the assertions are true, return "True". If any of the assertions are false, return "False". Here are some examples: === Checked Assertions: """ - ...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-20
""" Result: > Finished chain. > Finished chain. The Greenland Sea is an outlying portion of the Arctic Ocean located between Iceland, Norway, the Svalbard archipelago and Greenland. It has an area of 465,000 square miles and is covered almost entirely by water, some of which is frozen in the form of glaciers and iceber...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-21
Format your output as a bulleted list. Text: """ Mammals can lay eggs, birds can lay eggs, therefore birds are mammals. """ Facts: > Finished chain. > Entering new LLMChain chain... Prompt after formatting: You are an expert fact checker. You have been hired by a major news organization to fact check a very important s...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-22
Below are some assertions that have been fact checked and are labeled as true or false. If all of the assertions are true, return "True". If any of the assertions are false, return "False". Here are some examples: === Checked Assertions: """ - The sky is red: False - Water is made of lava: False - The sun is a star: Tr...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-23
> Finished chain. > Entering new LLMChain chain... Prompt after formatting: You are an expert fact checker. You have been hired by a major news organization to fact check a very important story. Here is a bullet point list of facts: """ - Birds and mammals are both capable of laying eggs. - Birds are not mammals. - Bir...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
927f5d19be24-24
Here are some examples: === Checked Assertions: """ - The sky is red: False - Water is made of lava: False - The sun is a star: True """ Result: False === Checked Assertions: """ - The sky is blue: True - Water is wet: True - The sun is a star: True """ Result: True === Checked Assertions: """ - The sky is blue - True ...
https://python.langchain.com/en/latest/modules/chains/examples/llm_summarization_checker.html
a37440782317-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
7e8fb1c3c07e-0
.ipynb .pdf Moderation Contents How to use the moderation chain How to append a Moderation chain to an LLMChain Moderation# This notebook walks through examples of how to use a moderation chain, and several common ways for doing so. Moderation chains are useful for detecting text that could be hateful, violent, etc. ...
https://python.langchain.com/en/latest/modules/chains/examples/moderation.html
7e8fb1c3c07e-1
'This is okay' moderation_chain.run("I will kill you") "Text was found that violates OpenAI's content policy." Here’s an example of using the moderation chain to throw an error. moderation_chain_error = OpenAIModerationChain(error=True) moderation_chain_error.run("This is okay") 'This is okay' moderation_chain_error.ru...
https://python.langchain.com/en/latest/modules/chains/examples/moderation.html
7e8fb1c3c07e-2
79 text = inputs[self.input_key] 80 results = self.client.create(text) ---> 81 output = self._moderate(text, results["results"][0]) 82 return {self.output_key: output} File ~/workplace/langchain/langchain/chains/moderation.py:73, in OpenAIModerationChain._moderate(self, text, results) 71 error_str = "Tex...
https://python.langchain.com/en/latest/modules/chains/examples/moderation.html
7e8fb1c3c07e-3
prompt = PromptTemplate(template="{text}", input_variables=["text"]) llm_chain = LLMChain(llm=OpenAI(temperature=0, model_name="text-davinci-002"), prompt=prompt) text = """We are playing a game of repeat after me. Person 1: Hi Person 2: Hi Person 1: How's your day Person 2: How's your day Person 1: I will kill you Per...
https://python.langchain.com/en/latest/modules/chains/examples/moderation.html
7e8fb1c3c07e-4
chain(inputs, return_only_outputs=True) {'sanitized_text': "Text was found that violates OpenAI's content policy."} previous LLMSummarizationCheckerChain next Router Chains: Selecting from multiple prompts with MultiPromptChain Contents How to use the moderation chain How to append a Moderation chain to an LLMChain...
https://python.langchain.com/en/latest/modules/chains/examples/moderation.html
dd92ad12c823-0
.ipynb .pdf API Chains Contents OpenMeteo Example TMDB Example Listen API Example API Chains# This notebook showcases using LLMs to interact with APIs to retrieve relevant information. from langchain.chains.api.prompt import API_RESPONSE_PROMPT from langchain.chains import APIChain from langchain.prompts.prompt impor...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-1
from langchain.chains.api import tmdb_docs headers = {"Authorization": f"Bearer {os.environ['TMDB_BEARER_TOKEN']}"} chain = APIChain.from_llm_and_api_docs(llm, tmdb_docs.TMDB_DOCS, headers=headers, verbose=True) chain.run("Search for 'Avatar'") > Entering new APIChain chain... https://api.themoviedb.org/3/search/movie...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-2
{"page":1,"results":[{"adult":false,"backdrop_path":"/o0s4XsEDfDlvit5pDRKjzXR4pp2.jpg","genre_ids":[28,12,14,878],"id":19995,"original_language":"en","original_title":"Avatar","overview":"In the 22nd century, a paraplegic Marine is dispatched to the moon Pandora on a unique mission, but becomes torn between following o...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-3
they fight to stay alive, and the tragedies they endure.","popularity":3948.296,"poster_path":"/t6HIqrRAclMCA60NsSmeqe9RmNV.jpg","release_date":"2022-12-14","title":"Avatar: The Way of Water","video":false,"vote_average":7.7,"vote_count":4219},{"adult":false,"backdrop_path":"/uEwGFGtao9YG2JolmdvtHLLVbA9.jpg","genre_ids...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-4
Scene Deconstruction","video":false,"vote_average":7.8,"vote_count":12},{"adult":false,"backdrop_path":null,"genre_ids":[28,18,878,12,14],"id":83533,"original_language":"en","original_title":"Avatar 3","overview":"","popularity":172.488,"poster_path":"/4rXqTMlkEaMiJjiG0Z2BX6F6Dkm.jpg","release_date":"2024-12-18","title...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-5
Avatar is a feature length behind-the-scenes documentary about the making of Avatar. It uses footage from the film's development, as well as stock footage from as far back as the production of Titanic in 1995. Also included are numerous interviews with cast, artists, and other crew members. The documentary was released...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-6
The Deep Dive - A Special Edition of 20/20","video":false,"vote_average":6.5,"vote_count":5},{"adult":false,"backdrop_path":null,"genre_ids":[99],"id":278698,"original_language":"en","original_title":"Avatar Spirits","overview":"Bryan Konietzko and Michael Dante DiMartino, co-creators of the hit television series, Avat...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-7
the scenes look at the new James Cameron blockbuster “Avatar”, which stars Aussie Sam Worthington. Hastily produced by Australia’s Nine Network following the film’s release.","popularity":30.903,"poster_path":"/9MHY9pYAgs91Ef7YFGWEbP4WJqC.jpg","release_date":"2009-12-05","title":"Avatar: Enter The World","video":false,...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-8
Agni Kai","video":false,"vote_average":7,"vote_count":1},{"adult":false,"backdrop_path":"/e8mmDO7fKK93T4lnxl4Z2zjxXZV.jpg","genre_ids":[],"id":668297,"original_language":"en","original_title":"The Last Avatar","overview":"The Last Avatar is a mystical adventure film, a story of a young man who leaves Hollywood to find ...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-9
awaken and create a world of truth, harmony and possibility.","popularity":8.786,"poster_path":"/XWz5SS5g5mrNEZjv3FiGhqCMOQ.jpg","release_date":"2014-12-06","title":"The Last Avatar","video":false,"vote_average":4.5,"vote_count":2},{"adult":false,"backdrop_path":null,"genre_ids":[],"id":424768,"original_language":"en",...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-10
2018","overview":"Live At Graspop Festival Belgium 2018","popularity":9.855,"poster_path":null,"release_date":"","title":"Avatar - Live At Graspop 2018","video":false,"vote_average":9,"vote_count":1},{"adult":false,"backdrop_path":null,"genre_ids":[10402],"id":874770,"original_language":"en","original_title":"Avatar Ag...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-11
Ages: Madness","video":false,"vote_average":8,"vote_count":1},{"adult":false,"backdrop_path":"/dj8g4jrYMfK6tQ26ra3IaqOx5Ho.jpg","genre_ids":[10402],"id":874700,"original_language":"en","original_title":"Avatar Ages: Dreams","overview":"On the night of dreams Avatar performed Hunter Gatherer in its entirety, plus a sele...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
dd92ad12c823-12
> Finished chain. ' This response contains 57 movies related to the search query "Avatar". The first movie in the list is the 2009 movie "Avatar" starring Sam Worthington. Other movies in the list include sequels to Avatar, documentaries, and live performances.' Listen API Example# import os from langchain.llms import ...
https://python.langchain.com/en/latest/modules/chains/examples/api.html
00c33be60b87-0
.ipynb .pdf BashChain Contents Customize Prompt Persistent Terminal BashChain# This notebook showcases using LLMs and a bash process to perform simple filesystem commands. from langchain.chains import LLMBashChain from langchain.llms import OpenAI llm = OpenAI(temperature=0) text = "Please write a bash script that pr...
https://python.langchain.com/en/latest/modules/chains/examples/llm_bash.html
00c33be60b87-1
Do not use 'echo' when writing the script. That is the format. Begin! Question: {question}""" PROMPT = PromptTemplate(input_variables=["question"], template=_PROMPT_TEMPLATE, output_parser=BashOutputParser()) bash_chain = LLMBashChain.from_llm(llm, prompt=PROMPT, verbose=True) text = "Please write a bash script that pr...
https://python.langchain.com/en/latest/modules/chains/examples/llm_bash.html
00c33be60b87-2
llm_requests.ipynb sqlite.ipynb > Finished chain. 'api.ipynb\t\t\tllm_summarization_checker.ipynb\r\nconstitutional_chain.ipynb\tmoderation.ipynb\r\nllm_bash.ipynb\t\t\topenai_openapi.yaml\r\nllm_checker.ipynb\t\topenapi.ipynb\r\nllm_math.ipynb\t\t\tpal.ipynb\r\nllm_requests.ipynb\t\tsqlite.ipynb' # Run the same comma...
https://python.langchain.com/en/latest/modules/chains/examples/llm_bash.html
c602cb272877-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
5c46835715c6-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
5c46835715c6-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
5c46835715c6-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