id stringlengths 14 16 | source stringlengths 49 117 | text stringlengths 16 2.73k |
|---|---|---|
209ac4e27a65-2 | https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html | "action_input": "The last letter in your name is 'b'. Argentina won the World Cup in 1978."
}
> Finished chain.
"The last letter in your name is 'b'. Argentina won the World Cup in 1978."
agent_chain.run(input="whats the weather like in pomfret?")
> Entering new AgentExecutor chain...
{
"action": "Current Search",
... |
6c087714eb3c-0 | https://python.langchain.com/en/latest/modules/agents/agents/examples/conversational_agent.html | .ipynb
.pdf
Conversation Agent
Conversation Agent#
This notebook walks through using an agent optimized for conversation. Other agents are often optimized for using tools to figure out the best response, which is not ideal in a conversational setting where you may want the agent to be able to chat with the user as well... |
6c087714eb3c-1 | https://python.langchain.com/en/latest/modules/agents/agents/examples/conversational_agent.html | agent_chain.run("what are some good dinners to make this week, if i like thai food?")
> Entering new AgentExecutor chain...
Thought: Do I need to use a tool? Yes
Action: Current Search
Action Input: Thai food dinner recipes
Observation: 59 easy Thai recipes for any night of the week · Marion Grasby's Thai spicy chilli ... |
6c087714eb3c-2 | https://python.langchain.com/en/latest/modules/agents/agents/examples/conversational_agent.html | agent_chain.run(input="whats the current temperature in pomfret?")
> Entering new AgentExecutor chain...
Thought: Do I need to use a tool? Yes
Action: Current Search
Action Input: Current temperature in Pomfret
Observation: Partly cloudy skies. High around 70F. Winds W at 5 to 10 mph. Humidity41%.
Thought: Do I need to... |
35a5046c1615-0 | https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html | .ipynb
.pdf
MRKL
MRKL#
This notebook showcases using an agent to replicate the MRKL chain.
This uses the example Chinook database.
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 L... |
35a5046c1615-1 | https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html | I need to find out who Leo DiCaprio's girlfriend is and then calculate her age raised to the 0.43 power.
Action: Search
Action Input: "Who is Leo DiCaprio's girlfriend?"
Observation: DiCaprio met actor Camila Morrone in December 2017, when she was 20 and he was 43. They were spotted at Coachella and went on multiple va... |
35a5046c1615-2 | https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html | I need to find out the artist's full name and then search the FooBar database for their albums.
Action: Search
Action Input: "The Storm Before the Calm" artist
Observation: The Storm Before the Calm (stylized in all lowercase) is the tenth (and eighth international) studio album by Canadian-American singer-songwriter A... |
35a5046c1615-3 | https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html | Final Answer: The artist who released the album 'The Storm Before the Calm' is Alanis Morissette and the albums of hers in the FooBar database are Jagged Little Pill.
> Finished chain.
"The artist who released the album 'The Storm Before the Calm' is Alanis Morissette and the albums of hers in the FooBar database are J... |
556f3a4fa2e2-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/vectorstore.html | .ipynb
.pdf
Vectorstore Agent
Contents
Create the Vectorstores
Initialize Toolkit and Agent
Examples
Multiple Vectorstores
Examples
Vectorstore Agent#
This notebook showcases an agent designed to retrieve information from one or more vectorstores, either with or without sources.
Create the Vectorstores#
from langchai... |
556f3a4fa2e2-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/vectorstore.html | description="the most recent state of the Union adress",
vectorstore=state_of_union_store
)
toolkit = VectorStoreToolkit(vectorstore_info=vectorstore_info)
agent_executor = create_vectorstore_agent(
llm=llm,
toolkit=toolkit,
verbose=True
)
Examples#
agent_executor.run("What did biden say about ketanji b... |
556f3a4fa2e2-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/vectorstore.html | Observation: {"answer": " Biden said that he nominated Circuit Court of Appeals Judge Ketanji Brown Jackson to the United States Supreme Court, and that she is one of the nation's top legal minds who will continue Justice Breyer's legacy of excellence.\n", "sources": "../../state_of_the_union.txt"}
Thought: I now know ... |
556f3a4fa2e2-3 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/vectorstore.html | agent_executor.run("What did biden say about ketanji brown jackson is the state of the union address?")
> Entering new AgentExecutor chain...
I need to use the state_of_union_address tool to answer this question.
Action: state_of_union_address
Action Input: What did biden say about ketanji brown jackson
Observation: ... |
556f3a4fa2e2-4 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/vectorstore.html | 'Ruff is integrated into nbQA, a tool for running linters and code formatters over Jupyter Notebooks. After installing ruff and nbqa, you can run Ruff over a notebook like so: > nbqa ruff Untitled.ipynb'
agent_executor.run("What tool does ruff use to run over Jupyter Notebooks? Did the president mention that tool in th... |
281dd18d6554-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark_sql.html | .ipynb
.pdf
Spark SQL Agent
Contents
Initialization
Example: describing a table
Example: running queries
Spark SQL Agent#
This notebook shows how to use agents to interact with a Spark SQL. Similar to SQL Database Agent, it is designed to address general inquiries about Spark SQL and facilitate error recovery.
NOTE: ... |
281dd18d6554-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark_sql.html | +-----------+--------+------+--------------------+------+----+-----+-----+----------------+-------+-----+--------+
| 1| 0| 3|Braund, Mr. Owen ...| male|22.0| 1| 0| A/5 21171| 7.25| null| S|
| 2| 1| 1|Cumings, Mrs. Joh...|female|38.0| 1| 0| PC 17599... |
281dd18d6554-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark_sql.html | | 7| 0| 1|McCarthy, Mr. Tim...| male|54.0| 0| 0| 17463|51.8625| E46| S|
| 8| 0| 3|Palsson, Master. ...| male| 2.0| 3| 1| 349909| 21.075| null| S|
| 9| 1| 3|Johnson, Mrs. Osc...|female|27.0| 0| 2| 347742... |
281dd18d6554-3 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark_sql.html | | 14| 0| 3|Andersson, Mr. An...| male|39.0| 1| 5| 347082| 31.275| null| S|
| 15| 0| 3|Vestrom, Miss. Hu...|female|14.0| 0| 0| 350406| 7.8542| null| S|
| 16| 1| 2|Hewlett, Mrs. (Ma...|female|55.0| 0| 0| 248706... |
281dd18d6554-4 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark_sql.html | # Note, you can also connect to Spark via Spark connect. For example:
# db = SparkSQL.from_uri("sc://localhost:15002", schema=schema)
spark_sql = SparkSQL(schema=schema)
llm = ChatOpenAI(temperature=0)
toolkit = SparkSQLToolkit(db=spark_sql, llm=llm)
agent_executor = create_spark_sql_agent(
llm=llm,
toolkit=too... |
281dd18d6554-5 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark_sql.html | 3 1 3 Heikkinen, Miss. Laina female 26.0 0 0 STON/O2. 3101282 7.925 None S
*/
Thought:I now know the schema and sample rows for the titanic table.
Final Answer: The titanic table has the following columns: PassengerId (INT), Survived (INT), Pclass (INT), Name (STRING), Sex (STRING), Age (DOUBLE), SibSp (INT), Parch (IN... |
281dd18d6554-6 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark_sql.html | 'The titanic table has the following columns: PassengerId (INT), Survived (INT), Pclass (INT), Name (STRING), Sex (STRING), Age (DOUBLE), SibSp (INT), Parch (INT), Ticket (STRING), Fare (DOUBLE), Cabin (STRING), and Embarked (STRING). Here are some sample rows from the table: \n\n1. PassengerId: 1, Survived: 0, Pclass:... |
281dd18d6554-7 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark_sql.html | Action: schema_sql_db
Action Input: titanic
Observation: CREATE TABLE langchain_example.titanic (
PassengerId INT,
Survived INT,
Pclass INT,
Name STRING,
Sex STRING,
Age DOUBLE,
SibSp INT,
Parch INT,
Ticket STRING,
Fare DOUBLE,
Cabin STRING,
Embarked STRING)
;
/*
3 rows from titanic table:
Passe... |
281dd18d6554-8 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark_sql.html | Action Input: SELECT SQRT(AVG(Age)) as square_root_of_avg_age FROM titanic
Observation: [('5.449689683556195',)]
Thought:I now know the final answer
Final Answer: The square root of the average age is approximately 5.45.
> Finished chain.
'The square root of the average age is approximately 5.45.'
agent_executor.run("W... |
281dd18d6554-9 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark_sql.html | Thought:I can use the titanic table to find the oldest survived passenger. I will query the Name and Age columns, filtering by Survived and ordering by Age in descending order.
Action: query_checker_sql_db
Action Input: SELECT Name, Age FROM titanic WHERE Survived = 1 ORDER BY Age DESC LIMIT 1
Observation: SELECT Name,... |
3f21eff89532-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | .ipynb
.pdf
OpenAPI agents
Contents
1st example: hierarchical planning agent
To start, let’s collect some OpenAPI specs.
How big is this spec?
Let’s see some examples!
Try another API.
2nd example: “json explorer” agent
OpenAPI agents#
We can construct agents to consume arbitrary APIs, here APIs conformant to the Ope... |
3f21eff89532-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | --2023-03-31 15:45:56-- https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.109.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... conne... |
3f21eff89532-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | --2023-03-31 15:45:57-- https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/spotify.com/1.0.0/openapi.yaml
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.109.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|18... |
3f21eff89532-3 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | You’ll have to set up an application in the Spotify developer console, documented here, to get credentials: CLIENT_ID, CLIENT_SECRET, and REDIRECT_URI.
To get an access tokens (and keep them fresh), you can implement the oauth flows, or you can use spotipy. If you’ve set your Spotify creedentials as environment variabl... |
3f21eff89532-4 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | llm = OpenAI(model_name="gpt-4", temperature=0.0)
/Users/jeremywelborn/src/langchain/langchain/llms/openai.py:169: UserWarning: You are trying to use a chat model. This way of initializing it is no longer supported. Instead, please use: `from langchain.chat_models import ChatOpenAI`
warnings.warn(
/Users/jeremywelbor... |
3f21eff89532-5 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | 2. GET /albums/{id}/tracks to get the tracks from the "Kind of Blue" album
3. GET /me to get the current user's information
4. POST /users/{user_id}/playlists to create a new playlist named "Machine Blues" for the current user
5. POST /playlists/{playlist_id}/tracks to add the first song from "Kind of Blue" to the "Mac... |
3f21eff89532-6 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Action Input: {"url": "https://api.spotify.com/v1/playlists/7lzoEi44WOISnFYlrAIqyX/tracks", "data": {"uris": ["spotify:track:7q3kkfAVpmcZ8g6JUThi3o"]}, "output_instructions": "Confirm that the track was added to the playlist"}
Observation: The track was added to the playlist, confirmed by the snapshot_id: MiwxODMxNTMxZ... |
3f21eff89532-7 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | 3. GET /recommendations with the seed_genre parameter set to "blues" to get a blues song recommendation for the user
Thought:I have the plan, now I need to execute the API calls.
Action: api_controller
Action Input: 1. GET /me to get the current user's information
2. GET /recommendations/available-genre-seeds to retrie... |
3f21eff89532-8 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Observation: acoustic, afrobeat, alt-rock, alternative, ambient, anime, black-metal, bluegrass, blues, bossanova, brazil, breakbeat, british, cantopop, chicago-house, children, chill, classical, club, comedy, country, dance, dancehall, death-metal, deep-house, detroit-techno, disco, disney, drum-and-bass, dub, dubstep,... |
3f21eff89532-9 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | id: '03lXHmokj9qsXspNsPoirR',
name: 'Get Away Jordan'
}
]
Thought:I am finished executing the plan.
Final Answer: The recommended blues song for user Jeremy Welborn (ID: 22rhrz4m4kvpxlsb5hezokzwi) is "Get Away Jordan" with the track ID: 03lXHmokj9qsXspNsPoirR.
> Finished chain.
Observation: The recommended blues ... |
3f21eff89532-10 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Action Input: I need to find the right API calls to generate a short piece of advice
Observation: 1. GET /engines to retrieve the list of available engines
2. POST /completions with the selected engine and a prompt for generating a short piece of advice
Thought:I have the plan, now I need to execute the API calls.
Acti... |
3f21eff89532-11 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Action Input: {"url": "https://api.openai.com/v1/completions", "data": {"engine": "davinci", "prompt": "Give me a short piece of advice on how to be more productive."}, "output_instructions": "Extract the text from the first choice"}
Observation: "you must provide a model parameter"
Thought:!! Could not _extract_tool_a... |
3f21eff89532-12 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Observation: babbage, davinci, text-davinci-edit-001, babbage-code-search-code, text-similarity-babbage-001, code-davinci-edit-001, text-davinci-edit-001, ada
Thought:Action: requests_post
Action Input: {"url": "https://api.openai.com/v1/completions", "data": {"model": "davinci", "prompt": "Give me a short piece of adv... |
3f21eff89532-13 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Action Input: 1. GET /models to retrieve the list of available models
2. Choose a suitable model for generating text (e.g., text-davinci-002)
3. POST /completions with the chosen model and a prompt related to improving communication skills to generate a short piece of advice
> Entering new AgentExecutor chain...
Action... |
3f21eff89532-14 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Here’s an agent that’s not particularly practical, but neat! The agent has access to 2 toolkits. One comprises tools to interact with json: one tool to list the keys of a json object and another tool to get the value for a given key. The other toolkit comprises requests wrappers to send GET and POST requests. This agen... |
3f21eff89532-15 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Observation: ValueError('Value at path `data["servers"][0]` is not a dict, get the value directly.')
Thought: I should get the value of the servers key
Action: json_spec_get_value
Action Input: data["servers"][0]
Observation: {'url': 'https://api.openai.com/v1'}
Thought: I now know the base url for the API
Final Answer... |
3f21eff89532-16 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Thought: I now know the path for the /completions endpoint
Final Answer: The path for the /completions endpoint is data["paths"][2]
> Finished chain.
Observation: The path for the /completions endpoint is data["paths"][2]
Thought: I should find the required parameters for the POST request.
Action: json_explorer
Action ... |
3f21eff89532-17 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Action Input: data["paths"]["/completions"]["post"]
Observation: ['operationId', 'tags', 'summary', 'requestBody', 'responses', 'x-oaiMeta']
Thought: I should look at the requestBody key to see what parameters are required
Action: json_spec_list_keys
Action Input: data["paths"]["/completions"]["post"]["requestBody"]
Ob... |
3f21eff89532-18 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Action Input: data["paths"]["/completions"]["post"]["requestBody"]["content"]["application/json"]["schema"]["$ref"]
Observation: #/components/schemas/CreateCompletionRequest
Thought: I should look at the CreateCompletionRequest schema to see what parameters are required
Action: json_spec_list_keys
Action Input: data["c... |
3f21eff89532-19 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi.html | Final Answer: The response of the POST request is {"id":"cmpl-70Ivzip3dazrIXU8DSVJGzFJj2rdv","object":"text_completion","created":1680307139,"model":"davinci","choices":[{"text":" with mummy not there”\n\nYou dig deep and come up with,","index":0,"logprobs":null,"finish_reason":"length"}],"usage":{"prompt_tokens":4,"co... |
52d5e0e9922c-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/python.html | .ipynb
.pdf
Python Agent
Contents
Fibonacci Example
Training neural net
Python Agent#
This notebook showcases an agent designed to write and execute python code to answer a question.
from langchain.agents.agent_toolkits import create_python_agent
from langchain.tools.python.tool import PythonREPLTool
from langchain.p... |
52d5e0e9922c-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/python.html | Action: Python REPL
Action Input:
import torch
# Define the model
model = torch.nn.Sequential(
torch.nn.Linear(1, 1)
)
# Define the loss
loss_fn = torch.nn.MSELoss()
# Define the optimizer
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)
# Define the data
x_data = torch.tensor([[1.0], [2.0], [3.0], [4.0]])... |
52d5e0e9922c-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/python.html | > Finished chain.
'The prediction for x = 5 is 10.0.'
previous
PowerBI Dataset Agent
next
Spark Dataframe Agent
Contents
Fibonacci Example
Training neural net
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 04, 2023. |
715932b51a29-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/json.html | .ipynb
.pdf
JSON Agent
Contents
Initialization
Example: getting the required POST parameters for a request
JSON Agent#
This notebook showcases an agent designed to interact with large JSON/dict objects. This is useful when you want to answer questions about a JSON blob that’s too large to fit in the context window of... |
715932b51a29-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/json.html | Thought: I should look at the paths key to see what endpoints exist
Action: json_spec_list_keys
Action Input: data["paths"]
Observation: ['/engines', '/engines/{engine_id}', '/completions', '/edits', '/images/generations', '/images/edits', '/images/variations', '/embeddings', '/engines/{engine_id}/search', '/files', '/... |
715932b51a29-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/json.html | Action Input: data["paths"]["/completions"]["post"]["requestBody"]["content"]
Observation: ['application/json']
Thought: I should look at the application/json key to see what parameters are required
Action: json_spec_list_keys
Action Input: data["paths"]["/completions"]["post"]["requestBody"]["content"]["application/js... |
715932b51a29-3 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/json.html | Last updated on Jun 04, 2023. |
7ffcb5e083fe-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/azure_cognitive_services.html | .ipynb
.pdf
Azure Cognitive Services Toolkit
Contents
Create the Toolkit
Use within an Agent
Azure Cognitive Services Toolkit#
This toolkit is used to interact with the Azure Cognitive Services API to achieve some multimodal capabilities.
Currently There are four tools bundled in this toolkit:
AzureCogsImageAnalysisT... |
7ffcb5e083fe-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/azure_cognitive_services.html | ['Azure Cognitive Services Image Analysis',
'Azure Cognitive Services Form Recognizer',
'Azure Cognitive Services Speech2Text',
'Azure Cognitive Services Text2Speech']
Use within an Agent#
from langchain import OpenAI
from langchain.agents import initialize_agent, AgentType
llm = OpenAI(temperature=0)
agent = initia... |
7ffcb5e083fe-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/azure_cognitive_services.html | "action": "Azure Cognitive Services Text2Speech",
"action_input": "Why did the chicken cross the playground? To get to the other slide!"
}
```
Observation: /tmp/tmpa3uu_j6b.wav
Thought: I have the audio file of the joke
Action:
```
{
"action": "Final Answer",
"action_input": "/tmp/tmpa3uu_j6b.wav"
}
```
> Finishe... |
37d31663795d-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/playwright.html | .ipynb
.pdf
PlayWright Browser Toolkit
Contents
Instantiating a Browser Toolkit
Use within an Agent
PlayWright Browser Toolkit#
This toolkit is used to interact with the browser. While other tools (like the Requests tools) are fine for static sites, Browser toolkits let your agent navigate the web and interact with d... |
37d31663795d-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/playwright.html | tools
[ClickTool(name='click_element', description='Click on an element with the given CSS selector', args_schema=<class 'langchain.tools.playwright.click.ClickToolInput'>, return_direct=False, verbose=False, callbacks=None, callback_manager=None, sync_browser=None, async_browser=<Browser type=<BrowserType name=chromiu... |
37d31663795d-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/playwright.html | ExtractTextTool(name='extract_text', description='Extract all the text on the current webpage', args_schema=<class 'pydantic.main.BaseModel'>, return_direct=False, verbose=False, callbacks=None, callback_manager=None, sync_browser=None, async_browser=<Browser type=<BrowserType name=chromium executable_path=/Users/wfh/L... |
37d31663795d-3 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/playwright.html | CurrentWebPageTool(name='current_webpage', description='Returns the URL of the current page', args_schema=<class 'pydantic.main.BaseModel'>, return_direct=False, verbose=False, callbacks=None, callback_manager=None, sync_browser=None, async_browser=<Browser type=<BrowserType name=chromium executable_path=/Users/wfh/Lib... |
37d31663795d-4 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/playwright.html | '[{"innerText": "These Ukrainian veterinarians are risking their lives to care for dogs and cats in the war zone"}, {"innerText": "Life in the ocean\\u2019s \\u2018twilight zone\\u2019 could disappear due to the climate crisis"}, {"innerText": "Clashes renew in West Darfur as food and water shortages worsen in Sudan vi... |
37d31663795d-5 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/playwright.html | \\u2018walk to your death\\u2019 she says"}, {"innerText": "U.S. House Speaker Kevin McCarthy weighs in on Disney-DeSantis feud"}, {"innerText": "Two sides agree to extend Sudan ceasefire"}, {"innerText": "Spanish Leopard 2 tanks are on their way to Ukraine, defense minister confirms"}, {"innerText": "Flamb\\u00e9ed pi... |
37d31663795d-6 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/playwright.html | Britain\\u2019s Queen Camilla"}, {"innerText": "Catastrophic drought that\\u2019s pushed millions into crisis made 100 times more likely by climate change, analysis finds"}, {"innerText": "For years, a UK mining giant was untouchable in Zambia for pollution until a former miner\\u2019s son took them on"}, {"innerText":... |
37d31663795d-7 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/playwright.html | ramen shop bans customers from using their phones while eating"}, {"innerText": "South African opera star will perform at coronation of King Charles III"}, {"innerText": "Luxury loot under the hammer: France auctions goods seized from drug dealers"}, {"innerText": "Judy Blume\\u2019s books were formative for generation... |
37d31663795d-8 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/playwright.html | unknown marine species"}, {"innerText": "Wall Street Journal editor discusses reporter\\u2019s arrest in Moscow"}, {"innerText": "Can Tunisia\\u2019s democracy be saved?"}, {"innerText": "Yasmeen Lari, \\u2018starchitect\\u2019 turned social engineer, wins one of architecture\\u2019s most coveted prizes"}, {"innerText"... |
37d31663795d-9 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/playwright.html | # If the agent wants to remember the current webpage, it can use the `current_webpage` tool
await tools_by_name['current_webpage'].arun({})
'https://web.archive.org/web/20230428133211/https://cnn.com/world'
Use within an Agent#
Several of the browser tools are StructuredTool’s, meaning they expect multiple arguments. T... |
37d31663795d-10 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/playwright.html | "selector": "h1, h2, h3, h4, h5, h6"
}
}
```
Observation: []
Thought: Thought: I need to navigate to langchain.com to see the headers
Action:
```
{
"action": "navigate_browser",
"action_input": "https://langchain.com/"
}
```
Observation: Navigating to https://langchain.com/ returned status code 200
Thought:
> Fin... |
81e7e5c83b15-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/gmail.html | .ipynb
.pdf
Gmail Toolkit
Contents
Create the Toolkit
Customizing Authentication
Use within an Agent
Gmail Toolkit#
This notebook walks through connecting a LangChain email to the Gmail API.
To use this toolkit, you will need to set up your credentials explained in the Gmail API docs. Once you’ve downloaded the crede... |
81e7e5c83b15-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/gmail.html | [GmailCreateDraft(name='create_gmail_draft', description='Use this tool to create a draft email with the provided message fields.', args_schema=<class 'langchain.tools.gmail.create_draft.CreateDraftSchema'>, return_direct=False, verbose=False, callbacks=None, callback_manager=None, api_resource=<googleapiclient.discove... |
81e7e5c83b15-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/gmail.html | GmailGetThread(name='get_gmail_thread', description=('Use this tool to search for email messages. The input must be a valid Gmail query. The output is a JSON list of messages.',), args_schema=<class 'langchain.tools.gmail.get_thread.GetThreadSchema'>, return_direct=False, verbose=False, callbacks=None, callback_manager... |
81e7e5c83b15-3 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/gmail.html | "The latest email in your drafts is from hopefulparrot@gmail.com with the subject 'Collaboration Opportunity'. The body of the email reads: 'Dear [Friend], I hope this letter finds you well. I am writing to you in the hopes of rekindling our friendship and to discuss the possibility of collaborating on some research to... |
6edeea6f7812-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/pandas.html | .ipynb
.pdf
Pandas Dataframe Agent
Contents
Multi DataFrame Example
Pandas Dataframe Agent#
This notebook shows how to use agents to interact with a pandas dataframe. It is mostly optimized for question answering.
NOTE: this agent calls the Python agent under the hood, which executes LLM generated Python code - this ... |
6edeea6f7812-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/pandas.html | Observation: 29.69911764705882
Thought: I now need to calculate the square root of the average age
Action: python_repl_ast
Action Input: math.sqrt(df['Age'].mean())
Observation: NameError("name 'math' is not defined")
Thought: I need to import the math library
Action: python_repl_ast
Action Input: import math
Observati... |
6edeea6f7812-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/pandas.html | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 04, 2023. |
d734411f4c91-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/powerbi.html | .ipynb
.pdf
PowerBI Dataset Agent
Contents
Some notes
Initialization
Example: describing a table
Example: simple query on a table
Example: running queries
Example: add your own few-shot prompts
PowerBI Dataset Agent#
This notebook showcases an agent designed to interact with a Power BI Dataset. The agent is designed ... |
d734411f4c91-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/powerbi.html | powerbi=PowerBIDataset(dataset_id="<dataset_id>", table_names=['table1', 'table2'], credential=DefaultAzureCredential()),
llm=smart_llm
)
agent_executor = create_pbi_agent(
llm=fast_llm,
toolkit=toolkit,
verbose=True,
)
Example: describing a table#
agent_executor.run("Describe table1")
Example: simple ... |
d734411f4c91-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/powerbi.html | toolkit=toolkit,
verbose=True,
)
agent_executor.run("What was the maximum of value in revenue in dollars in 2022?")
previous
PlayWright Browser Toolkit
next
Python Agent
Contents
Some notes
Initialization
Example: describing a table
Example: simple query on a table
Example: running queries
Example: add your own... |
b0c9fd1f8ada-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/jira.html | .ipynb
.pdf
Jira
Jira#
This notebook goes over how to use the Jira tool.
The Jira tool allows agents to interact with a given Jira instance, performing actions such as searching for issues and creating issues, the tool wraps the atlassian-python-api library, for more see: https://atlassian-python-api.readthedocs.io/jir... |
b0c9fd1f8ada-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/jira.html | Observation: None
Thought: I now know the final answer
Final Answer: A new issue has been created in project PW with the summary "Make more fried rice" and description "Reminder to make more fried rice".
> Finished chain.
'A new issue has been created in project PW with the summary "Make more fried rice" and descriptio... |
653edb99f580-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/csv.html | .ipynb
.pdf
CSV Agent
Contents
Multi CSV Example
CSV Agent#
This notebook shows how to use agents to interact with a csv. It is mostly optimized for question answering.
NOTE: this agent calls the Pandas DataFrame agent under the hood, which in turn calls the Python agent, which executes LLM generated Python code - th... |
653edb99f580-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/csv.html | Thought: I now need to calculate the square root of the average age
Action: python_repl_ast
Action Input: math.sqrt(df['Age'].mean())
Observation: NameError("name 'math' is not defined")
Thought: I need to import the math library
Action: python_repl_ast
Action Input: import math
Observation:
Thought: I now need to cal... |
ccf4ac1e6e74-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html | .ipynb
.pdf
SQL Database Agent
Contents
Initialization
Example: describing a table
Example: describing a table, recovering from an error
Example: running queries
Recovering from an error
SQL Database Agent#
This notebook showcases an agent designed to interact with a sql databases. The agent builds off of SQLDatabase... |
ccf4ac1e6e74-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html | CREATE TABLE "PlaylistTrack" (
"PlaylistId" INTEGER NOT NULL,
"TrackId" INTEGER NOT NULL,
PRIMARY KEY ("PlaylistId", "TrackId"),
FOREIGN KEY("TrackId") REFERENCES "Track" ("TrackId"),
FOREIGN KEY("PlaylistId") REFERENCES "Playlist" ("PlaylistId")
)
SELECT * FROM 'PlaylistTrack' LIMIT 3;
PlaylistId TrackId
1 34... |
ccf4ac1e6e74-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html | CREATE TABLE "PlaylistTrack" (
"PlaylistId" INTEGER NOT NULL,
"TrackId" INTEGER NOT NULL,
PRIMARY KEY ("PlaylistId", "TrackId"),
FOREIGN KEY("TrackId") REFERENCES "Track" ("TrackId"),
FOREIGN KEY("PlaylistId") REFERENCES "Playlist" ("PlaylistId")
)
SELECT * FROM 'PlaylistTrack' LIMIT 3;
PlaylistId TrackId
1 34... |
ccf4ac1e6e74-3 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html | "Country" NVARCHAR(40),
"PostalCode" NVARCHAR(10),
"Phone" NVARCHAR(24),
"Fax" NVARCHAR(24),
"Email" NVARCHAR(60) NOT NULL,
"SupportRepId" INTEGER,
PRIMARY KEY ("CustomerId"),
FOREIGN KEY("SupportRepId") REFERENCES "Employee" ("EmployeeId")
)
SELECT * FROM 'Customer' LIMIT 3;
CustomerId FirstName LastName... |
ccf4ac1e6e74-4 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html | "Total" NUMERIC(10, 2) NOT NULL,
PRIMARY KEY ("InvoiceId"),
FOREIGN KEY("CustomerId") REFERENCES "Customer" ("CustomerId")
)
SELECT * FROM 'Invoice' LIMIT 3;
InvoiceId CustomerId InvoiceDate BillingAddress BillingCity BillingState BillingCountry BillingPostalCode Total
1 2 2009-01-01 00:00:00 Theodor-Heuss-Straße 3... |
ccf4ac1e6e74-5 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html | > Finished chain.
'The customers from the USA spent the most, with a total of $523.06.'
agent_executor.run("Show the total number of tracks in each playlist. The Playlist name should be included in the result.")
> Entering new AgentExecutor chain...
Action: list_tables_sql_db
Action Input: ""
Observation: Invoice, Medi... |
ccf4ac1e6e74-6 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html | SELECT Playlist.Name, COUNT(PlaylistTrack.TrackId) AS TotalTracks FROM Playlist INNER JOIN PlaylistTrack ON Playlist.PlaylistId = PlaylistTrack.PlaylistId GROUP BY Playlist.Name
Thought: The query looks correct, I can now execute it.
Action: query_sql_db
Action Input: SELECT Playlist.Name, COUNT(PlaylistTrack.TrackId) ... |
ccf4ac1e6e74-7 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html | "The total number of tracks in each playlist are: '90’s Music' (1477), 'Brazilian Music' (39), 'Classical' (75), 'Classical 101 - Deep Cuts' (25), 'Classical 101 - Next Steps' (25), 'Classical 101 - The Basics' (25), 'Grunge' (15), 'Heavy Metal Classic' (26), 'Music' (6580), 'Music Videos' (1)."
Recovering from an erro... |
ccf4ac1e6e74-8 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html | "Milliseconds" INTEGER NOT NULL,
"Bytes" INTEGER,
"UnitPrice" NUMERIC(10, 2) NOT NULL,
PRIMARY KEY ("TrackId"),
FOREIGN KEY("MediaTypeId") REFERENCES "MediaType" ("MediaTypeId"),
FOREIGN KEY("GenreId") REFERENCES "Genre" ("GenreId"),
FOREIGN KEY("AlbumId") REFERENCES "Album" ("AlbumId")
)
SELECT * FROM 'Tra... |
ccf4ac1e6e74-9 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html | 3 2 6 0.99 1
Thought: I should query the database to get the top 3 best selling artists.
Action: query_sql_db
Action Input: SELECT Artist.Name, SUM(InvoiceLine.Quantity) AS TotalQuantity FROM Artist INNER JOIN Track ON Artist.ArtistId = Track.ArtistId INNER JOIN InvoiceLine ON Track.TrackId = InvoiceLine.TrackId GROUP ... |
ccf4ac1e6e74-10 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html | Action Input: SELECT Artist.Name, SUM(InvoiceLine.Quantity) AS TotalQuantity FROM Artist INNER JOIN Album ON Artist.ArtistId = Album.ArtistId INNER JOIN Track ON Album.AlbumId = Track.AlbumId INNER JOIN InvoiceLine ON Track.TrackId = InvoiceLine.TrackId GROUP BY Artist.Name ORDER BY TotalQuantity DESC LIMIT 3
Observati... |
a30677dc167e-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html | .ipynb
.pdf
Natural Language APIs
Contents
First, import dependencies and load the LLM
Next, load the Natural Language API Toolkits
Create the Agent
Using Auth + Adding more Endpoints
Thank you!
Natural Language APIs#
Natural Language API Toolkits (NLAToolkits) permit LangChain Agents to efficiently plan and combine ... |
a30677dc167e-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html | 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 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support.
Create the Agent#
# Slightly twe... |
a30677dc167e-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html | Action Input: Italian clothes
Observation: The API response contains two products from the Alé brand in Italian Blue. The first is the Alé Colour Block Short Sleeve Jersey Men - Italian Blue, which costs $86.49, and the second is the Alé Dolid Flash Jersey Men - Italian Blue, which costs $40.00.
Thought: I now know wha... |
a30677dc167e-3 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html | max_text_length=1800, # If you want to truncate the response text
)
Attempting to load an OpenAPI 3.0.0 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support.
Unsupported APIPropertyLocation "header" for parameter Content-Type. Valid values are ['path', 'query'] Igno... |
a30677dc167e-4 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html | Unsupported APIPropertyLocation "header" for parameter Content-Type. Valid values are ['path', 'query'] Ignoring optional parameter
Unsupported APIPropertyLocation "header" for parameter Accept. Valid values are ['path', 'query'] Ignoring optional parameter
Unsupported APIPropertyLocation "header" for parameter Accept.... |
a30677dc167e-5 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html | Observation: The API response contains 10 Italian recipes, including Turkey Tomato Cheese Pizza, Broccolini Quinoa Pilaf, Bruschetta Style Pork & Pasta, Salmon Quinoa Risotto, Italian Tuna Pasta, Roasted Brussels Sprouts With Garlic, Asparagus Lemon Risotto, Italian Steamed Artichokes, Crispy Italian Cauliflower Popper... |
a30677dc167e-6 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html | 'To present for your Italian language class, you could wear an Italian Gold Sparkle Perfectina Necklace - Gold, an Italian Design Miami Cuban Link Chain Necklace - Gold, or an Italian Gold Miami Cuban Link Chain Necklace - Gold. For a recipe, you could make Turkey Tomato Cheese Pizza, Broccolini Quinoa Pilaf, Bruschett... |
d8498d9d3d8e-0 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark.html | .ipynb
.pdf
Spark Dataframe Agent
Contents
Spark Connect Example
Spark Dataframe Agent#
This notebook shows how to use agents to interact with a Spark dataframe and Spark Connect. It is mostly optimized for question answering.
NOTE: this agent calls the Python agent under the hood, which executes LLM generated Python... |
d8498d9d3d8e-1 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark.html | +-----------+--------+------+--------------------+------+----+-----+-----+----------------+-------+-----+--------+
| 1| 0| 3|Braund, Mr. Owen ...| male|22.0| 1| 0| A/5 21171| 7.25| null| S|
| 2| 1| 1|Cumings, Mrs. Joh...|female|38.0| 1| 0| PC 17599... |
d8498d9d3d8e-2 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark.html | | 7| 0| 1|McCarthy, Mr. Tim...| male|54.0| 0| 0| 17463|51.8625| E46| S|
| 8| 0| 3|Palsson, Master. ...| male| 2.0| 3| 1| 349909| 21.075| null| S|
| 9| 1| 3|Johnson, Mrs. Osc...|female|27.0| 0| 2| 347742... |
d8498d9d3d8e-3 | https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark.html | | 14| 0| 3|Andersson, Mr. An...| male|39.0| 1| 5| 347082| 31.275| null| S|
| 15| 0| 3|Vestrom, Miss. Hu...|female|14.0| 0| 0| 350406| 7.8542| null| S|
| 16| 1| 2|Hewlett, Mrs. (Ma...|female|55.0| 0| 0| 248706... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.