id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
59
127
ed4adcbf338f-12
previous Spark SQL Agent next Vectorstore Agent Contents Initialization Using ZERO_SHOT_REACT_DESCRIPTION Using OpenAI Functions Example: describing a table Example: describing a table, recovering from an error Example: running queries Recovering from an error By Harrison Chase © Copyright 2023, Harrison...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/sql_database.html
68108dd505d5-0
.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 ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/powerbi.html
68108dd505d5-1
toolkit = PowerBIToolkit( 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("Desc...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/powerbi.html
68108dd505d5-2
examples=few_shots, ) agent_executor = create_pbi_agent( llm=fast_llm, 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 ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/powerbi.html
e64ab912084b-0
.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: ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark_sql.html
e64ab912084b-1
+-----------+--------+------+--------------------+------+----+-----+-----+----------------+-------+-----+--------+ | 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark_sql.html
e64ab912084b-2
| 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark_sql.html
e64ab912084b-3
| 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark_sql.html
e64ab912084b-4
only showing top 20 rows # 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( ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark_sql.html
e64ab912084b-5
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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark_sql.html
e64ab912084b-6
> Finished chain. '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, Su...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark_sql.html
e64ab912084b-7
Action: list_tables_sql_db Action Input: Observation: titanic Thought:I should check the schema of the titanic table to see if there is an age column. Action: schema_sql_db Action Input: titanic Observation: CREATE TABLE langchain_example.titanic ( PassengerId INT, Survived INT, Pclass INT, Name STRING, Sex ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark_sql.html
e64ab912084b-8
SELECT SQRT(AVG(Age)) as square_root_of_avg_age FROM titanic Thought:The query is correct, so I can execute it to find the square root of the average age. Action: query_sql_db Action Input: SELECT SQRT(AVG(Age)) as square_root_of_avg_age FROM titanic Observation: [('5.449689683556195',)] Thought:I now know the final an...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark_sql.html
e64ab912084b-9
2 1 1 Cumings, Mrs. John Bradley (Florence Briggs Thayer) female 38.0 1 0 PC 17599 71.2833 C85 C 3 1 3 Heikkinen, Miss. Laina female 26.0 0 0 STON/O2. 3101282 7.925 None S */ 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 order...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark_sql.html
805b1a25a4e7-0
.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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
805b1a25a4e7-1
tools = toolkit.get_tools() 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 ty...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
805b1a25a4e7-2
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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
805b1a25a4e7-3
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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
805b1a25a4e7-4
'[{"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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
805b1a25a4e7-5
launches deadly wave of strikes across Ukraine"}, {"innerText": "Woman forced to leave her forever home or \\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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
805b1a25a4e7-6
performing at the ceremony"}, {"innerText": "The week in 33 photos"}, {"innerText": "Hong Kong\\u2019s endangered turtles"}, {"innerText": "In pictures: Britain\\u2019s Queen Camilla"}, {"innerText": "Catastrophic drought that\\u2019s pushed millions into crisis made 100 times more likely by climate change, analysis fi...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
805b1a25a4e7-7
guide to the coronation"}, {"innerText": "A year in Azerbaijan: From spring\\u2019s Grand Prix to winter ski adventures"}, {"innerText": "The bicycle mayor peddling a two-wheeled revolution in Cape Town"}, {"innerText": "Tokyo ramen shop bans customers from using their phones while eating"}, {"innerText": "South Africa...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
805b1a25a4e7-8
{"innerText": "Bureaucracy stalling at least one family\\u2019s evacuation from Sudan"}, {"innerText": "Girl to get life-saving treatment for rare immune disease"}, {"innerText": "Haiti\\u2019s crime rate more than doubles in a year"}, {"innerText": "Ocean census aims to discover 100,000 previously unknown marine speci...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
805b1a25a4e7-9
give up on milestones: A CNN Hero\\u2019s message for Autism Awareness Month"}, {"innerText": "CNN Hero of the Year Nelly Cheboi returned to Kenya with plans to lift more students out of poverty"}]'
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
805b1a25a4e7-10
# 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
805b1a25a4e7-11
``` { "action": "get_elements", "action_input": { "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 http...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/playwright.html
6302e75ce9d7-0
.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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/azure_cognitive_services.html
6302e75ce9d7-1
[tool.name for tool in toolkit.get_tools()] ['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, AgentTyp...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/azure_cognitive_services.html
6302e75ce9d7-2
audio_file = agent.run("Tell me a joke and read it out for me.") > Entering new AgentExecutor chain... Action: ``` { "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 au...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/azure_cognitive_services.html
34841874c7d6-0
.ipynb .pdf Pandas Dataframe Agent Contents Using ZERO_SHOT_REACT_DESCRIPTION Using OpenAI Functions 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 t...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/pandas.html
34841874c7d6-1
> Entering new AgentExecutor chain... Thought: I need to count the number of people with more than 3 siblings Action: python_repl_ast Action Input: df[df['SibSp'] > 3].shape[0] Observation: 30 Thought: I now know the final answer Final Answer: 30 people have more than 3 siblings. > Finished chain. '30 people have more ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/pandas.html
34841874c7d6-2
df1["Age"] = df1["Age"].fillna(df1["Age"].mean()) agent = create_pandas_dataframe_agent(OpenAI(temperature=0), [df, df1], verbose=True) agent.run("how many rows in the age column are different?") > Entering new AgentExecutor chain... Thought: I need to compare the age columns in both dataframes Action: python_repl_ast ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/pandas.html
f73d2c679031-0
.ipynb .pdf Python Agent Contents Using ZERO_SHOT_REACT_DESCRIPTION Using OpenAI Functions 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/python.html
f73d2c679031-1
return 0 elif n == 1: return 1 else: return fibonacci(n-1) + fibonacci(n-2) fibonacci(10)` The 10th Fibonacci number is 55. > Finished chain. 'The 10th Fibonacci number is 55.' Training neural net# This example was created by Samee Ur Rehman. agent_executor.run("""Understand, write a single neur...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/python.html
f73d2c679031-2
> Entering new chain... Could not parse tool input: {'name': 'python', 'arguments': 'import torch\nimport torch.nn as nn\nimport torch.optim as optim\n\n# Define the neural network\nclass SingleNeuron(nn.Module):\n def __init__(self):\n super(SingleNeuron, self).__init__()\n self.linear = nn.Linear(1,...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/python.html
f73d2c679031-3
Invoking: `Python_REPL` with `import torch import torch.nn as nn import torch.optim as optim # Define the neural network class SingleNeuron(nn.Module): def __init__(self): super(SingleNeuron, self).__init__() self.linear = nn.Linear(1, 1) def forward(self, x): return self.linear...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/python.html
f73d2c679031-4
Epoch 200: Loss = 0.02100197970867157 Epoch 300: Loss = 0.01152981910854578 Epoch 400: Loss = 0.006329738534986973 Epoch 500: Loss = 0.0034749575424939394 Epoch 600: Loss = 0.0019077073084190488 Epoch 700: Loss = 0.001047312980517745 Epoch 800: Loss = 0.0005749554838985205 Epoch 900: Loss = 0.0003156439634039998 Epoch ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/python.html
06fffc39337b-0
.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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark.html
06fffc39337b-1
+-----------+--------+------+--------------------+------+----+-----+-----+----------------+-------+-----+--------+ | 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark.html
06fffc39337b-2
| 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark.html
06fffc39337b-3
| 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark.html
06fffc39337b-4
only showing top 20 rows agent = create_spark_dataframe_agent(llm=OpenAI(temperature=0), df=df, verbose=True) agent.run("how many rows are there?") > Entering new AgentExecutor chain... Thought: I need to find out how many rows are in the dataframe Action: python_repl_ast Action Input: df.count() Observation: 891 Thoug...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark.html
06fffc39337b-5
Thought: I now have the math library imported, I can get the square root Action: python_repl_ast Action Input: math.sqrt(29.69911764705882) Observation: 5.449689683556195 Thought: I now know the final answer Final Answer: 5.449689683556195 > Finished chain. '5.449689683556195' spark.stop() Spark Connect Example# # in a...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark.html
06fffc39337b-6
df.show() +-----------+--------+------+--------------------+------+----+-----+-----+----------------+-------+-----+--------+ |PassengerId|Survived|Pclass| Name| Sex| Age|SibSp|Parch| Ticket| Fare|Cabin|Embarked| +-----------+--------+------+--------------------+------+----+-----+-----+------...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark.html
06fffc39337b-7
| 6| 0| 3| Moran, Mr. James| male|null| 0| 0| 330877| 8.4583| null| Q| | 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark.html
06fffc39337b-8
| 13| 0| 3|Saundercock, Mr. ...| male|20.0| 0| 0| A/5. 2151| 8.05| null| S| | 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark.html
06fffc39337b-9
| 20| 1| 3|Masselmani, Mrs. ...|female|null| 0| 0| 2649| 7.225| null| C| +-----------+--------+------+--------------------+------+----+-----+-----+----------------+-------+-----+--------+ only showing top 20 rows from langchain.agents import create_spark_dataframe_agent from la...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/spark.html
a664f63e805d-0
.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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/jira.html
a664f63e805d-1
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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/jira.html
0143e874a04e-0
.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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/gmail.html
0143e874a04e-1
tools = toolkit.get_tools() tools [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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/gmail.html
0143e874a04e-2
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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/gmail.html
0143e874a04e-3
WARNING:root:Failed to persist run: {"detail":"Not Found"} "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 d...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/gmail.html
76464081f6eb-0
.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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-1
!mv openapi.yaml spotify_openapi.yaml --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.githubusercont...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-2
--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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-3
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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-4
from langchain.agents.agent_toolkits.openapi import planner 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_mo...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-5
Action: api_controller Action Input: 1. GET /search to search for the album "Kind of Blue" 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....
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-6
Observation: 7lzoEi44WOISnFYlrAIqyX Thought:Action: requests_post 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 ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-7
Observation: 1. GET /me to get the current user's information 2. GET /recommendations/available-genre-seeds to retrieve a list of available genres 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 c...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-8
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,...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-9
Observation: [ { 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:...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-10
openai_agent.run(user_query) > Entering new AgentExecutor chain... Action: api_planner 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 s...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-11
Thought:I will use the "davinci" engine to generate a short piece of advice. Action: requests_post 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 fi...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-12
> Entering new AgentExecutor chain... Action: requests_get Action Input: {"url": "https://api.openai.com/v1/models", "output_instructions": "Extract the ids of the available models"} Observation: babbage, davinci, text-davinci-edit-001, babbage-code-search-code, text-similarity-babbage-001, code-davinci-edit-001, text-...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-13
3. POST /completions with the chosen model and a prompt related to improving communication skills to generate a short piece of advice Thought:I have an updated plan, now I need to execute the API calls. Action: api_controller Action Input: 1. GET /models to retrieve the list of available models 2. Choose a suitable mod...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-14
> Finished chain. 'A short piece of advice for improving communication skills is to make sure to listen.' Takes awhile to get there! 2nd example: “json explorer” agent# 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-15
Action: json_spec_list_keys Action Input: data Observation: ['openapi', 'info', 'servers', 'tags', 'paths', 'components', 'x-oaiMeta'] Thought: I should look at the servers key to see what the base url is Action: json_spec_list_keys Action Input: data["servers"][0] Observation: ValueError('Value at path `data["servers"...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-16
Action: json_spec_list_keys Action Input: data["paths"] Observation: ['/engines', '/engines/{engine_id}', '/completions', '/chat/completions', '/edits', '/images/generations', '/images/edits', '/images/variations', '/embeddings', '/audio/transcriptions', '/audio/translations', '/engines/{engine_id}/search', '/files', '...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-17
Action: json_spec_list_keys Action Input: data["paths"] Observation: ['/engines', '/engines/{engine_id}', '/completions', '/chat/completions', '/edits', '/images/generations', '/images/edits', '/images/variations', '/embeddings', '/audio/transcriptions', '/audio/translations', '/engines/{engine_id}/search', '/files', '...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-18
Action: json_spec_list_keys Action Input: data["paths"]["/completions"]["post"]["requestBody"]["content"]["application/json"] Observation: ['schema'] Thought: I should look at the schema key to see what parameters are required Action: json_spec_list_keys Action Input: data["paths"]["/completions"]["post"]["requestBody"...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-19
> Finished chain. Observation: The required parameters for a POST request to the /completions endpoint are 'model'. Thought: I now know the parameters needed to make the request. Action: requests_post Action Input: { "url": "https://api.openai.com/v1/completions", "data": { "model": "davinci", "prompt": "tell me a joke...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
76464081f6eb-20
> Finished chain. '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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi.html
179faf895f47-0
.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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/vectorstore.html
179faf895f47-1
) vectorstore_info = VectorStoreInfo( name="state_of_union_address", 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, ve...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/vectorstore.html
179faf895f47-2
Action Input: What did biden say about ketanji brown jackson 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", "s...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/vectorstore.html
179faf895f47-3
toolkit=router_toolkit, verbose=True ) Examples# agent_executor.run("What did biden say about ketanji brown jackson in 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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/vectorstore.html
179faf895f47-4
Thought: I now know the final answer Final Answer: 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 > Finished chain. 'Ruff is integrated into nbQA, a tool for running...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/vectorstore.html
179faf895f47-5
previous SQL Database Agent next Agent Executors Contents Create the Vectorstores Initialize Toolkit and Agent Examples Multiple Vectorstores Examples By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/vectorstore.html
2953fa091fda-0
.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 ...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi_nla.html
2953fa091fda-1
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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi_nla.html
2953fa091fda-2
Action: Open_AI_Klarna_product_Api.productsUsingGET 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 - Itali...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi_nla.html
2953fa091fda-3
llm, "https://spoonacular.com/application/frontend/downloads/spoonacular-openapi-3.json", requests=requests, 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 be...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi_nla.html
2953fa091fda-4
Unsupported APIPropertyLocation "header" for parameter Accept. Valid values are ['path', 'query'] Ignoring optional parameter Unsupported APIPropertyLocation "header" for parameter Content-Type. Valid values are ['path', 'query'] Ignoring optional parameter Unsupported APIPropertyLocation "header" for parameter Accept....
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi_nla.html
2953fa091fda-5
Action: spoonacular_API.searchRecipes Action Input: Italian 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, I...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi_nla.html
2953fa091fda-6
> Finished chain. '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 Quino...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/openapi_nla.html
0fb84d3c40b8-0
.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...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/json.html
0fb84d3c40b8-1
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', '/...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/json.html
0fb84d3c40b8-2
Action: json_spec_list_keys 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"...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/json.html
0fb84d3c40b8-3
Initialization Example: getting the required POST parameters for a request By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/json.html
1f8b27c186bf-0
.ipynb .pdf CSV Agent Contents Using ZERO_SHOT_REACT_DESCRIPTION Using OpenAI Functions 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 Py...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/csv.html
1f8b27c186bf-1
agent.run("how many people have more than 3 siblings") Error in on_chain_start callback: 'name' Invoking: `python_repl_ast` with `df[df['SibSp'] > 3]['PassengerId'].count()` 30There are 30 people in the dataframe who have more than 3 siblings. > Finished chain. 'There are 30 people in the dataframe who have more than 3...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/csv.html
1f8b27c186bf-2
-1There is 1 row in the age column that is different between the two dataframes. > Finished chain. 'There is 1 row in the age column that is different between the two dataframes.' previous Azure Cognitive Services Toolkit next Gmail Toolkit Contents Using ZERO_SHOT_REACT_DESCRIPTION Using OpenAI Functions Multi CSV...
rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/toolkits/examples/csv.html
bdcd3a012add-0
.md .pdf Deployments Contents Anyscale Streamlit Gradio (on Hugging Face) Chainlit Beam Vercel FastAPI + Vercel Kinsta Fly.io Digitalocean App Platform Google Cloud Run SteamShip Langchain-serve BentoML Databutton Deployments# So, you’ve created a really cool chain - now what? How do you deploy it and make it easily ...
rtdocs_stable/api.python.langchain.com/en/stable/ecosystem/deployments.html
bdcd3a012add-1
This is heavily influenced by James Weaver’s excellent examples. Chainlit# This repo is a cookbook explaining how to visualize and deploy LangChain agents with Chainlit. You create ChatGPT-like UIs with Chainlit. Some of the key features include intermediary steps visualisation, element management & display (images, te...
rtdocs_stable/api.python.langchain.com/en/stable/ecosystem/deployments.html
bdcd3a012add-2
BentoML# This repository provides an example of how to deploy a LangChain application with BentoML. BentoML is a framework that enables the containerization of machine learning applications as standard OCI images. BentoML also allows for the automatic generation of OpenAPI and gRPC endpoints. With BentoML, you can inte...
rtdocs_stable/api.python.langchain.com/en/stable/ecosystem/deployments.html
21d345307eec-0
Source code for langchain.requests """Lightweight wrapper around requests library, with async support.""" from contextlib import asynccontextmanager from typing import Any, AsyncGenerator, Dict, Optional import aiohttp import requests from pydantic import BaseModel, Extra class Requests(BaseModel): """Wrapper aroun...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/requests.html
21d345307eec-1
def delete(self, url: str, **kwargs: Any) -> requests.Response: """DELETE the URL and return the text.""" return requests.delete(url, headers=self.headers, **kwargs) @asynccontextmanager async def _arequest( self, method: str, url: str, **kwargs: Any ) -> AsyncGenerator[aiohttp.Clien...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/requests.html
21d345307eec-2
"""PATCH the URL and return the text asynchronously.""" async with self._arequest("PATCH", url, **kwargs) as response: yield response @asynccontextmanager async def aput( self, url: str, data: Dict[str, Any], **kwargs: Any ) -> AsyncGenerator[aiohttp.ClientResponse, None]: ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/requests.html