![]() ![]() You can order the results by a relevant column to return the most interesting examples in the database. [Document(page_content='House of Pain', metadata= results. Invoking: `name_search` with `alis in pains` Similar one to the misspelled user question.įirst we need the unique values for each entity we want, for which weĭefine a function that parses the result into a list of elements: Just embedding the proper nouns and then querying to get the most Let’s follow a similar approach to the few shots, but without metadata: Referring to before building the target query. The agent can make sure it understands which entity the user is Their question, to find the correct spelling for that word. Query that vector store each time the user includes a proper noun in We can achieve this by creating a vector store using all the distinct Song names or artists, we first need to double-check the spelling in In order to filter columns that contain proper nouns such as addresses, Finding and correcting misspellings for proper nouns ![]() Tool from the standard Toolkit, thus saving time and tokens. To other few shot examples, the agent didn’t need to use any other "How many employees are there" : 'SELECT COUNT(*) FROM "employee"' ,Īs we can see, the agent first used the sql_get_similar_examples tool "Which albums are from the year 2000?" : "SELECT * FROM albums WHERE strftime('%Y', ReleaseDate) = '2000' " , "Who are the top 5 customers by total purchase?" : "SELECT CustomerId, SUM(Total) AS TotalPurchase FROM invoices GROUP BY CustomerId ORDER BY TotalPurchase DESC LIMIT 5 " , "List all tracks that are longer than 5 minutes." : "SELECT * FROM tracks WHERE Milliseconds > 300000 " , "Find the total number of invoices." : "SELECT COUNT(*) FROM invoices " , "How many tracks are there in the album with ID 5?" : "SELECT COUNT(*) FROM tracks WHERE AlbumId = 5 " , "List all customers from Canada." : "SELECT * FROM customers WHERE Country = 'Canada' " , "Find the total duration of all tracks." : "SELECT SUM(Milliseconds) FROM tracks " , ![]() "List all tracks in the 'Rock' genre." : "SELECT * FROM tracks WHERE GenreId = (SELECT GenreId FROM genres WHERE Name = 'Rock') " , "Find all albums for the artist 'AC/DC'." : "SELECT * FROM albums WHERE ArtistId = (SELECT ArtistId FROM artists WHERE Name = 'AC/DC') " , "List all artists." : "SELECT * FROM artists " , Observation: įinal Answer: The country with the highest total sales is the USA, with a total of $523.06. Thought: I should query the total sales per country.Īction Input: SELECT Country, SUM(Total) AS TotalSales FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId GROUP BY Country ORDER BY TotalSales DESC LIMIT 10 InvoiceId CustomerId InvoiceDate BillingAddress BillingCity BillingState BillingCountry BillingPostalCode Totalġ 2 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98Ģ 4 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96ģ 8 00:00:00 Grétrystraat 63 Brussels None Belgium 1000 5.94 Thought: I should query the schema of the Invoice and Customer tables.įOREIGN KEY("SupportRepId") REFERENCES "Employee" ("EmployeeId")ĬustomerId FirstName LastName Company Address City State Country PostalCode Phone Fax Email SupportRepIdġ Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Observation: Album, Artist, Customer, Employee, Genre, Invoice, InvoiceLine, MediaType, Playlist, PlaylistTrack, Track Names by providing two rows from the Track table. ![]() Providing sample data can help the LLM construct correct queries whenįor example, we can tell LLM that artists are saved with their full
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |