id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
59
127
63cad9945ed4-7
{'uuid': '52cfe3e8-b800-4dd8-a7dd-8e9e4764dfc8', 'created_at': '2023-05-25T15:09:41.913856Z', 'role': 'ai', 'content': "Octavia Butler's contemporaries included Ursula K. Le Guin, Samuel R. Delany, and Joanna Russ.", 'token_count': 27} 0.852352466457884 {'uuid': 'd40da612-0867-4a43-92ec-778b86490a39', 'created_at': '20...
rtdocs_stable/api.python.langchain.com/en/stable/modules/memory/examples/zep_memory.html
63cad9945ed4-8
{'uuid': '862107de-8f6f-43c0-91fa-4441f01b2b3a', 'created_at': '2023-05-25T15:09:41.898149Z', 'role': 'human', 'content': 'Which books of hers were made into movies?', 'token_count': 11} 0.7954322970428519 {'uuid': '97164506-90fe-4c71-9539-69ebcd1d90a2', 'created_at': '2023-05-25T15:09:41.90887Z', 'role': 'human', 'con...
rtdocs_stable/api.python.langchain.com/en/stable/modules/memory/examples/zep_memory.html
63cad9945ed4-9
previous Redis Chat Message History next Indexes Contents REACT Agent Chat Message History Example Initialize the Zep Chat Message History Class and initialize the Agent Add some history data Run the agent Inspect the Zep memory Vector search over the Zep memory By Harrison Chase © Copyright 2023, Harris...
rtdocs_stable/api.python.langchain.com/en/stable/modules/memory/examples/zep_memory.html
1225b3f64d34-0
.ipynb .pdf How to add memory to a Multi-Input Chain How to add memory to a Multi-Input Chain# Most memory objects assume a single input. In this notebook, we go over how to add memory to a chain that has multiple inputs. As an example of such a chain, we will add memory to a question/answering chain. This chain takes ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/memory/examples/adding_memory_chain_multiple_inputs.html
1225b3f64d34-1
{context} {chat_history} Human: {human_input} Chatbot:""" prompt = PromptTemplate( input_variables=["chat_history", "human_input", "context"], template=template ) memory = ConversationBufferMemory(memory_key="chat_history", input_key="human_input") chain = load_qa_chain(OpenAI(temperature=0), chain_type="stuff...
rtdocs_stable/api.python.langchain.com/en/stable/modules/memory/examples/adding_memory_chain_multiple_inputs.html
958f5252040f-0
.ipynb .pdf Callbacks Contents Callbacks How to use callbacks When do you want to use each of these? Tags Using an existing handler Creating a custom handler Async Callbacks Using multiple handlers, passing in handlers Tracing and Token Counting Tracing Token Counting Callbacks# LangChain provides a callbacks system ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-1
CallbackHandlers are objects that implement the CallbackHandler interface, which has a method for each event that can be subscribed to. The CallbackManager will call the appropriate method on each handler when the event is triggered. class BaseCallbackHandler: """Base callback handler that can be used to handle cal...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-2
"""Run when chain errors.""" def on_tool_start( self, serialized: Dict[str, Any], input_str: str, **kwargs: Any ) -> Any: """Run when tool starts running.""" def on_tool_end(self, output: str, **kwargs: Any) -> Any: """Run when tool ends running.""" def on_tool_error( sel...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-3
The verbose argument is available on most objects throughout the API (Chains, Models, Tools, Agents, etc.) as a constructor argument, eg. LLMChain(verbose=True), and it is equivalent to passing a ConsoleCallbackHandler to the callbacks argument of that object and all child objects. This is useful for debugging, as it w...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-4
Note when the verbose flag on the object is set to true, the StdOutCallbackHandler will be invoked even without being explicitly passed in. from langchain.callbacks import StdOutCallbackHandler from langchain.chains import LLMChain from langchain.llms import OpenAI from langchain.prompts import PromptTemplate handler =...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-5
from langchain.schema import HumanMessage class MyCustomHandler(BaseCallbackHandler): def on_llm_new_token(self, token: str, **kwargs) -> None: print(f"My custom handler, token: {token}") # To enable streaming, we pass in `streaming=True` to the ChatModel constructor # Additionally, we pass in a list with o...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-6
from langchain.schema import LLMResult from langchain.callbacks.base import AsyncCallbackHandler class MyCustomSyncHandler(BaseCallbackHandler): def on_llm_new_token(self, token: str, **kwargs) -> None: print(f"Sync handler being called in a `thread_pool_executor`: token: {token}") class MyCustomAsyncHandle...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-7
Sync handler being called in a `thread_pool_executor`: token: don Sync handler being called in a `thread_pool_executor`: token: 't Sync handler being called in a `thread_pool_executor`: token: scientists Sync handler being called in a `thread_pool_executor`: token: trust Sync handler being called in a `thread_pool_e...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-8
However, in many cases, it is advantageous to pass in handlers instead when running the object. When we pass through CallbackHandlers using the callbacks keyword arg when executing an run, those callbacks will be issued by all nested objects involved in the execution. For example, when a handler is passed through to an...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-9
) -> Any: print(f"on_tool_start {serialized['name']}") def on_agent_action(self, action: AgentAction, **kwargs: Any) -> Any: print(f"on_agent_action {action}") class MyCustomHandlerTwo(BaseCallbackHandler): def on_llm_start( self, serialized: Dict[str, Any], prompts: List[str], **kwargs:...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-10
Action on_new_token : on_new_token Calculator on_new_token Action on_new_token Input on_new_token : on_new_token 2 on_new_token ^ on_new_token 0 on_new_token . on_new_token 235 on_new_token on_agent_action AgentAction(tool='Calculator', tool_input='2^0.235', log=' I need to use a calculator to solve this.\nAction:...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-11
on_new_token . on_new_token 17 on_new_token 690 on_new_token 67 on_new_token 372 on_new_token 187 on_new_token 674 on_new_token '1.1769067372187674' Tracing and Token Counting# Tracing and token counting are two capabilities we provide which are built on our callbacks mechanism. Tracing# There are two recommended ways...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-12
"Who is Beyonce's husband? What is his age raised to the 0.19 power?", ] os.environ["LANGCHAIN_TRACING"] = "true" # Both of the agent runs will be traced because the environment variable is set agent.run(questions[0]) with tracing_enabled() as session: assert session agent.run(questions[1]) > Entering new Agent...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-13
Action: Search Action Input: "Olivia Wilde boyfriend" Observation: Sudeikis and Wilde's relationship ended in November 2020. Wilde was publicly served with court documents regarding child custody while she was presenting Don't Worry Darling at CinemaCon 2022. In January 2021, Wilde began dating singer Harry Styles afte...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-14
Action: Search Action Input: "US Open men's final 2019 winner" Observation: Rafael Nadal defeated Daniil Medvedev in the final, 7–5, 6–3, 5–7, 4–6, 6–4 to win the men's singles tennis title at the 2019 US Open. It was his fourth US ... Thought: I need to find out the age of the winner Action: Search Action Input: "Rafa...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-15
Action: Calculator Action Input: 29^0.23 Observation: Answer: 2.169459462491557 Thought: I now know the final answer. Final Answer: Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. > Finished chain. "Harry Styles is Olivia Wilde's boyfriend and his current age ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-16
Action: Search Action Input: "US Open men's final 2019 winner"Rafael Nadal defeated Daniil Medvedev in the final, 7–5, 6–3, 5–7, 4–6, 6–4 to win the men's singles tennis title at the 2019 US Open. It was his fourth US ... I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 p...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-17
I now need to calculate 38 raised to the 0.23 power Action: Calculator Action Input: 38^0.23Answer: 2.3086081644669734 > Finished chain. "Rafael Nadal, aged 36, won the US Open men's final in 2019 and his age raised to the 0.334 power is 3.3098250249682484." Token Counting# LangChain offers a context manager that allow...
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
958f5252040f-18
When do you want to use each of these? Tags Using an existing handler Creating a custom handler Async Callbacks Using multiple handlers, passing in handlers Tracing and Token Counting Tracing Token Counting By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/modules/callbacks/getting_started.html
230a4236d05f-0
.rst .pdf How-To Guides How-To Guides# A chain is made up of links, which can be either primitives or other chains. Primitives can be either prompts, models, arbitrary functions, or other chains. The examples here are broken up into three sections: Generic Functionality Covers both generic chains (that are useful in a ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/how_to_guides.html
f9c45827a15f-0
.ipynb .pdf Getting Started Contents Why do we need chains? Quick start: Using LLMChain Different ways of calling chains Add memory to chains Debug Chain Combine chains with the SequentialChain Create a custom chain with the Chain class Getting Started# In this tutorial, we will learn about creating simple chains in ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/getting_started.html
f9c45827a15f-1
print(chain.run("colorful socks")) Colorful Toes Co. If there are multiple variables, you can input them all at once using a dictionary. prompt = PromptTemplate( input_variables=["company", "product"], template="What is a good name for {company} that makes {product}?", ) chain = LLMChain(llm=llm, prompt=prompt)...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/getting_started.html
f9c45827a15f-2
{'adjective': 'corny', 'text': 'Why did the tomato turn red? Because it saw the salad dressing!'} By default, __call__ returns both the input and output key values. You can configure it to only return output key values by setting return_only_outputs to True. llm_chain("corny", return_only_outputs=True) {'text': 'Why d...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/getting_started.html
f9c45827a15f-3
llm=chat, memory=ConversationBufferMemory() ) conversation.run("Answer briefly. What are the first 3 colors of a rainbow?") # -> The first three colors of a rainbow are red, orange, and yellow. conversation.run("And the next 4?") # -> The next four colors of a rainbow are green, blue, indigo, and violet. 'The next ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/getting_started.html
f9c45827a15f-4
Human: What is ChatGPT? AI: > Finished chain. 'ChatGPT is an AI language model developed by OpenAI. It is based on the GPT-3 architecture and is capable of generating human-like responses to text prompts. ChatGPT has been trained on a massive amount of text data and can understand and respond to a wide range of topics....
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/getting_started.html
f9c45827a15f-5
catchphrase = overall_chain.run("colorful socks") print(catchphrase) > Entering new SimpleSequentialChain chain... Rainbow Socks Co. "Put a little rainbow in your step!" > Finished chain. "Put a little rainbow in your step!" Create a custom chain with the Chain class# LangChain provides many chains out of the box, but ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/getting_started.html
f9c45827a15f-6
prompt_1 = PromptTemplate( input_variables=["product"], template="What is a good name for a company that makes {product}?", ) chain_1 = LLMChain(llm=llm, prompt=prompt_1) prompt_2 = PromptTemplate( input_variables=["product"], template="What is a good slogan for a company that makes {product}?", ) chain...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/getting_started.html
c50ca7af02b9-0
.ipynb .pdf Serialization Contents Saving a chain to disk Loading a chain from disk Saving components separately Serialization# This notebook covers how to serialize chains to and from disk. The serialization format we use is json or yaml. Currently, only some chains support this type of serialization. We will grow t...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/serialization.html
c50ca7af02b9-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/serialization.html
c50ca7af02b9-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/serialization.html
ae357dc74de5-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: ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/from_hub.html
ae357dc74de5-1
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 from the Fraternal Order of Police to former judges appointed by ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/from_hub.html
9bd6ce2ff374-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 ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/router.html
9bd6ce2ff374-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/router.html
9bd6ce2ff374-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/router.html
9bd6ce2ff374-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/router.html
71f0bd480c50-0
.ipynb .pdf Creating a custom Chain Creating a custom Chain# To implement your own custom chain you can subclass Chain and implement the following methods: from __future__ import annotations from typing import Any, Dict, List, Optional from pydantic import Extra from langchain.base_language import BaseLanguageModel fro...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/custom_chain.html
71f0bd480c50-1
# Whenever you call a language model, or another chain, you should pass # a callback manager to it. This allows the inner run to be tracked by # any callbacks that are registered on the outer run. # You can always obtain a callback manager for this by calling # `run_manager.get_child()` ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/custom_chain.html
71f0bd480c50-2
callbacks=run_manager.get_child() if run_manager else None ) # If you want to log something about this run, you can do so by calling # methods on the `run_manager`, as shown below. This will trigger any # callbacks that are registered for that event. if run_manager: a...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/custom_chain.html
cfda074507f9-0
.ipynb .pdf Transformation Chain Transformation Chain# This notebook showcases using a generic transformation chain. As an example, we will create a dummy transformation that takes in a super long text, filters the text to only the first 3 paragraphs, and then passes that into an LLMChain to summarize those. from langc...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/transformation.html
91a767214cd6-0
.ipynb .pdf Sequential Chains Contents SimpleSequentialChain Sequential Chain Memory in Sequential Chains Sequential Chains# The next step after calling a language model is make a series of calls to a language model. This is particularly useful when you want to take the output from one call and use it as the input to...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/sequential_chains.html
91a767214cd6-1
synopsis_chain = LLMChain(llm=llm, prompt=prompt_template) # This is an LLMChain to write a review of a play given a synopsis. llm = OpenAI(temperature=.7) template = """You are a play critic from the New York Times. Given the synopsis of play, it is your job to write a review for that play. Play Synopsis: {synopsis} R...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/sequential_chains.html
91a767214cd6-2
The play follows the couple as they struggle to stay together and battle the forces that threaten to tear them apart. Despite the tragedy that awaits them, they remain devoted to one another and fight to keep their love alive. In the end, the couple must decide whether to take a chance on their future together or succu...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/sequential_chains.html
91a767214cd6-3
The play's setting of the beach at sunset adds a touch of poignancy and romanticism to the story, while the mysterious figure serves to keep the audience enthralled. Overall, Tragedy at Sunset on the Beach is an engaging and thought-provoking play that is sure to leave audiences feeling inspired and hopeful. Sequential...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/sequential_chains.html
91a767214cd6-4
Play Synopsis: {synopsis} Review from a New York Times play critic of the above play:""" prompt_template = PromptTemplate(input_variables=["synopsis"], template=template) review_chain = LLMChain(llm=llm, prompt=prompt_template, output_key="review") # This is the overall chain where we run these two chains in sequence. ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/sequential_chains.html
91a767214cd6-5
'era': 'Victorian England', 'synopsis': "\n\nThe play follows the story of John, a young man from a wealthy Victorian family, who dreams of a better life for himself. He soon meets a beautiful young woman named Mary, who shares his dream. The two fall in love and decide to elope and start a new life together.\n\nOn th...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/sequential_chains.html
91a767214cd6-6
'review': "\n\nThe latest production from playwright X is a powerful and heartbreaking story of love and loss set against the backdrop of 19th century England. The play follows John, a young man from a wealthy Victorian family, and Mary, a beautiful young woman with whom he falls in love. The two decide to elope and st...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/sequential_chains.html
91a767214cd6-7
from langchain.memory import SimpleMemory llm = OpenAI(temperature=.7) template = """You are a social media manager for a theater company. Given the title of play, the era it is set in, the date,time and location, the synopsis of the play, and the review of the play, it is your job to write a social media post for tha...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/sequential_chains.html
91a767214cd6-8
'location': 'Theater in the Park', 'social_post_text': "\nSpend your Christmas night with us at Theater in the Park and experience the heartbreaking story of love and loss that is 'A Walk on the Beach'. Set in Victorian England, this romantic tragedy follows the story of Frances and Edward, a young couple whose love i...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/sequential_chains.html
37cb620079e7-0
.ipynb .pdf Async API for Chain Async API for Chain# LangChain provides async support for Chains by leveraging the asyncio library. Async methods are currently supported in LLMChain (through arun, apredict, acall) and LLMMathChain (through arun and acall), ChatVectorDBChain, and QA chains. Async support for other chain...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/async_chain.html
37cb620079e7-1
await generate_concurrently() elapsed = time.perf_counter() - s print('\033[1m' + f"Concurrent executed in {elapsed:0.2f} seconds." + '\033[0m') s = time.perf_counter() generate_serially() elapsed = time.perf_counter() - s print('\033[1m' + f"Serial executed in {elapsed:0.2f} seconds." + '\033[0m') BrightSmile Toothpas...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/async_chain.html
e98b75f55faf-0
.ipynb .pdf LLM Chain Contents LLM Chain Additional ways of running LLM Chain Parsing the outputs Initialize from string LLM Chain# LLMChain is perhaps one of the most popular ways of querying an LLM object. It formats the prompt template using the input key values provided (and also memory key values, if available),...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/llm_chain.html
e98b75f55faf-1
llm_chain.generate(input_list) LLMResult(generations=[[Generation(text='\n\nSocktastic!', generation_info={'finish_reason': 'stop', 'logprobs': None})], [Generation(text='\n\nTechCore Solutions.', generation_info={'finish_reason': 'stop', 'logprobs': None})], [Generation(text='\n\nFootwear Factory.', generation_info={'...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/llm_chain.html
e98b75f55faf-2
template = """List all the colors in a rainbow""" prompt = PromptTemplate(template=template, input_variables=[], output_parser=output_parser) llm_chain = LLMChain(prompt=prompt, llm=llm) llm_chain.predict() '\n\nRed, orange, yellow, green, blue, indigo, violet' With predict_and_parser: llm_chain.predict_and_parse() ['R...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/generic/llm_chain.html
b80d4de316a8-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/multi_prompt_router.html
b80d4de316a8-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/multi_prompt_router.html
b80d4de316a8-2
None: {'input': 'What is the name of the type of cloud that rains?'} > 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 ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/multi_prompt_router.html
ff4380adc0c6-0
.ipynb .pdf PAL Contents Math Prompt Colored Objects Intermediate Steps PAL# Implements Program-Aided Language Models, as in https://arxiv.org/pdf/2211.10435.pdf. from langchain.chains import PALChain from langchain import OpenAI llm = OpenAI(temperature=0, max_tokens=512) Math Prompt# pal_chain = PALChain.from_math_...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/pal.html
ff4380adc0c6-1
objects += [('booklet', 'purple')] * 2 objects += [('sunglasses', 'yellow')] * 2 # Remove all pairs of sunglasses objects = [object for object in objects if object[0] != 'sunglasses'] # Count number of purple objects num_purple = len([object for object in objects if object[1] == 'purple']) answer = num_purple > Finishe...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/pal.html
ff4380adc0c6-2
answer = num_purple > Finished chain. result['intermediate_steps'] "# Put objects into a list to record ordering\nobjects = []\nobjects += [('booklet', 'blue')] * 2\nobjects += [('booklet', 'purple')] * 2\nobjects += [('sunglasses', 'yellow')] * 2\n\n# Remove all pairs of sunglasses\nobjects = [object for object in obj...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/pal.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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 >...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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: ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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 ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
808b16fa5fc3-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/flare.html
91cf89266cf6-0
.ipynb .pdf GraphCypherQAChain Contents Seeding the database Refresh graph schema information Querying the graph Limit the number of results Return intermediate results Return direct results GraphCypherQAChain# This notebook shows how to use LLMs to provide a natural language interface to a graph database you can que...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/graph_cypher_qa.html
91cf89266cf6-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/graph_cypher_qa.html
91cf89266cf6-2
Limit the number of results# You can limit the number of results from the Cypher QA Chain using the top_k parameter. The default is 10. chain = GraphCypherQAChain.from_llm( ChatOpenAI(temperature=0), graph=graph, verbose=True, top_k=2 ) chain.run("Who played in Top Gun?") > Entering new GraphCypherQAChain chain... ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/graph_cypher_qa.html
91cf89266cf6-3
> Finished chain. Intermediate steps: [{'query': "MATCH (a:Actor)-[:ACTED_IN]->(m:Movie {name: 'Top Gun'})\nRETURN a.name"}, {'context': [{'a.name': 'Val Kilmer'}, {'a.name': 'Anthony Edwards'}, {'a.name': 'Meg Ryan'}, {'a.name': 'Tom Cruise'}]}] Final answer: Val Kilmer, Anthony Edwards, Meg Ryan, and Tom Cruise playe...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/graph_cypher_qa.html
13efa52e14c6-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/sqlite.html
13efa52e14c6-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/sqlite.html
13efa52e14c6-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_...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/sqlite.html
13efa52e14c6-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',
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/sqlite.html
13efa52e14c6-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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/sqlite.html
13efa52e14c6-5
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) 262-3322\tnancy@chinookcorp.com\n3\tPeacock\tJane\tSales Support Agent\t2\t1973-08-29 00:00:00\t2002-0...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/sqlite.html
13efa52e14c6-6
TABLE "Playlist" (\n\t"PlaylistId" INTEGER NOT NULL, \n\t"Name" NVARCHAR(120), \n\tPRIMARY KEY ("PlaylistId")\n)\n\n/*\n3 rows from Playlist table:\nPlaylistId\tName\n1\tMusic\n2\tMovies\n3\tTV Shows\n*/\n\n\nCREATE TABLE "Album" (\n\t"AlbumId" INTEGER NOT NULL, \n\t"Title" NVARCHAR(160) NOT NULL, \n\t"ArtistId" INTEGE...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/sqlite.html
13efa52e14c6-7
REFERENCES "Employee" ("EmployeeId")\n)\n\n/*\n3 rows from Customer table:\nCustomerId\tFirstName\tLastName\tCompany\tAddress\tCity\tState\tCountry\tPostalCode\tPhone\tFax\tEmail\tSupportRepId\n1\tLuís\tGonçalves\tEmbraer - Empresa Brasileira de Aeronáutica S.A.\tAv. Brigadeiro Faria Lima, 2170\tSão José dos Campos\tSP...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/sqlite.html
13efa52e14c6-8
KEY ("InvoiceId"), \n\tFOREIGN KEY("CustomerId") REFERENCES "Customer" ("CustomerId")\n)\n\n/*\n3 rows from Invoice table:\nInvoiceId\tCustomerId\tInvoiceDate\tBillingAddress\tBillingCity\tBillingState\tBillingCountry\tBillingPostalCode\tTotal\n1\t2\t2009-01-01 00:00:00\tTheodor-Heuss-Straße 34\tStuttgart\tNone\tGerman...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/sqlite.html
13efa52e14c6-9
Those About To Rock (We Salute You)\t1\t1\t1\tAngus Young, Malcolm Young, Brian Johnson\t343719\t11170334\t0.99\n2\tBalls 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"I...
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/sqlite.html
13efa52e14c6-10
"Playlist" ("PlaylistId")\n)\n\n/*\n3 rows from PlaylistTrack table:\nPlaylistId\tTrackId\n1\t3402\n1\t3389\n1\t3390\n*/',
rtdocs_stable/api.python.langchain.com/en/stable/modules/chains/examples/sqlite.html