id
stringlengths
14
15
text
stringlengths
27
2.12k
source
stringlengths
49
118
9fbaaf7ee976-0
Chains | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/
9fbaaf7ee976-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalDocumentsPopularAdditionalMemoryAgentsCallbacksModulesGuidesEcosystemAdditional resourcesModulesChainsOn this pageChainsUsin...
https://python.langchain.com/docs/modules/chains/
9fbaaf7ee976-2
but more complex applications require chaining LLMs - either with each other or with other components.LangChain provides the Chain interface for such "chained" applications. We define a Chain very generically as a sequence of calls to components, which can include other chains. The base interface is simple:class Chain(...
https://python.langchain.com/docs/modules/chains/
9fbaaf7ee976-3
prompt template, formats it with the user input and returns the response from an LLM.To use the LLMChain, first create a prompt template.from langchain.llms import OpenAIfrom langchain.prompts import PromptTemplatellm = OpenAI(temperature=0.9)prompt = PromptTemplate( input_variables=["product"], template="What is...
https://python.langchain.com/docs/modules/chains/
9fbaaf7ee976-4
input_variables=["product"], ) )chat_prompt_template = ChatPromptTemplate.from_messages([human_message_prompt])chat = ChatOpenAI(temperature=0.9)chain = LLMChain(llm=chat, prompt=chat_prompt_template)print(chain.run("colorful socks")) Rainbow Socks Co.PreviousVector store-backed retrieverNextHow toWhy do w...
https://python.langchain.com/docs/modules/chains/
9ed5f798e742-0
Foundational | 🦜�🔗 Langchain Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalLLMRouterSequentialTransformationDocumentsPopularAdditionalMemoryAgentsCallbacksMo...
https://python.langchain.com/docs/modules/chains/foundational/
04f0fede01f7-0
Sequential | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/foundational/sequential_chains
04f0fede01f7-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalLLMRouterSequentialTransformationDocumentsPopularAdditionalMemoryAgentsCallbacksModulesGuidesEcosystemAdditional resourcesMo...
https://python.langchain.com/docs/modules/chains/foundational/sequential_chains
04f0fede01f7-2
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}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...
https://python.langchain.com/docs/modules/chains/foundational/sequential_chains
04f0fede01f7-3
Tragedy at Sunset on the Beach is an emotionally gripping story of love, hope, and sacrifice. Through the story of Jack and Sarah, the audience is taken on a journey of self-discovery and the power of love to overcome even the greatest of obstacles. The play's talented cast brings the characters to life, allowi...
https://python.langchain.com/docs/modules/chains/foundational/sequential_chains
04f0fede01f7-4
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 Chain​Of course, not all sequential chains will be as simple as passing a single string as an argument and getting a single string as output for all steps in the ch...
https://python.langchain.com/docs/modules/chains/foundational/sequential_chains
04f0fede01f7-5
prompt=prompt_template, output_key="review")# This is the overall chain where we run these two chains in sequence.from langchain.chains import SequentialChainoverall_chain = SequentialChain( chains=[synopsis_chain, review_chain], input_variables=["era", "title"], # Here we return multiple variables output_v...
https://python.langchain.com/docs/modules/chains/foundational/sequential_chains
04f0fede01f7-6
of a future, chooses to take his own life by jumping off the cliffs into the sea below. \n\nThe play is a powerful story of love, hope, and loss set against the backdrop of 19th century England.", 'review': "\n\nThe latest production from playwright X is a powerful and heartbreaking story of love and loss set again...
https://python.langchain.com/docs/modules/chains/foundational/sequential_chains
04f0fede01f7-7
a SimpleMemory to the chain to manage this context:from langchain.chains import SequentialChainfrom langchain.memory import SimpleMemoryllm = 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...
https://python.langchain.com/docs/modules/chains/foundational/sequential_chains
04f0fede01f7-8
PST', '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...
https://python.langchain.com/docs/modules/chains/foundational/sequential_chains
356fcd0563bb-0
Router | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/foundational/router
356fcd0563bb-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalLLMRouterSequentialTransformationDocumentsPopularAdditionalMemoryAgentsCallbacksModulesGuidesEcosystemAdditional resourcesMo...
https://python.langchain.com/docs/modules/chains/foundational/router
356fcd0563bb-2
"name": "physics", "description": "Good for answering questions about physics", "prompt_template": physics_template, }, { "name": "math", "description": "Good for answering math questions", "prompt_template": math_template, },]llm = OpenAI()destination_chains = {}for p_info i...
https://python.langchain.com/docs/modules/chains/foundational/router
356fcd0563bb-3
default_chain=default_chain, verbose=True,)print(chain.run("What is black body radiation?")) > Entering new MultiPromptChain chain... physics: {'input': 'What is black body radiation?'} > Finished chain. Black body radiation is the term used to describe the electromagnetic radiation emitt...
https://python.langchain.com/docs/modules/chains/foundational/router
356fcd0563bb-4
of cloud that rains?'} > Finished chain. The type of cloud that rains is called a cumulonimbus cloud. It is a tall and dense cloud that is often accompanied by thunder and lightning.EmbeddingRouterChain​The EmbeddingRouterChain uses embeddings and similarity to route between destination chains.from langchain.c...
https://python.langchain.com/docs/modules/chains/foundational/router
356fcd0563bb-5
chain.run( "What is the first prime number greater than 40 such that one plus the prime number is divisible by 3" )) > Entering new MultiPromptChain chain... math: {'input': 'What is the first prime number greater than 40 such that one plus the prime number is divisible by 3'} > Finished chai...
https://python.langchain.com/docs/modules/chains/foundational/router
d4a9a0032504-0
Transformation | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/foundational/transformation
d4a9a0032504-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalLLMRouterSequentialTransformationDocumentsPopularAdditionalMemoryAgentsCallbacksModulesGuidesEcosystemAdditional resourcesMo...
https://python.langchain.com/docs/modules/chains/foundational/transformation
0c6257a6776a-0
LLM | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/foundational/llm_chain
0c6257a6776a-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalLLMRouterSequentialTransformationDocumentsPopularAdditionalMemoryAgentsCallbacksModulesGuidesEcosystemAdditional resourcesMo...
https://python.langchain.com/docs/modules/chains/foundational/llm_chain
0c6257a6776a-2
'\n\nSocktastic!'}, {'text': '\n\nTechCore Solutions.'}, {'text': '\n\nFootwear Factory.'}]generate is similar to apply, except it return an LLMResult instead of string. LLMResult often contains useful generation such as token usages and finish reason.llm_chain.generate(input_list) LLMResult(generations=[[Ge...
https://python.langchain.com/docs/modules/chains/foundational/llm_chain
0c6257a6776a-3
an output parser. If you would like to apply that output parser on the LLM output, use predict_and_parse instead of predict and apply_and_parse instead of apply. With predict:from langchain.output_parsers import CommaSeparatedListOutputParseroutput_parser = CommaSeparatedListOutputParser()template = """List all the col...
https://python.langchain.com/docs/modules/chains/foundational/llm_chain
10498023424d-0
Documents | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/document/
10498023424d-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalDocumentsStuffRefineMap reduceMap re-rankPopularAdditionalMemoryAgentsCallbacksModulesGuidesEcosystemAdditional resourcesMod...
https://python.langchain.com/docs/modules/chains/document/
10498023424d-2
or collapse, the mapped documents to make sure that they fit in the combine documents chain (which will often pass them to an LLM). This compression step is performed recursively if necessary.📄� Map re-rankThe map re-rank documents chain runs an initial prompt on each document, that not only tries to complete a ta...
https://python.langchain.com/docs/modules/chains/document/
b770ca4fd1a7-0
Map reduce | 🦜�🔗 Langchain Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalDocumentsStuffRefineMap reduceMap re-rankPopularAdditionalMemoryAgentsCallbacksModul...
https://python.langchain.com/docs/modules/chains/document/map_reduce
75bc2bd82034-0
Refine | 🦜�🔗 Langchain Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalDocumentsStuffRefineMap reduceMap re-rankPopularAdditionalMemoryAgentsCallbacksModulesGu...
https://python.langchain.com/docs/modules/chains/document/refine
fb46ee486dca-0
Map re-rank | 🦜�🔗 Langchain Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalDocumentsStuffRefineMap reduceMap re-rankPopularAdditionalMemoryAgentsCallbacksModu...
https://python.langchain.com/docs/modules/chains/document/map_rerank
e2576a8d2c80-0
Stuff | 🦜�🔗 Langchain Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalDocumentsStuffRefineMap reduceMap re-rankPopularAdditionalMemoryAgentsCallbacksModulesGui...
https://python.langchain.com/docs/modules/chains/document/stuff
59d8dd21386a-0
How to | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/how_to/
59d8dd21386a-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toAsync APIDifferent call methodsCustom chainDebugging chainsLoading from LangChainHubAdding memory (state)SerializationFoundationalDocume...
https://python.langchain.com/docs/modules/chains/how_to/
cbddc1e252b8-0
Different call methods | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/how_to/call_methods
cbddc1e252b8-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toAsync APIDifferent call methodsCustom chainDebugging chainsLoading from LangChainHubAdding memory (state)SerializationFoundationalDocume...
https://python.langchain.com/docs/modules/chains/how_to/call_methods
cbddc1e252b8-2
the case of one input key, you can input the string directly without specifying the input mapping.# These two are equivalentllm_chain.run({"adjective": "corny"})llm_chain.run("corny")# These two are also equivalentllm_chain("corny")llm_chain({"adjective": "corny"}) {'adjective': 'corny', 'text': 'Why did the tom...
https://python.langchain.com/docs/modules/chains/how_to/call_methods
c8528d21471e-0
Custom chain | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/how_to/custom_chain
c8528d21471e-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toAsync APIDifferent call methodsCustom chainDebugging chainsLoading from LangChainHubAdding memory (state)SerializationFoundationalDocume...
https://python.langchain.com/docs/modules/chains/how_to/custom_chain
c8528d21471e-2
output_keys(self) -> List[str]: """Will always return text key. :meta private: """ return [self.output_key] def _call( self, inputs: Dict[str, Any], run_manager: Optional[CallbackManagerForChainRun] = None, ) -> Dict[str, str]: # Your custom chain logic goes...
https://python.langchain.com/docs/modules/chains/how_to/custom_chain
c8528d21471e-3
if run_manager: run_manager.on_text("Log something about this run") return {self.output_key: response.generations[0][0].text} async def _acall( self, inputs: Dict[str, Any], run_manager: Optional[AsyncCallbackManagerForChainRun] = None, ) -> Dict[str, str]: # Your cus...
https://python.langchain.com/docs/modules/chains/how_to/custom_chain
c8528d21471e-4
that event. if run_manager: await run_manager.on_text("Log something about this run") return {self.output_key: response.generations[0][0].text} @property def _chain_type(self) -> str: return "my_custom_chain"from langchain.callbacks.stdout import StdOutCallbackHandlerfrom langchain...
https://python.langchain.com/docs/modules/chains/how_to/custom_chain
72f82be22281-0
Serialization | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/how_to/serialization
72f82be22281-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toAsync APIDifferent call methodsCustom chainDebugging chainsLoading from LangChainHubAdding memory (state)SerializationFoundationalDocume...
https://python.langchain.com/docs/modules/chains/how_to/serialization
72f82be22281-2
"output_parser": null, "template": "Question: {question}\n\nAnswer: Let's think step by step.", "template_format": "f-string" }, "llm": { "model_name": "text-davinci-003", "temperature": 0.0, "max_tokens": 256, "top_p": 1, "frequ...
https://python.langchain.com/docs/modules/chains/how_to/serialization
72f82be22281-3
> Entering new LLMChain chain... Prompt after formatting: Question: whats 2 + 2 Answer: Let's think step by step. > Finished chain. ' 2 + 2 = 4'Saving components separately​In the above example, we can see that the prompt and llm configuration information is saved in the same json as the overal...
https://python.langchain.com/docs/modules/chains/how_to/serialization
72f82be22281-4
"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", "_type": "llm_chain",}import jsonwith open("llm_chain_separate.json...
https://python.langchain.com/docs/modules/chains/how_to/serialization
72f82be22281-5
from diskSaving components separatelyCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright © 2023 LangChain, Inc.
https://python.langchain.com/docs/modules/chains/how_to/serialization
fa4c6d6042ca-0
Adding memory (state) | 🦜�🔗 Langchain Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toAsync APIDifferent call methodsCustom chainDebugging chainsLoading from LangChainHubA...
https://python.langchain.com/docs/modules/chains/how_to/memory
3d35fee08c4a-0
Debugging chains | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/how_to/debugging
3d35fee08c4a-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toAsync APIDifferent call methodsCustom chainDebugging chainsLoading from LangChainHubAdding memory (state)SerializationFoundationalDocume...
https://python.langchain.com/docs/modules/chains/how_to/debugging
2b6b4e0e208b-0
Loading from LangChainHub | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/how_to/from_hub
2b6b4e0e208b-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toAsync APIDifferent call methodsCustom chainDebugging chainsLoading from LangChainHubAdding memory (state)SerializationFoundationalDocume...
https://python.langchain.com/docs/modules/chains/how_to/from_hub
2b6b4e0e208b-2
local API. Using DuckDB in-memory for database. Data will be transient.chain = load_chain("lc://chains/vector-db-qa/stuff/chain.json", vectorstore=vectorstore)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 Appe...
https://python.langchain.com/docs/modules/chains/how_to/from_hub
1070e46081c2-0
Async API | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/how_to/async_chain
1070e46081c2-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toAsync APIDifferent call methodsCustom chainDebugging chainsLoading from LangChainHubAdding memory (state)SerializationFoundationalDocume...
https://python.langchain.com/docs/modules/chains/how_to/async_chain
1070e46081c2-2
input_variables=["product"], template="What is a good name for a company that makes {product}?", ) chain = LLMChain(llm=llm, prompt=prompt) tasks = [async_generate(chain) for _ in range(5)] await asyncio.gather(*tasks)s = time.perf_counter()# If running this outside of Jupyter, use asyncio.run(genera...
https://python.langchain.com/docs/modules/chains/how_to/async_chain
1070e46081c2-3
Serial executed in 6.38 seconds.PreviousHow toNextDifferent call methodsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright © 2023 LangChain, Inc.
https://python.langchain.com/docs/modules/chains/how_to/async_chain
991945926421-0
Popular | 🦜�🔗 Langchain Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalDocumentsPopularAPI chainsRetrieval QAConversational Retrieval QAUsing OpenAI functions...
https://python.langchain.com/docs/modules/chains/popular/
a2555e1d69a8-0
Retrieval QA | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/popular/vector_db_qa
a2555e1d69a8-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalDocumentsPopularAPI chainsRetrieval QAConversational Retrieval QAUsing OpenAI functionsSQLSummarizationAdditionalMemoryAgent...
https://python.langchain.com/docs/modules/chains/popular/vector_db_qa
a2555e1d69a8-2
and use in the RetrievalQA chain. For a more detailed walkthrough of these types, please see this notebook.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, i...
https://python.langchain.com/docs/modules/chains/popular/vector_db_qa
a2555e1d69a8-3
former top litigator in private practice, a former federal public defender, and from a family of public school educators and police officers. He also said that she is a consensus builder and has received a broad range of support from the Fraternal Order of Police to former judges appointed by Democrats and Republicans....
https://python.langchain.com/docs/modules/chains/popular/vector_db_qa
a2555e1d69a8-4
return_source_documents=True)query = "What did the president say about Ketanji Brown Jackson"result = qa({"query": query})result["result"] " The president said that Ketanji Brown Jackson is one of the nation's top legal minds, a former top litigator in private practice and a former federal public defender from a fam...
https://python.langchain.com/docs/modules/chains/popular/vector_db_qa
a2555e1d69a8-5
the Fraternal Order of Police to former judges appointed by Democrats and Republicans. \n\nAnd if we are to advance liberty and justice, we need to secure the Border and fix the immigration system. \n\nWe can do both. At our border, we’ve installed new technology like cutting-edge scanners to better detect drug smugg...
https://python.langchain.com/docs/modules/chains/popular/vector_db_qa
a2555e1d69a8-6
metadata={'source': '../../state_of_the_union.txt'}, lookup_index=0), 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...
https://python.langchain.com/docs/modules/chains/popular/vector_db_qa
a2555e1d69a8-7
"What did the president say about Justice Breyer"}, return_only_outputs=True) {'answer': ' The president honored Justice Breyer for his service and mentioned his legacy of excellence.\n', 'sources': '31-pl'}PreviousAPI chainsNextConversational Retrieval QACommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogC...
https://python.langchain.com/docs/modules/chains/popular/vector_db_qa
c3a547b5ea13-0
API chains | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/popular/api
c3a547b5ea13-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalDocumentsPopularAPI chainsRetrieval QAConversational Retrieval QAUsing OpenAI functionsSQLSummarizationAdditionalMemoryAgent...
https://python.langchain.com/docs/modules/chains/popular/api
c3a547b5ea13-2
> Finished chain. ' The current temperature in Munich, Germany is 33.4 degrees Fahrenheit with a windspeed of 6.8 km/h and a wind direction of 198 degrees. The weathercode is 2.'TMDB Example​import osos.environ['TMDB_BEARER_TOKEN'] = ""from langchain.chains.api import tmdb_docsheaders = {"Authorization": f"Bearer ...
https://python.langchain.com/docs/modules/chains/popular/api
c3a547b5ea13-3
The Way of Water","overview":"Set more than a decade after the events of the first film, learn the story of the Sully family (Jake, Neytiri, and their kids), the trouble that follows them, the lengths they go to keep each other safe, the battles they fight to stay alive, and the tragedies they endure.","popularity":394...
https://python.langchain.com/docs/modules/chains/popular/api
c3a547b5ea13-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/docs/modules/chains/popular/api
c3a547b5ea13-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/docs/modules/chains/popular/api
c3a547b5ea13-6
hit television series, Avatar: The Last Airbender, reflect on the creation of the masterful series.","popularity":51.593,"poster_path":"/oBWVyOdntLJd5bBpE0wkpN6B6vy.jpg","release_date":"2010-06-22","title":"Avatar Spirits","video":false,"vote_average":9,"vote_count":16},{"adult":false,"backdrop_path":"/cACUWJKvRfhXge7N...
https://python.langchain.com/docs/modules/chains/popular/api
c3a547b5ea13-7
Production Materials","overview":"Production material overview of what was used in Avatar","popularity":12.389,"poster_path":null,"release_date":"2009-12-18","title":"Avatar: Production Materials","video":true,"vote_average":6,"vote_count":4},{"adult":false,"backdrop_path":"/x43RWEZg9tYRPgnm43GyIB4tlER.jpg","genre_ids"...
https://python.langchain.com/docs/modules/chains/popular/api
c3a547b5ea13-8
the innate power and potential that lies within humanity to 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_pat...
https://python.langchain.com/docs/modules/chains/popular/api
c3a547b5ea13-9
Ages: Memories","overview":"On the night of memories Avatar performed songs from Thoughts of No Tomorrow, Schlacht and Avatar as voted on by the fans.","popularity":2.66,"poster_path":"/xDNNQ2cnxAv3o7u0nT6JJacQrhp.jpg","release_date":"2021-01-30","title":"Avatar Ages: Memories","video":false,"vote_average":10,"vote_cou...
https://python.langchain.com/docs/modules/chains/popular/api
c3a547b5ea13-10
> 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 osfrom langchain.llms impor...
https://python.langchain.com/docs/modules/chains/popular/api
4da1e06043c4-0
Conversational Retrieval QA | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/popular/chat_vector_db
4da1e06043c4-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalDocumentsPopularAPI chainsRetrieval QAConversational Retrieval QAUsing OpenAI functionsSQLSummarizationAdditionalMemoryAgent...
https://python.langchain.com/docs/modules/chains/popular/chat_vector_db
4da1e06043c4-2
= CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)documents = text_splitter.split_documents(documents)embeddings = OpenAIEmbeddings()vectorstore = Chroma.from_documents(documents, embeddings) Using embedded DuckDB without persistence: data will be transientWe can now create a memory object, which is necessary...
https://python.langchain.com/docs/modules/chains/popular/chat_vector_db
4da1e06043c4-3
asking a question with no chat historychat_history = []query = "What did the president say about Ketanji Brown Jackson"result = qa({"question": query, "chat_history": chat_history})result["answer"] " The president said that Ketanji Brown Jackson is one of the nation's top legal minds, a former top litigator in priva...
https://python.langchain.com/docs/modules/chains/popular/chat_vector_db
4da1e06043c4-4
vectorstore.as_retriever(), condense_question_llm = ChatOpenAI(temperature=0, model='gpt-3.5-turbo'),)chat_history = []query = "What did the president say about Ketanji Brown Jackson"result = qa({"question": query, "chat_history": chat_history})chat_history = [(query, result["answer"])]query = "Did he mention who sh...
https://python.langchain.com/docs/modules/chains/popular/chat_vector_db
4da1e06043c4-5
Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence.', metadata={'source': '../../state_of_the_union.txt'})ConversationalRetrievalChain with search_distance​If you are using a vector store that supports filtering by search distance, you can add a threshold v...
https://python.langchain.com/docs/modules/chains/popular/chat_vector_db
4da1e06043c4-6
one of the nation's top legal minds, a former top litigator in private practice, a former federal public defender, from a family of public school educators and police officers, a consensus builder, and has received a broad range of support from the Fraternal Order of Police to former judges appointed by Democrats and R...
https://python.langchain.com/docs/modules/chains/popular/chat_vector_db
4da1e06043c4-7
import StreamingStdOutCallbackHandlerfrom langchain.chains.conversational_retrieval.prompts import CONDENSE_QUESTION_PROMPT, QA_PROMPTfrom langchain.chains.question_answering import load_qa_chain# Construct a ConversationalRetrievalChain with a streaming llm for combine docs# and a separate, non-streaming llm for quest...
https://python.langchain.com/docs/modules/chains/popular/chat_vector_db
4da1e06043c4-8
used to format the chat_history string.def get_chat_history(inputs) -> str: res = [] for human, ai in inputs: res.append(f"Human:{human}\nAI:{ai}") return "\n".join(res)qa = ConversationalRetrievalChain.from_llm(OpenAI(temperature=0), vectorstore.as_retriever(), get_chat_history=get_chat_history)chat_hi...
https://python.langchain.com/docs/modules/chains/popular/chat_vector_db
23d1bce49020-0
SQL | 🦜�🔗 Langchain
https://python.langchain.com/docs/modules/chains/popular/sqlite
23d1bce49020-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsHow toFoundationalDocumentsPopularAPI chainsRetrieval QAConversational Retrieval QAUsing OpenAI functionsSQLSummarizationAdditionalMemoryAgent...
https://python.langchain.com/docs/modules/chains/popular/sqlite
23d1bce49020-2
To set it up, follow the instructions on https://database.guide/2-sample-databases-sqlite/, placing the .db file in a notebooks folder at the root of this repository.from langchain import OpenAI, SQLDatabase, SQLDatabaseChaindb = SQLDatabase.from_uri("sqlite:///../../../../notebooks/Chinook.db")llm = OpenAI(temperature...
https://python.langchain.com/docs/modules/chains/popular/sqlite
23d1bce49020-3
to try and fix the SQL using the LLM. You can simply specify this option when creating the chain:db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True, use_query_checker=True)db_chain.run("How many albums by Aerosmith?") > Entering new SQLDatabaseChain chain... How many albums by Aerosmith? SQLQue...
https://python.langchain.com/docs/modules/chains/popular/sqlite
23d1bce49020-4
chain... How many employees are there in the foobar table? SQLQuery:SELECT COUNT(*) FROM Employee; SQLResult: [(8,)] Answer:There are 8 employees in the foobar table. > Finished chain. 'There are 8 employees in the foobar table.'Return Intermediate Steps​You can also return the intermediate steps of...
https://python.langchain.com/docs/modules/chains/popular/sqlite
23d1bce49020-5
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, \n\t"FirstName" NVARCHAR(20) NOT NULL, \n\t"Title" NVARCHAR(30), \n\t"ReportsTo" INTEGER, \n\t"BirthDate" DAT...
https://python.langchain.com/docs/modules/chains/popular/sqlite
23d1bce49020-6
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-04-01 00:00:00\t1111 6 Ave SW\tCalgary\tAB\tCanada\tT2P 5M5\t+1 (403) 262-3443\t+1 (403) 262-...
https://python.langchain.com/docs/modules/chains/popular/sqlite
23d1bce49020-7
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" INTEGER NOT NULL, \n\tPRIMARY KEY ("AlbumId"), \n\tFOREIGN KEY("ArtistId") REFERENCES "Artist" ("...
https://python.langchain.com/docs/modules/chains/popular/sqlite
23d1bce49020-8
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 Campo...
https://python.langchain.com/docs/modules/chains/popular/sqlite
23d1bce49020-9
NUMERIC(10, 2) NOT NULL, \n\tPRIMARY 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-Heu...
https://python.langchain.com/docs/modules/chains/popular/sqlite
23d1bce49020-10
REFERENCES "Album" ("AlbumId")\n)\n\n/*\n3 rows from Track table:\nTrackId\tName\tAlbumId\tMediaTypeId\tGenreId\tComposer\tMilliseconds\tBytes\tUnitPrice\n1\tFor 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\t...
https://python.langchain.com/docs/modules/chains/popular/sqlite