id stringlengths 14 16 | text stringlengths 31 2.73k | source stringlengths 56 166 |
|---|---|---|
5d5c171ee09e-9 | {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_st... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-10 | 0 on_llm_start OpenAI 1 1 0 0 0 0
1 on_llm_start OpenAI 1 1 0 0 0 0
2 on_llm_start OpenAI 1 1 0 0 0 0
3 on_llm_start OpenAI 1 1 0 0 0 0
... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-11 | 14 on_llm_start OpenAI 3 2 1 0 0 0
15 on_llm_start OpenAI 3 2 1 0 0 0
16 on_llm_start OpenAI 3 2 1 0 0 0
17 on_llm_start OpenAI 3 2 1 0 0 0
... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-12 | 5 0 1 ... NaN NaN
6 0 1 ... 0.0 5.5
7 0 1 ... 2.0 6.5
8 0 1 ... 0.0 5.5
9 0 ... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-13 | 0 NaN NaN NaN NaN
1 NaN NaN NaN NaN
2 NaN NaN NaN NaN
3 NaN NaN NaN NaN
4 NaN N... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-14 | 21 8.28 6th and 7th grade 115.58 112.37
22 5.20 5th and 6th grade 133.58 131.54
23 8.28 6th and 7th grade 115.58 112.37
gutierrez_polini crawford gulpease_index osman
0 NaN NaN NaN ... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-15 | 19 54.83 1.4 72.1 100.17
20 62.30 -0.2 79.8 116.91
21 54.83 1.4 72.1 100.17
22 62.30 -0.2 79.8 116.91
23 54.83 1.4 72.1 100.17
[24 rows x 39 columns], 'session_an... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-16 | 2 \n\nQ: What did the fish say when it hit the w...
3 \n\nRoses are red,\nViolets are blue,\nSugar i...
4 \n\nQ: What did the fish say when it hit the w...
5 \n\nRoses are red,\nViolets are blue,\nSugar i...
6 \n\nQ: What did the fish say when it hit the w...
7 \n\nRoses are red,\nViolets are... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-17 | 1 138 83.66 4.8
2 138 109.04 1.3
3 138 83.66 4.8
4 138 109.04 1.3
... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-18 | 10 ... 0 5.5 5.20
11 ... 2 6.5 8.28
text_standard fernandez_huerta szigriszt_pazos gutierrez_polini \
0 5th and 6th grade 133.58 131.54 62.30
1 6th and 7th grade 115... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-19 | crawford gulpease_index osman
0 -0.2 79.8 116.91
1 1.4 72.1 100.17
2 -0.2 79.8 116.91
3 1.4 72.1 100.17
4 -0.2 79.8 116.91
5 1.4 72.1 100.17
6 -0.2 79.8 116.91
7 1.4 ... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-20 | Finally, if you enabled visualizations, these are stored as HTML files under debug samples.
Scenario 2: Creating an agent with tools#
To show a more advanced workflow, let’s create an agent with access to tools. The way ClearML tracks the results is not different though, only the table will look slightly different as t... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-21 | {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 2, 'starts': 2, 'ends': 0, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 1, 'llm_ends': 0, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'prompts': 'Answer the following questions as best you can. You have access... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-22 | {'action': 'on_llm_end', 'token_usage_prompt_tokens': 189, 'token_usage_completion_tokens': 34, 'token_usage_total_tokens': 223, 'model_name': 'text-davinci-003', 'step': 3, 'starts': 2, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 1, 'llm_ends': 1, 'llm_streams': 0, 'tool_st... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-23 | I need to find out who sang summer of 69 and then find out who their wife is.
Action: Search
Action Input: "Who sang summer of 69"{'action': 'on_agent_action', 'tool': 'Search', 'tool_input': 'Who sang summer of 69', 'log': ' I need to find out who sang summer of 69 and then find out who their wife is.\nAction: Search\... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-24 | Observation: Bryan Adams - Summer Of 69 (Official Music Video).
Thought:{'action': 'on_tool_end', 'output': 'Bryan Adams - Summer Of 69 (Official Music Video).', 'step': 6, 'starts': 4, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 1, 'llm_ends': 1, 'llm_streams': 0, 'tool_sta... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-25 | {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 7, 'starts': 5, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 2, 'tool_ends': 1, 'agent_ends': 0, 'prompts': 'Answer the following questions as best you can. You have access... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-26 | {'action': 'on_llm_end', 'token_usage_prompt_tokens': 242, 'token_usage_completion_tokens': 28, 'token_usage_total_tokens': 270, 'model_name': 'text-davinci-003', 'step': 8, 'starts': 5, 'ends': 3, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_st... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-27 | I need to find out who Bryan Adams is married to.
Action: Search
Action Input: "Who is Bryan Adams married to"{'action': 'on_agent_action', 'tool': 'Search', 'tool_input': 'Who is Bryan Adams married to', 'log': ' I need to find out who Bryan Adams is married to.\nAction: Search\nAction Input: "Who is Bryan Adams marri... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-28 | Thought:{'action': 'on_tool_end', 'output': 'Bryan Adams has never married. In the 1990s, he was in a relationship with Danish model Cecilie Thomsen. In 2011, Bryan and Alicia Grimaldi, his ...', 'step': 11, 'starts': 7, 'ends': 4, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 2, 'llm_en... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-29 | {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 12, 'starts': 8, 'ends': 4, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 3, 'llm_ends': 2, 'llm_streams': 0, 'tool_starts': 4, 'tool_ends': 2, 'agent_ends': 0, 'prompts': 'Answer the following questions as best you can. You have acces... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-30 | Bryan Adams has never married. In the 1990s, he was in a relationship with Danish model Cecilie Thomsen. In 2011, Bryan and Alicia Grimaldi, his ...\nThought:'} | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-31 | {'action': 'on_llm_end', 'token_usage_prompt_tokens': 314, 'token_usage_completion_tokens': 18, 'token_usage_total_tokens': 332, 'model_name': 'text-davinci-003', 'step': 13, 'starts': 8, 'ends': 5, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 3, 'llm_ends': 3, 'llm_streams': 0, 'tool_s... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-32 | I now know the final answer.
Final Answer: Bryan Adams has never been married.
{'action': 'on_agent_finish', 'output': 'Bryan Adams has never been married.', 'log': ' I now know the final answer.\nFinal Answer: Bryan Adams has never been married.', 'step': 14, 'starts': 8, 'ends': 6, 'errors': 0, 'text_ctr': 0, 'chain_... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-33 | 4 on_llm_start OpenAI 1 1 0 0 0
.. ... ... ... ... ... ... ...
66 on_tool_end NaN 11 7 4 0 0
67 on_llm_start OpenAI 12 8 4 0 0
68 on_llm_end NaN 13 8 ... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-34 | 69 1 0 3 ... NaN NaN NaN
70 1 1 3 ... NaN NaN NaN
tool tool_input log \
0 NaN NaN NaN
1 NaN ... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-35 | 0 2 Answer the following questions as best you can... OpenAI
1 7 Answer the following questions as best you can... OpenAI
2 12 Answer the following questions as best you can... OpenAI
output_step output \
0 3 I n... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
5d5c171ee09e-36 | 2 3rd and 4th grade 115.70 110.84 49.79
crawford gulpease_index osman
0 0.9 72.7 92.16
1 0.7 74.7 84.20
2 0.7 85.4 83.14
[3 rows x 24 columns]}
Could not update last created model in Task 988bd727b0e94a29a3ac0ee526813545... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/clearml_tracking.html |
6c8edc076138-0 | .ipynb
.pdf
Weights & Biases
Weights & Biases#
This notebook goes over how to track your LangChain experiments into one centralized Weights and Biases dashboard. To learn more about prompt engineering and the callback please refer to this Report which explains both alongside the resultant dashboards you can expect to s... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/wandb_tracking.html |
6c8edc076138-1 | notes (str): The notes to log.
visualize (bool): Whether to visualize the run.
complexity_metrics (bool): Whether to log complexity metrics.
stream_logs (bool): Whether to stream callback actions to W&B
Default values for WandbCallbackHandler(...)
visualize: bool = False,
complexity_metrics: bool = False,
s... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/wandb_tracking.html |
6c8edc076138-2 | Tracking run with wandb version 0.14.0Run data is saved locally in /Users/harrisonchase/workplace/langchain/docs/ecosystem/wandb/run-20230318_150408-e47j1914Syncing run llm to Weights & Biases (docs) View project at https://wandb.ai/harrison-chase/langchain_callback_demo View run at https://wandb.ai/harrison-chase/lang... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/wandb_tracking.html |
6c8edc076138-3 | wandb_callback.flush_tracker(llm, name="simple_sequential")
Waiting for W&B process to finish... (success). View run llm at: https://wandb.ai/harrison-chase/langchain_callback_demo/runs/e47j1914Synced 5 W&B file(s), 2 media file(s), 5 artifact file(s) and 0 other file(s)Find logs at: ./wandb/run-20230318_150408-e47j191... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/wandb_tracking.html |
6c8edc076138-4 | ]
synopsis_chain.apply(test_prompts)
wandb_callback.flush_tracker(synopsis_chain, name="agent")
Waiting for W&B process to finish... (success). View run simple_sequential at: https://wandb.ai/harrison-chase/langchain_callback_demo/runs/jyxma7huSynced 4 W&B file(s), 2 media file(s), 6 artifact file(s) and 0 other file(s... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/wandb_tracking.html |
6c8edc076138-5 | Action: Search
Action Input: "Leo DiCaprio girlfriend"
Observation: DiCaprio had a steady girlfriend in Camila Morrone. He had been with the model turned actress for nearly five years, as they were first said to be dating at the end of 2017. And the now 26-year-old Morrone is no stranger to Hollywood.
Thought: I need t... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/wandb_tracking.html |
cabff5a11716-0 | .md
.pdf
GPT4All
Contents
Installation and Setup
Usage
GPT4All
Model File
GPT4All#
This page covers how to use the GPT4All wrapper within LangChain. The tutorial is divided into two parts: installation and setup, followed by usage with an example.
Installation and Setup#
Install the Python package with pip install py... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/gpt4all.html |
cabff5a11716-1 | You can find links to model file downloads in the pyllamacpp repository.
For a more detailed walkthrough of this, see this notebook
previous
GooseAI
next
Graphsignal
Contents
Installation and Setup
Usage
GPT4All
Model File
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 1... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/gpt4all.html |
211d673a88a3-0 | .md
.pdf
GooseAI
Contents
Installation and Setup
Wrappers
LLM
GooseAI#
This page covers how to use the GooseAI ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific GooseAI wrappers.
Installation and Setup#
Install the Python SDK with pip install openai
Get y... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/gooseai.html |
e5830bac927d-0 | .md
.pdf
DeepInfra
Contents
Installation and Setup
Wrappers
LLM
DeepInfra#
This page covers how to use the DeepInfra ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific DeepInfra wrappers.
Installation and Setup#
Get your DeepInfra api key from this link he... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/deepinfra.html |
048c723b9b7d-0 | .md
.pdf
Apify
Contents
Overview
Installation and Setup
Wrappers
Utility
Loader
Apify#
This page covers how to use Apify within LangChain.
Overview#
Apify is a cloud platform for web scraping and data extraction,
which provides an ecosystem of more than a thousand
ready-made apps called Actors for various scraping, c... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/apify.html |
596c0f3a88d6-0 | .md
.pdf
Graphsignal
Contents
Installation and Setup
Tracing and Monitoring
Graphsignal#
This page covers how to use Graphsignal to trace and monitor LangChain. Graphsignal enables full visibility into your application. It provides latency breakdowns by chains and tools, exceptions with full context, data monitoring,... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/graphsignal.html |
94f9c61ffa10-0 | .md
.pdf
NLPCloud
Contents
Installation and Setup
Wrappers
LLM
NLPCloud#
This page covers how to use the NLPCloud ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific NLPCloud wrappers.
Installation and Setup#
Install the Python SDK with pip install nlpcloud... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/nlpcloud.html |
49a82bce0889-0 | .md
.pdf
OpenAI
Contents
Installation and Setup
Wrappers
LLM
Embeddings
Tokenizer
Moderation
OpenAI#
This page covers how to use the OpenAI ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific OpenAI wrappers.
Installation and Setup#
Install the Python SDK w... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/openai.html |
49a82bce0889-1 | Contents
Installation and Setup
Wrappers
LLM
Embeddings
Tokenizer
Moderation
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 18, 2023. | https://langchain-cn.readthedocs.io/en/latest/ecosystem/openai.html |
4c80f772c835-0 | .md
.pdf
AI21 Labs
Contents
Installation and Setup
Wrappers
LLM
AI21 Labs#
This page covers how to use the AI21 ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific AI21 wrappers.
Installation and Setup#
Get an AI21 api key and set it as an environment varia... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/ai21.html |
c2e3d0cb5fa1-0 | .md
.pdf
Deep Lake
Contents
Why Deep Lake?
More Resources
Installation and Setup
Wrappers
VectorStore
Deep Lake#
This page covers how to use the Deep Lake ecosystem within LangChain.
Why Deep Lake?#
More than just a (multi-modal) vector store. You can later use the dataset to fine-tune your own LLM models.
Not only s... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/deeplake.html |
7d2a6956b57a-0 | .md
.pdf
PromptLayer
Contents
Installation and Setup
Wrappers
LLM
PromptLayer#
This page covers how to use PromptLayer within LangChain.
It is broken into two parts: installation and setup, and then references to specific PromptLayer wrappers.
Installation and Setup#
If you want to work with PromptLayer:
Install the ... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/promptlayer.html |
7d2a6956b57a-1 | you can add pl_tags when instantializing to tag your requests on PromptLayer
you can add return_pl_id when instantializing to return a PromptLayer request id to use while tracking requests.
PromptLayer also provides native wrappers for PromptLayerChatOpenAI and PromptLayerOpenAIChat
previous
Pinecone
next
Qdrant
Conte... | https://langchain-cn.readthedocs.io/en/latest/ecosystem/promptlayer.html |
d0c242a0650e-0 | .ipynb
.pdf
Tracing Walkthrough
Tracing Walkthrough#
import os
os.environ["LANGCHAIN_HANDLER"] = "langchain"
## Uncomment this if using hosted setup.
# os.environ["LANGCHAIN_ENDPOINT"] = "https://langchain-api-gateway-57eoxz8z.uc.gateway.dev"
## Uncomment this if you want traces to be recorded to "my_session" instead ... | https://langchain-cn.readthedocs.io/en/latest/tracing/agent_with_tracing.html |
d0c242a0650e-1 | # Agent run with tracing using a chat model
agent = initialize_agent(
tools, ChatOpenAI(temperature=0), agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)
agent.run("What is 2 raised to .123243 power?")
> Entering new AgentExecutor chain...
Question: What is 2 raised to .123243 power?
Thought: I need a cal... | https://langchain-cn.readthedocs.io/en/latest/tracing/agent_with_tracing.html |
d0c242a0650e-2 | '1.0891804557407723'
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 18, 2023. | https://langchain-cn.readthedocs.io/en/latest/tracing/agent_with_tracing.html |
bc96a952b099-0 | .md
.pdf
Cloud Hosted Setup
Contents
Installation
Environment Setup
Cloud Hosted Setup#
We offer a hosted version of tracing at langchainplus.vercel.app. You can use this to view traces from your run without having to run the server locally.
Note: we are currently only offering this to a limited number of users. The ... | https://langchain-cn.readthedocs.io/en/latest/tracing/hosted_installation.html |
bc96a952b099-1 | os.environ["LANGCHAIN_API_KEY"] = "my_api_key" # Don't commit this to your repo! Better to set it in your terminal.
Contents
Installation
Environment Setup
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 18, 2023. | https://langchain-cn.readthedocs.io/en/latest/tracing/hosted_installation.html |
bd6a53d3f809-0 | .md
.pdf
Locally Hosted Setup
Contents
Installation
Environment Setup
Locally Hosted Setup#
This page contains instructions for installing and then setting up the environment to use the locally hosted version of tracing.
Installation#
Ensure you have Docker installed (see Get Docker) and that it’s running.
Install th... | https://langchain-cn.readthedocs.io/en/latest/tracing/local_installation.html |
bd6a53d3f809-1 | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 18, 2023. | https://langchain-cn.readthedocs.io/en/latest/tracing/local_installation.html |
b6e40c6e5678-0 | .rst
.pdf
Agents
Contents
Go Deeper
Agents#
Note
Conceptual Guide
Some applications will require not just a predetermined chain of calls to LLMs/other tools,
but potentially an unknown chain that depends on the user’s input.
In these types of chains, there is a “agent” which has access to a suite of tools.
Depending ... | https://langchain-cn.readthedocs.io/en/latest/modules/agents.html |
9013f6c382ba-0 | .rst
.pdf
Models(模型)
Contents
深入了解
Models(模型)#
这份文档的这一部分涉及到 LangChain 中使用的不同类型的模型。在本页中,我们将高层次地讨论这些模型类型,同时我们也会为每个模型类型单独创建页面。
这些页面包含更详细的关于如何使用该模型的指南,以及不同模型提供商的列表。
LLMs
大型语言模型(LLMs)是我们涵盖的第一种模型类型。这些模型以文本串作为输入,并返回文本串作为输出。
Chat Models
聊天模型是我们涵盖的第二种模型类型。这些模型通常由语言模型支持,但它们的 API 更为结构化。具体而言,这些模型以聊天消息列表作为输入,并返回聊天消息。
Text Embeddi... | https://langchain-cn.readthedocs.io/en/latest/modules/models.html |
d76296577dae-0 | .rst
.pdf
Chains
Chains#
Note
Conceptual Guide
Using an LLM in isolation is fine for some simple applications,
but many more complex ones require chaining LLMs - either with each other or with other experts.
LangChain provides a standard interface for Chains, as well as some common implementations of chains for ease of... | https://langchain-cn.readthedocs.io/en/latest/modules/chains.html |
9783b636818d-0 | .rst
.pdf
Prompts
Contents
Go Deeper
Prompts#
Note
Conceptual Guide
The new way of programming models is through prompts.
A “prompt” refers to the input to the model.
This input is rarely hard coded, but rather is often constructed from multiple components.
A PromptTemplate is responsible for the construction of this... | https://langchain-cn.readthedocs.io/en/latest/modules/prompts.html |
b026fabd1e9b-0 | .rst
.pdf
Memory
Memory#
Note
Conceptual Guide
By default, Chains and Agents are stateless,
meaning that they treat each incoming query independently (as are the underlying LLMs and chat models).
In some applications (chatbots being a GREAT example) it is highly important
to remember previous interactions, both at a sh... | https://langchain-cn.readthedocs.io/en/latest/modules/memory.html |
cd2cc2440291-0 | .rst
.pdf
Indexes
Contents
Go Deeper
Indexes#
Note
Conceptual Guide
Indexes refer to ways to structure documents so that LLMs can best interact with them.
This module contains utility functions for working with documents, different types of indexes, and then examples for using those indexes in chains.
The most common... | https://langchain-cn.readthedocs.io/en/latest/modules/indexes.html |
cd2cc2440291-1 | previous
Structured Output Parser
next
Getting Started
Contents
Go Deeper
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 18, 2023. | https://langchain-cn.readthedocs.io/en/latest/modules/indexes.html |
f81a9428b6bc-0 | .ipynb
.pdf
Getting Started
Contents
Why do we need chains?
Query an LLM with the LLMChain
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 LangChain. We will learn how to create a chain, add components ... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/getting_started.html |
f81a9428b6bc-1 | print(chain.run("colorful socks"))
Rainbow Socks Co.
You can use a chat model in an LLMChain as well:
from langchain.chat_models import ChatOpenAI
from langchain.prompts.chat import (
ChatPromptTemplate,
HumanMessagePromptTemplate,
)
human_message_prompt = HumanMessagePromptTemplate(
prompt=PromptTempla... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/getting_started.html |
f81a9428b6bc-2 | template="Write a catchphrase for the following company: {company_name}",
)
chain_two = LLMChain(llm=llm, prompt=second_prompt)
Now we can combine the two LLMChains, so that we can create a company name and a catchphrase in a single step.
from langchain.chains import SimpleSequentialChain
overall_chain = SimpleSequenti... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/getting_started.html |
f81a9428b6bc-3 | return list(all_input_vars)
@property
def output_keys(self) -> List[str]:
return ['concat_output']
def _call(self, inputs: Dict[str, str]) -> Dict[str, str]:
output_1 = self.chain_1.run(inputs)
output_2 = self.chain_2.run(inputs)
return {'concat_output': output_1 + output_2}
... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/getting_started.html |
0971707588bb-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 ... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/how_to_guides.html |
fbbbcc210e55-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://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/api.html |
fbbbcc210e55-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://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/api.html |
fbbbcc210e55-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://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/api.html |
fbbbcc210e55-3 | The Way of Water","video":false,"vote_average":7.7,"vote_count":4219},{"adult":false,"backdrop_path":"/uEwGFGtao9YG2JolmdvtHLLVbA9.jpg","genre_ids":[99],"id":111332,"original_language":"en","original_title":"Avatar: Creating the World of Pandora","overview":"The Making-of James Cameron's Avatar. It shows interesting pa... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/api.html |
fbbbcc210e55-4 | 3","video":false,"vote_average":0,"vote_count":0},{"adult":false,"backdrop_path":null,"genre_ids":[28,878,12,14],"id":216527,"original_language":"en","original_title":"Avatar 4","overview":"","popularity":162.536,"poster_path":"/qzMYKnT4MG1d0gnhwytr4cKhUvS.jpg","release_date":"2026-12-16","title":"Avatar 4","video":fal... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/api.html |
fbbbcc210e55-5 | Avatar","video":false,"vote_average":7.8,"vote_count":39},{"adult":false,"backdrop_path":"/eoAvHxfbaPOcfiQyjqypWIXWxDr.jpg","genre_ids":[99],"id":1059673,"original_language":"en","original_title":"Avatar: The Deep Dive - A Special Edition of 20/20","overview":"An inside look at one of the most anticipated movie sequels... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/api.html |
fbbbcc210e55-6 | - Au Hellfest 2022","overview":"","popularity":21.992,"poster_path":"/fw6cPIsQYKjd1YVQanG2vLc5HGo.jpg","release_date":"2022-06-26","title":"Avatar - Au Hellfest 2022","video":false,"vote_average":8,"vote_count":4},{"adult":false,"backdrop_path":null,"genre_ids":[],"id":931019,"original_language":"en","original_title":"... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/api.html |
fbbbcc210e55-7 | Agni Kai","overview":"","popularity":9.462,"poster_path":"/y9PrKMUTA6NfIe5FE92tdwOQ2sH.jpg","release_date":"2020-01-18","title":"Avatar: Agni Kai","video":false,"vote_average":7,"vote_count":1},{"adult":false,"backdrop_path":"/e8mmDO7fKK93T4lnxl4Z2zjxXZV.jpg","genre_ids":[],"id":668297,"original_language":"en","origina... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/api.html |
fbbbcc210e55-8 | the summer of 2001 by drummer John Alfredsson and vocalist Christian Rimmi under the name Lost Soul. The band offers a free mp3 download to a song called \"Bloody Knuckles\" if one subscribes to their newsletter. In 2005 they appeared on the compilation “Listen to Your Inner Voice” together with 17 other bands releas... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/api.html |
fbbbcc210e55-9 | the night of madness Avatar performed songs from Black Waltz and Hail The Apocalypse as voted on by the fans.","popularity":2.024,"poster_path":"/wVyTuruUctV3UbdzE5cncnpyNoY.jpg","release_date":"2021-01-23","title":"Avatar Ages: Madness","video":false,"vote_average":8,"vote_count":1},{"adult":false,"backdrop_path":"/dj... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/api.html |
fbbbcc210e55-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 os
from langchain.llms import ... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/api.html |
9d32ac40e180-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://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/llm_requests.html |
e95c52c66e48-0 | .ipynb
.pdf
OpenAPI Chain
Contents
Load the spec
Select the Operation
Construct the chain
Return raw response
Example POST message
OpenAPI Chain#
This notebook shows an example of using an OpenAPI chain to call an endpoint in natural language, and get back a response in natural language
from langchain.tools import Op... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-1 | llm,
requests=Requests(),
verbose=True,
return_intermediate_steps=True # Return request and response text
)
output = chain("whats the most expensive shirt?")
> Entering new OpenAPIEndpointChain chain...
> Entering new APIRequesterChain chain...
Prompt after formatting:
You are a helpful AI Assistant. Plea... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-2 | ARGS: ```json
{valid json conforming to API_SCHEMA}
```
Example
-----
ARGS: ```json
{"foo": "bar", "baz": {"qux": "quux"}}
```
The block must be no more than 1 line long, and all arguments must be valid JSON. All string arguments must be wrapped in double quotes.
You MUST strictly comply to the types indicated by the p... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-3 | You attempted to call an API, which resulted in:
API_RESPONSE: {"products":[{"name":"Burberry Check Poplin Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201810981/Clothing/Burberry-Check-Poplin-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$360.00","attributes":["Material:Cotton","Target Grou... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-4 | 'response_text': '{"products":[{"name":"Burberry Check Poplin Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201810981/Clothing/Burberry-Check-Poplin-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$360.00","attributes":["Material:Cotton","Target Group:Man","Color:Gray,Blue,Beige","Properties:Po... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-5 | q: string,
/* number of products returned */
size?: number,
/* (Optional) Minimum price in local currency for the product searched for. Either explicitly stated by the user or implicitly inferred from a combination of the user's request and the kind of product searched for. */
min_price?: number,
/* (Optional) Maxi... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-6 | {"products":[{"name":"Burberry Check Poplin Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201810981/Clothing/Burberry-Check-Poplin-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$360.00","attributes":["Material:Cotton","Target Group:Man","Color:Gray,Blue,Beige","Properties:Pockets","Pattern:Ch... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-7 | Outdoors Laguna Madre Solid Short Sleeve Fishing Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3203102142/Clothing/Magellan-Outdoors-Laguna-Madre-Solid-Short-Sleeve-Fishing-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$19.99","attributes":["Material:Polyester,Nylon","Target Group:Man","Color:... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-8 | > Finished chain.
output
{'instructions': 'whats the most expensive shirt?', | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-9 | 'output': '{"products":[{"name":"Burberry Check Poplin Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201810981/Clothing/Burberry-Check-Poplin-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$360.00","attributes":["Material:Cotton","Target Group:Man","Color:Gray,Blue,Beige","Properties:Pockets",... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-10 | Group:Man","Color:Beige"]},{"name":"Magellan Outdoors Laguna Madre Solid Short Sleeve Fishing Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3203102142/Clothing/Magellan-Outdoors-Laguna-Madre-Solid-Short-Sleeve-Fishing-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$19.99","attributes":["Materia... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-11 | 'intermediate_steps': {'request_args': '{"q": "shirt", "max_price": null}', | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-12 | 'response_text': '{"products":[{"name":"Burberry Check Poplin Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201810981/Clothing/Burberry-Check-Poplin-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$360.00","attributes":["Material:Cotton","Target Group:Man","Color:Gray,Blue,Beige","Properties:Po... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-13 | Group:Man","Color:Beige"]},{"name":"Magellan Outdoors Laguna Madre Solid Short Sleeve Fishing Shirt","url":"https://www.klarna.com/us/shopping/pl/cl10001/3203102142/Clothing/Magellan-Outdoors-Laguna-Madre-Solid-Short-Sleeve-Fishing-Shirt/?utm_source=openai&ref-site=openai_plugin","price":"$19.99","attributes":["Materia... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-14 | Example POST message#
For this demo, we will interact with the speak API.
spec = OpenAPISpec.from_url("https://api.speak.com/openapi.yaml")
Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support.
Attempting to load an OpenAPI 3.0.1 ... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-15 | learning_language?: string,
/* The user's native language. Infer this value from the language the user asked their question in. Always use the full name of the language (e.g. Spanish, French). */
native_language?: string,
/* A description of any additional context in the user's question that could affect the explanat... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-16 | {"explanation":"<what-to-say language=\"Hindi\" context=\"None\">\nऔर चाय लाओ। (Aur chai lao.) \n</what-to-say>\n\n<alternatives context=\"None\">\n1. \"चाय थोड़ी ज्यादा मिल सकती है?\" *(Chai thodi zyada mil sakti hai? - Polite, asking if more tea is available)*\n2. \"मुझे महसूस हो रहा है कि मुझे कुछ अन्य प्रकार की चाय... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-17 | सर, क्या main aur cups chai lekar aaun? (Sir,kya main aur cups chai lekar aaun? - Sir, should I get more tea cups?)\nRahul: हां,बिल्कुल। और चाय की मात्रा में भी थोड़ा सा इजाफा करना। (Haan,bilkul. Aur chai ki matra mein bhi thoda sa eejafa karna. - Yes, please. And add a little extra in the quantity of tea as well.)\n</... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-18 | > Entering new APIResponderChain chain...
Prompt after formatting:
You are a helpful AI assistant trained to answer user queries from API responses.
You attempted to call an API, which resulted in: | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-19 | API_RESPONSE: {"explanation":"<what-to-say language=\"Hindi\" context=\"None\">\nऔर चाय लाओ। (Aur chai lao.) \n</what-to-say>\n\n<alternatives context=\"None\">\n1. \"चाय थोड़ी ज्यादा मिल सकती है?\" *(Chai thodi zyada mil sakti hai? - Polite, asking if more tea is available)*\n2. \"मुझे महसूस हो रहा है कि मुझे कुछ अन्य... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-20 | सर, क्या main aur cups chai lekar aaun? (Sir,kya main aur cups chai lekar aaun? - Sir, should I get more tea cups?)\nRahul: हां,बिल्कुल। और चाय की मात्रा में भी थोड़ा सा इजाफा करना। (Haan,bilkul. Aur chai ki matra mein bhi thoda sa eejafa karna. - Yes, please. And add a little extra in the quantity of tea as well.)\n</... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
e95c52c66e48-21 | USER_COMMENT: "How would ask for more tea in Delhi?"
If the API_RESPONSE can answer the USER_COMMENT respond with the following markdown json block:
Response: ```json
{"response": "Concise response to USER_COMMENT based on API_RESPONSE."}
```
Otherwise respond with the following markdown json block:
Response Error: ```... | https://langchain-cn.readthedocs.io/en/latest/modules/chains/examples/openapi.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.