Thought: The query looks correct, I can now execute it.    Action: query_sql_db    Action Input: SELECT Playlist.Name, COUNT(PlaylistTrack.TrackId) AS TotalTracks FROM Playlist INNER JOIN PlaylistTrack ON Playlist.PlaylistId = PlaylistTrack.PlaylistId GROUP BY Playlist.Name LIMIT 10    Observation: [('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)]    Thought: I now know the final answer.    Final Answer: 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).        > Finished chain.    "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 error‚ÄãIn this example, the agent is able to recover from an error after initially trying to access an attribute (Track.ArtistId) which doesn't exist.agent_executor.run("Who are the top 3 best selling artists?")            > Entering new AgentExecutor chain...    Action: list_tables_sql_db    Action Input: ""    Observation: MediaType, Track, Invoice, Album, Playlist, Customer, Employee, InvoiceLine, PlaylistTrack, Genre, Artist    Thought: I should look at the schema of the Artist, InvoiceLine, and Track tables to see what columns I can use.    Action: schema_sql_db    Action Input: "Artist, InvoiceLine, Track"    Observation:     CREATE TABLE "Artist" (        "ArtistId" INTEGER NOT NULL,         "Name" NVARCHAR(120),
This notebook showcases an agent designed to interact with a SQL databases.
This notebook showcases an agent designed to interact with a SQL databases. ->: Thought: The query looks correct, I can now execute it.    Action: query_sql_db    Action Input: SELECT Playlist.Name, COUNT(PlaylistTrack.TrackId) AS TotalTracks FROM Playlist INNER JOIN PlaylistTrack ON Playlist.PlaylistId = PlaylistTrack.PlaylistId GROUP BY Playlist.Name LIMIT 10    Observation: [('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)]    Thought: I now know the final answer.    Final Answer: 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).        > Finished chain.    "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 error‚ÄãIn this example, the agent is able to recover from an error after initially trying to access an attribute (Track.ArtistId) which doesn't exist.agent_executor.run("Who are the top 3 best selling artists?")            > Entering new AgentExecutor chain...    Action: list_tables_sql_db    Action Input: ""    Observation: MediaType, Track, Invoice, Album, Playlist, Customer, Employee, InvoiceLine, PlaylistTrack, Genre, Artist    Thought: I should look at the schema of the Artist, InvoiceLine, and Track tables to see what columns I can use.    Action: schema_sql_db    Action Input: "Artist, InvoiceLine, Track"    Observation:     CREATE TABLE "Artist" (        "ArtistId" INTEGER NOT NULL,         "Name" NVARCHAR(120),