Chat with MySQL Database with Python | LangChain Tutorial

Поделиться
HTML-код
  • Опубликовано: 28 май 2024
  • Discover how to interact with a MySQL database using Python and LangChain in our latest tutorial. This comprehensive guide walks you through the process of creating a LangChain chain, detailing every step with a helpful diagram for a clearer understanding. Whether you're a beginner or an experienced developer, this video will equip you with the knowledge to execute SQL queries using an innovative approach.
    IMPORTANT: Remember to NOT use a MySQL user with WRITE privileges. Use only READ and limit the scope. Otherwise your user could ask your chain to delete data.
    USEFUL LINKS:
    📌 Article (follow along): alejandro-ao.com/chat-with-my...
    📊 Chinook database: github.com/lerocha/chinook-da...
    💬 Join the Discord Help Server: link.alejandro-ao.com/HrFKZn
    ❤️ Buy me a coffee... or a beer (thanks): link.alejandro-ao.com/l83gNq
    Timestamps:
    0:00 Intro
    1:02 How this works
    2:59 Our test data
    4:58 Load the test data
    6:47 Notebook setup
    9:23 Create SQL Chain Prompt
    13:00 Load MySQL Database in Python
    17:01 Create SQL Chain
    26:02 Create run_query Function & Final Prompt
    29:45 Create Full Chain
    35:54 Conclusion
    In this tutorial, you'll learn:
    - How to set up LangChain to communicate with a MySQL database.
    - The intricacies of creating and utilizing SQL queries within LangChain.
    - Implementing a full chain that includes SQL query generation and natural language response construction.
    - Best practices for interacting with databases using Python and LangChain.
    Key Highlights:
    - LangChain Integration: Learn how to create a LangChain chain for database queries.
    - SQL Query Generation: Understand the process behind generating SQL queries from natural language questions.
    - Interactive Diagram: A detailed diagram explains the architecture and process flow.
    - Comprehensive Code Walkthrough: From setting up your environment to executing queries, every step is covered.
    Who Should Watch?
    This tutorial is perfect for developers, data scientists, and tech enthusiasts interested in leveraging LangChain for database interactions. Whether you're looking to enhance your projects or explore new technologies, this guide has something for everyone.
    Stay Connected: Don't forget to subscribe to our channel for more tutorials on cutting-edge technologies. Join our Discord server for community discussions and updates. Join us here.
    Happy Coding! 🚀

Комментарии • 167

  • @davidtindell950
    @davidtindell950 2 месяца назад +5

    Hi, I reviewed this "Chat with MySQL DB" tutorial yet again and decided to try a more difficult SQL query: "determine the most popular artist in the database based upon total sales.". Of course, I manually ran the full Select -- with three table joins -- to make sure that this new query would work and produce the correct answer(s). To my surprise, the "natural language query" was properly processed by my modified version of your program and produced the correct response: " Iron Maiden with total sales of $138.60 " ! To further test the program, I changed the question to "top three most popular artists". The correct result was again returned: "Iron Maiden, U2, and Metallica" ! Glad to see 'U2' near the top ! Since "langchain-openai" is only at version 0.0.8 and "SQLDatabase" at 0.0.26, we may expect even more NLP Query improvements in the near future [i.e., if 'Altman' & 'Musk' do not mess everything up for all of us !?!]. P.S. Looking forward to the next MySQL vid(s) that you post !

    • @EricLofland
      @EricLofland 2 месяца назад +1

      I got an error when I tried your first query - the query was correct (validated in database) but it was prepended by "sql" like this:
      [SQL: ```sql
      SELECT a.Name AS Artist, SUM(il.UnitPrice * il.Quantity) AS TotalSales
      FROM Artist a
      JOIN Album al ON a.ArtistId = al.ArtistId
      JOIN Track t ON al.AlbumId = t.AlbumId
      JOIN InvoiceLine il ON t.TrackId = il.TrackId
      JOIN Invoice i ON il.InvoiceId = i.InvoiceId
      GROUP BY a.Name
      ORDER BY TotalSales DESC
      LIMIT 1;
      ```]

    • @davidtindell950
      @davidtindell950 2 месяца назад

      @@EricLofland Thank You! For the feedback. The natural language query worked well for me and ChatGPT4 validated the SQL Query. I have since moved on to testing SQLite and also saving query vectors in ChromaDB. Later, I will try to re-check and reproduce the MySQL Database query and compare it to your results.

    • @davidtindell950
      @davidtindell950 2 месяца назад

      ​@@EricLofland I reset my laptop for my extension of Alejandro's "Chat with MySQL" Python program. It ran as before and produced both the SQL and
      Natural Language Query. SQL: run_query("select artist.Name AS ArtistName, COUNT(*) AS TotalSales from \
      invoiceline join track on invoiceline.TrackId = track.TrackId \
      join album on track.AlbumId = album.AlbumId \
      join artist on album.ArtistId = artist.ArtistId \
      group by artist.Name order by TotalSales desc limit 3;")
      NLQ: user_question = 'determine the top three most popular artists in the database based upon total sales.'
      BOTH Results were very similar: "'The top three most popular artists in the database based on total sales are Iron Maiden with $138.60, U2 with $105.93, and Metallica with $90.09.".
      Further, I researched any conditions under which "sql" would be prepended to the SELECT statement. I did NOT find any examples of this artifact, however, I did find a good very recent "Medium" article on this subject by " Senthil E " at " levelup.gitconnected.com/llms-meet-sql-revolutionizing-data-querying-with-natural-language-processing-52487337f043 ". As we say "Hope This Helps!" and thanks again for your detailed feedback.

    • @warrenmarkham8891
      @warrenmarkham8891 2 месяца назад +1

      @@davidtindell950 Are you writing up any of your experiments/tests? I'd be interested in seeing the caching of queries and responses into a vector database.

    • @davidtindell950
      @davidtindell950 2 месяца назад

      ​@@warrenmarkham8891 Hi, I expect to write a new "Medium" article fairly soon, however, I am still currently continuing my R&D. In addition to Alejandro's excellent tutorials, I have found another good tutorial that includes the employment of PyTorch for fast processing of large vector databases: " Maximize ChromaDB Embedding Vectorization Speed with NVidia CUDA GPU and Python Multiprocessing " " Johnny Code " " ruclips.net/video/7FvdwwvqrD4/видео.html " and " ruclips.net/video/7FvdwwvqrD4/видео.htmlsi=a18-dKxTYk2UvRMT ". Also, there are several good current "Medium" articles available on this research subject.

  • @davidtindell950
    @davidtindell950 2 месяца назад +5

    Thanks for including MySQL and not just SQLite.

  • @tannerdio333
    @tannerdio333 Месяц назад

    Dude, incredible tutorial, right on the money for what i needed.

  • @1sanak
    @1sanak 3 месяца назад +3

    Nice, looking forward to part 2!

  • @imranonthenet
    @imranonthenet 3 месяца назад +10

    I really love your tutorials, you are teaching us to create such powerful AI tools in Python that are really useful. I'm surprised that you have only 26K subscribers, you should have millions.

    • @alejandro_ao
      @alejandro_ao  3 месяца назад +2

      thank you man! i hope i will get there someday!

  • @krisograbek
    @krisograbek 2 месяца назад

    Loving this video, Alejandro! 2 things I'd like to add:
    1. I removed the {schema} part from the full_chain prompt and it works great. Only the sql_chain needs schema (to produce the sql query).
    2. Your website is down :(
    Thanks for explaining every bit of your code so well!

  • @student7261
    @student7261 3 месяца назад

    Awesome. Looking forward to part 2....

  • @funmiemore194
    @funmiemore194 2 месяца назад

    First time here and I'm glad I gound your channel.Thanks for sharing!

    • @alejandro_ao
      @alejandro_ao  2 месяца назад +1

      hey there! welcome to the channel :) very happy to have you here :)

    • @funmiemore194
      @funmiemore194 2 месяца назад

      @@alejandro_ao Thanks!!

  • @heaton922
    @heaton922 3 месяца назад

    Love to watch your tutorials. It's very details.

  • @mazinzain7121
    @mazinzain7121 3 месяца назад

    I love your content, thanks for all your efforts ❤

    • @alejandro_ao
      @alejandro_ao  3 месяца назад

      i appreciate it! let me know what you want to see next

  • @wg5920
    @wg5920 2 месяца назад

    Amazing Video. Great job

  • @adnank4980
    @adnank4980 3 месяца назад

    Love your videos, started watching all your langchain and it really has helped me and I wanted to say thanks. I would also like to see the use of agents if it isnt too much to ask

    • @alejandro_ao
      @alejandro_ao  3 месяца назад +1

      hey there! thank you for telling me this :) keep it up and keep learning 🚀 i'll bring up agents here very soon!

  • @jatinnandwani6678
    @jatinnandwani6678 3 месяца назад +3

    Thanks Alejandro!

    • @alejandro_ao
      @alejandro_ao  3 месяца назад

      Thank you man, you are amazing

  • @teddyperera8531
    @teddyperera8531 16 дней назад

    This is a great tutorial. Thanks for explaining it in a way that's easy to understand

    • @alejandro_ao
      @alejandro_ao  8 дней назад

      thanks Teddy! i’m glad it was useful!

  • @msssouza2
    @msssouza2 24 дня назад

    Hi Alejandro. Great post! It helped me a lot. I was trying to find a Gemini alternative to a solution that I learned from a Udemy course, using LangChain and OpenAI Agents to access a SQLite database and pass the results to the OpenAI LLM. I searched for days and found nothing, until I saw your video. Now my code is running and I can see many possibilities for accessing enterprise databases to enable users to obtain results using generative AI. Thank you and greetings from Brazil.

  • @artislove491
    @artislove491 3 месяца назад

    Great stuff! Many thanks 💪

  • @bwilliams060
    @bwilliams060 3 месяца назад

    Your videos are the best!

  • @dgm1949
    @dgm1949 2 месяца назад

    Thank you for your videos. As a subscriber to your channel, I look forward to each new one. I would like to make a comment, and perhaps a suggestion for a future video. As a Finance Manager for the last 40+ years, I have come to find these three areas important as it relates to the retrieval of information. What every office need is a way to search:
    1) URL's , EXCEL, and PDF on the internet.
    2) EXCEL and CSV files locally. (and Securely)
    3) PDF and DOC documents locally. (and Securely)
    And nowadays, you could never get a NON GUI program adopted by the office staff. And of course, all three of the search types would be incorporated into the same GUI.
    Python based program would be the preferred language. OLLAMA based. NO DOCKER. No wrapper programs like streamlit, etc. Thanks for your time, and keep up the good work.

    • @alejandro_ao
      @alejandro_ao  2 месяца назад

      Hey there, thanks for following the channel and for your suggestions!
      I see what you mean and agree that in order to get an app adopted internally, it should be very straightforward and easy to use.
      However, I don't see why it shouldn't use streamlit? Streamlit is just a way to build the GUI in a few lines of code. And if what you are interested in is the privacy, you can totally host it internally and have your data never leave your network.

  • @chibuzoemelike6403
    @chibuzoemelike6403 3 месяца назад

    Thank you so much for this video, this is really helpful!! Looking forward to using huggingface models

    • @alejandro_ao
      @alejandro_ao  3 месяца назад

      Great! Which models in particular are you interested in?

    • @palanikumarmsc
      @palanikumarmsc 25 дней назад

      Mistral AI

  • @Aidev7876
    @Aidev7876 3 месяца назад

    Thanks. What about long ot short term memory during conversation?

  • @bitcoinjc
    @bitcoinjc 2 дня назад +1

    Will this work with a Microsoft SQL relational database that is much bigger too?

  • @victorchrist9899
    @victorchrist9899 2 месяца назад

    for the GUI, what tool would you suggest one can use to return a table, just like in mysql

  • @natawebmaster
    @natawebmaster 2 месяца назад

    Thanks for useful video)

  • @sam-uw3gf
    @sam-uw3gf 3 месяца назад

    great as always bro

  • @Matepediaoficial
    @Matepediaoficial 3 месяца назад

    I love you!! You are the best!!!

  • @anismairi865
    @anismairi865 2 месяца назад +2

    When i write the code in py file, the schema variable in full_chain function s returning an error (it expect dict type and get_schema return str), do you have any idea on how to fix it ? i've checked langchain doc + you article but i still cant find a solution...
    thanks for all the tutorials i've learned a lot, keep going !

  • @abhaypkyek
    @abhaypkyek 3 месяца назад

    You really made my day. i was trying to figure out this code from Langchain templates from many days. But you gave a perfect clarity giving step by step understanding. Thanks alot for that. Can u further enhance this in your next video as said in the end of the video with ollama & vizualization from the response using PandasAI or LIDA AI or something better please.

    • @alejandro_ao
      @alejandro_ao  3 месяца назад

      it's great to hear this! thank you for letting me know. and congrats for finally getting through it! keep it up 👍 that's actually a great idea. i'll see if i can put it in the next video or make a dedicated video about this!

  • @user-im3zw4ge7b
    @user-im3zw4ge7b 3 месяца назад

    Excellent! ♥

    • @alejandro_ao
      @alejandro_ao  3 месяца назад

      i really need to update my video on memory. i'll look into it!

  • @fbravoc9748
    @fbravoc9748 2 месяца назад

    Amazing video!! Thanks for creating it!! Is there a way to apply the same principles but with another LLMs (open-source)?? If I had gone over all the database I am working with and I had identified the queries related to the most frequent questions, how can I finetune my queries to these frequent questions? ..should I think about adding RAG logic to it?

  • @guanjwcn
    @guanjwcn 3 месяца назад

    Awesome. Could you include streaming in part 2 as well?

    • @alejandro_ao
      @alejandro_ao  3 месяца назад

      streaming is coming very soon 😎

  • @BrandonFoltz
    @BrandonFoltz 3 месяца назад

    Fabulous!

  • @av1743
    @av1743 2 месяца назад

    Thanks for posting this. Very helpful. is there any open source LLM which can convert Natural language to SQL ? would Llama, Flan T5 etc work instead of gpt ?

  • @machinelearningzone.6230
    @machinelearningzone.6230 Месяц назад

    Awesome tutorial! I tried to implement the same on collar, using a sqlite database(chinook). but consistently get the error:"'NoneType' object has no attribute 'get_table_info'" when I try to ge the table schema. Any work arounds?

  • @rameshh3821
    @rameshh3821 6 дней назад

    Could you please let me know if it's possible to use LangChain to query multiple tables and generate data visualizations on the chatbot interface? I've seen solutions for a single CSV file using PandasAI or LIDA, but I haven't found anything that works with multiple tables stored in a database.

  • @abdulrahmanalrabah8324
    @abdulrahmanalrabah8324 Месяц назад

    I was wondering if your calendly link is working for consultations ?it seems that its down

  • @SanjayRoy-vz5ih
    @SanjayRoy-vz5ih 3 месяца назад +2

    Have done it with SAP Hana DB 6 month back..issue related hallucinations are faced and token size limit is also a constraint with open ai GPT 3.5 turbo

    • @vojtechkaiser2525
      @vojtechkaiser2525 21 день назад

      Did you make it work at the end? Or was not worth the struggle?

    • @SanjayRoy-vz5ih
      @SanjayRoy-vz5ih 21 день назад

      @@vojtechkaiser2525 Not much work done on that further but of course you can use combination of SQL agent and combinations of prompt techniques but the issues is different as you SAP would not support or recommend working directly with SQL tables but I would still try it as Q&A bot simply as an "art of possible" solution...I am now trying to do the same using combination of OData API and through BTP using function calls and agent architecture

  • @scratch6594
    @scratch6594 23 дня назад

    Hey , is it possible to run DML queries using chains or agents?

  • @Jaypatel512
    @Jaypatel512 2 месяца назад

    Hey, thanks for the video. However, few questions if you don't mind:
    1. Do we need to assign the sql_chain inputs again when building a full_chain ? Won't it remember from its own structure. I see that as complexity grows, we end up adding a whole bunch of assignment in full chain.
    2. For full chain, is there a way to use pipe operator to let the sql_chain response be passed to the next step where you run_query ? Basically, RunnablePassthrough.assign(sql_chain) | run_query | prompt | llm | StrOutput... ?
    Thanks again for your wonderful tutorials.

  • @dr.aravindacvnmamit3770
    @dr.aravindacvnmamit3770 3 месяца назад

    Hey very nice,
    I had one query , LLM based Application to assess the quality of language being used by parents and give practice sessions to improve them.
    Can you show us "It is a kind of Therapy for special children to make understand the words

  • @drummermike5150
    @drummermike5150 3 месяца назад +1

    Great tutorial as usual Alejandro! Is it possible to do this with SQL Server? I look at the documentation and it doesn't appear so but maybe I'm missing something.

    • @alejandro_ao
      @alejandro_ao  3 месяца назад

      Thanks! I am not sure how it would work with MS SQL Server. I suppose you would need a driver to connect it. Since SQLAlchemy supports it, I suppose that it can be done. Maybe if you add the driver to the URI like we did here, but instead of adding the MySQL driver, you add one for MS SQL Server? I checked and this driver might work, but I am not on Windows, so I have no way of testing it right away:
      ```python
      from langchain_community.utilities import SQLDatabase
      db_uri = "mssql+pyodbc://username:password@hostname:port/DatabaseName?driver=SQL+Server"
      db = SQLDatabase.from_uri(db_uri)
      ```

    • @drummermike5150
      @drummermike5150 3 месяца назад

      @@alejandro_aoI'll give that a try. Thanks much!!

  • @madhutera298
    @madhutera298 2 месяца назад

    Thanks!

    • @madhutera298
      @madhutera298 2 месяца назад

      Hi - how does this work when the response returns table data - example - show me top 10 artists by song streaming count?

    • @alejandro_ao
      @alejandro_ao  2 месяца назад

      hey there! thank you so much for the tip!! it totally would work. the results are always a table actually. what happens is that the LLM receives a table-like prompt and reads it as though it were simple text. so in this case, your LLM would receive the table in the prompt and return something like "the top 10 artists are...." and it may even give you more details depending on your initial instructions :)

  • @tanzeelmohammed9157
    @tanzeelmohammed9157 Месяц назад

    Hi Alejandro
    I have been trying to do the same thing. The problem I do not have credit in OpenAI and i wanted to know if there is any other way using opensource models to achieve the same result..specially in LangChain. Is there any other way?

  • @youngchrisyang
    @youngchrisyang 2 месяца назад

    Thanks so much Alejandro! Great contents. Btw seems your website is down today>?

    • @alejandro_ao
      @alejandro_ao  2 месяца назад

      hey there, thanks! can you check again? i think my dns has been struggling with some changes i did recently :S

    • @youngchrisyang
      @youngchrisyang 2 месяца назад

      @@alejandro_ao Thank you Alejandro. All works fine now!

  • @muneerAbro
    @muneerAbro 12 дней назад

    Very Informative video ❤, can you create this video in PHP

    • @alejandro_ao
      @alejandro_ao  5 дней назад

      hey, thanks! i would like to but unfortunately langchain does not have a PHP version that I know of :( if you are trying to create something like this for a PHP app, I would create an API that deals with these processes in python or js and then have my PHP app query this API

  • @geekyprogrammer4831
    @geekyprogrammer4831 3 месяца назад

    Can you create langchain based streaming chatbot? Would be very helpful. Thanks for creating high quality contents!

  • @protimaranipaul7107
    @protimaranipaul7107 17 дней назад

    Could you please elaborate on the following with respect to SQL agents:
    Handling Relationships with Multiple Tables:
    How can we manage relations involving multiple tables, specifically with primary and foreign keys, given token limitations and potentially multiple agents?
    Similarity Search in Databases:
    How can we perform a similarity search within a SQL database? For example, if we have several film plots stored in the database, how can we find films with similar plots?
    Orchestration Between SQL and JSON Databases (MongoDB):
    How can we orchestrate data between SQL databases and JSON-based databases like MongoDB without converting everything to SQL, which can be time-consuming?
    Displaying Subsets of Tables:
    How can we present a subset of data from multiple tables in the database to the user? Should we parse JSON or CSV formats for this purpose?
    Utility of Graph Databases:
    Can Graph databases provide solutions to the above challenges?

  • @ArunPrasathR-sp6lt
    @ArunPrasathR-sp6lt Месяц назад

    Should I make predictions about the future based on the data in my table?

  • @isvic007
    @isvic007 2 месяца назад

    Can we not using Oracle DB for this test?

  • @KurskikhA
    @KurskikhA 2 месяца назад

    Hi, been following you for a long time, very cool content. Can you please tell me how to use Langchain for MSSQL or Postgres?

    • @alejandro_ao
      @alejandro_ao  2 месяца назад +1

      hey there! thanks for following the content :) i'll be putting up a video about postgres soon. i actually haven't tested if this would work using a mssql driver. but look, apparently you can pass in a driver just like we did here with mysql, but for MSSQL: docs.sqlalchemy.org/en/20/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pyodbc

  • @marvinmarkham8405
    @marvinmarkham8405 9 дней назад

    Videos are exceptional just very high level and the mic seems close when speaking so its not pleaseant for me to watch the vids with that type of mic calibration. Luckily the website is a better walkthough for me. Thanks for your work

    • @alejandro_ao
      @alejandro_ao  8 дней назад

      hey thank you for the feedback, glad you found the tutorial useful mate. i’ll improve the sound in future vids :)

  • @abhishekbourai1832
    @abhishekbourai1832 Месяц назад +1

    Thanks for such amazing resource, Alejandro.. i am getting this error: attributeerror : dict object has no attribute get_table_info.. when i try to invoke chain

    • @alejandro_ao
      @alejandro_ao  Месяц назад

      seems to me like your database instance is not being created. try logging the type of your SQL client to see if it was actually defined

  • @jimgsewell
    @jimgsewell 3 месяца назад

    Thank you. This is a real interesting idea. I wonder how complex of a question you can ask it. Can it come up with a query which requires a merging of tables, or returning multiple values? You have me curious.

    • @mwdcodeninja
      @mwdcodeninja 3 месяца назад

      I have used this method to join across a db of 34 tables to form a master document archive for customer data. I was happy with it.

    • @alejandro_ao
      @alejandro_ao  3 месяца назад +1

      absolutely, it all depends on your LLM's accuracy at executing the queries. in my experience, GPT3 16k is very good. as @sanjayojha1 mentioned, a coding-specific LLM might give you even better results. just don't forget to limit the scope of your MySQL user to avoid security problems!

    • @chibuzoemelike6403
      @chibuzoemelike6403 3 месяца назад

      @@mwdcodeninja wow, it's glad you've been able to use this before and it performs a join. I'm working on a project with bigquery which has so many data, it doesn't give the desired output as it doesn't perform join, I'll be glad if we can connect and work on it together. Thank you in advance

    • @chibuzoemelike6403
      @chibuzoemelike6403 3 месяца назад

      @@alejandro_ao please how do we implement a code specific LLM to the chain.

    • @mwdcodeninja
      @mwdcodeninja 3 месяца назад

      @@chibuzoemelike6403 would you be able to share the schema?

  • @user-pr6nm2di6d
    @user-pr6nm2di6d 3 месяца назад

    ❤❤Can u apply RAG on schema to accommodate bigger Databases with huge tables in next video?

  • @AIWALABRO
    @AIWALABRO 2 месяца назад

    can you tell me at timestamp 14:29 what is grep SQL, i confused when I was doing , it shows it not recognizing

    • @alejandro_ao
      @alejandro_ao  2 месяца назад

      hey there, that's just to only return the lines that contain the string "sql" when doing 'pip freeze'. otherwise i would get the huge list of all the packages installed. 'grep' is a unix command that allows you to filter the output text and return only the lines that contain the passed string 👍

  • @dswithanand
    @dswithanand Месяц назад

    I made the sqldb chatbot using fastapi and every thing is working fine except that the chat memory history. Can you suggest how can we implement memory with fastapi.

    • @dswithanand
      @dswithanand Месяц назад

      Can you please answer this

  • @07-bmanohar70
    @07-bmanohar70 2 месяца назад

    Does this can be implemented to the large Databases ?

    • @alejandro_ao
      @alejandro_ao  2 месяца назад

      absolutely, just be careful that these two things fall within your context window:
      - the table schemas of your database (unless you have a humungous number of tables, it should be fine).
      - the results from your query (as they they will be sent back to the model for interpretation).
      the second point is more tricky than the first one. you may want to update your prompt to make sure that it does not allow to query more than X number of records at a time.

    • @MrJaczes
      @MrJaczes Месяц назад

      @@alejandro_ao i thought about this topic to use Views to handle sets form large database and pre-agregate it there

  • @sanjayojha1
    @sanjayojha1 3 месяца назад

    Great as always. I personally find the RunnablePassthrough ugly syntax and confusing. Also, using a coding specific LLM we might get better SQL query with less hallucination.

    • @alejandro_ao
      @alejandro_ao  3 месяца назад

      hey good to see you again. thanks! i totally agree with you that RunnablePassthrough could be better. and about the LLM, totally. not only better, but also faster, as it would be a smaller model 🤔

    • @chibuzoemelike6403
      @chibuzoemelike6403 3 месяца назад

      Please what do you mean by coding specific LLM?

  • @warrenmarkham8891
    @warrenmarkham8891 2 месяца назад

    Thanks for the content. The link to your blog post doesn't work for me.

    • @alejandro_ao
      @alejandro_ao  2 месяца назад

      hey there, can you try again? i think my dns server was giving me trouble last week

    • @warrenmarkham8891
      @warrenmarkham8891 2 месяца назад

      @@alejandro_ao Still not working I'm afraid.

    • @alejandro_ao
      @alejandro_ao  2 месяца назад

      @@warrenmarkham8891 just refreshed the DNS settings on netlify! Should be up now!!

    • @warrenmarkham8891
      @warrenmarkham8891 2 месяца назад

      @@alejandro_ao Yep, you punched the right ticket that time. It is now working great.

  • @user-vj8fc2ji7b
    @user-vj8fc2ji7b 2 месяца назад

    It's a wonderful session but the link to your blog post doesn't working.

    • @alejandro_ao
      @alejandro_ao  2 месяца назад

      just fixed it! DNS propagation problem after meddling with some records on netlify :S

  • @user-kx4cg7su8b
    @user-kx4cg7su8b 2 месяца назад

    Great tutorial, Thanks a lot. I am watching from India and your website is not opening. Don't know why.

  • @monica.b181
    @monica.b181 3 месяца назад

    Awesome videos.. really appreciate your efforts 👍
    Could you please make a video to create a chat bot for WordPress websites.. because scrapping the content from WordPress websites is a bit tricky and passing them to divide into chunks are throwing errors...please help

    • @monica.b181
      @monica.b181 3 месяца назад

      @UC1oXUA7qgs0GZc_yk46K2OQ hi, I am grateful you replied to my comment 😊🙏
      Actually I don't have access to deal with database..the idea of my project is to create a webchat bot for dynamic WordPress websites, where I can scrape all the content from sitemap.xml and then divide it into chunks -> store in any database like faiss or vector store and finally with streamlit I would able to chat with the content on the site.
      So I need your help in this, as I am beginner and new to these technologies. Please

    • @monica.b181
      @monica.b181 3 месяца назад

      @UC1oXUA7qgs0GZc_yk46K2OQ hi, I am grateful you replied to my comment 😊🙏
      Actually I don't have access to deal with database..the idea of my project is to create a webchat bot for dynamic WordPress websites, where I can scrape all the content from sitemap.xml and then divide it into chunks -> store in any database like faiss or vector store and finally with streamlit I would able to chat with the content on the site.
      So I need your help in this, as I am beginner and new to these technologies. Please

  • @nazarmohammed5681
    @nazarmohammed5681 3 месяца назад +1

    chatting with website using gemini pro plz make a video on this???????

  • @monishamonisha-zt3uy
    @monishamonisha-zt3uy 2 месяца назад

    When I execute full_chain.invoke
    ({"question": "how many albums are there in the database?"}) it returns {'question': 'how many albums are there in the database?'}

    • @kartiksaini-xn6ke
      @kartiksaini-xn6ke Месяц назад

      i am facing the same issue, did you get any solution ?

  • @AdhisashanJ
    @AdhisashanJ 21 день назад

    Nice, how to do column mapping.
    Like "How many creator are there" as input question but we have artist instead. I tried as below but still it not works
    sql_chain = (
    RunnablePassthrough.assign(schema=get_schema, column_mapping=get_column_mapping)
    | prompt
    | llm.bind(stop=["\
    SQLResult:"])
    | StrOutputParser()
    )
    column_mapping = {
    r'creator|artists': 'artist',
    # Add more mappings as needed
    }
    def get_column_mapping(_):
    column_mapping_str = "
    ".join([f"{key}: {value}" for key, value in column_mapping.items()])
    return column_mapping_str

  • @dswithanand
    @dswithanand Месяц назад

    I have a question: If the database belongs to an e-commerce website with a substantial product inventory, and a user query such as 'SHOW ME PRODUCTS' risks exceeding the ChatGPT token limit of 60000, how can this issue be effectively managed?

    • @alejandro_ao
      @alejandro_ao  Месяц назад +1

      Yeah, maybe that will require a bit of prompt engineering to make sure that you never index more than X number of records. You could add something like "if you are selecting records, please never call more than 100 records in a single query" or something like that. another alternative would be to use an agent, that would make it more flexible

    • @dswithanand
      @dswithanand Месяц назад

      @@alejandro_ao Thanks for reply.. I tested this and it actually worked. Thanks bro

  • @MADMAX-rw7jx
    @MADMAX-rw7jx 2 месяца назад

    There is no password in my SQL server what to put in db_uri sir

  • @AA-hb6sc
    @AA-hb6sc 2 месяца назад +15

    This tutorial looks nice in "theory". There are several things that are wrong with this approach. Firstly, it is very insecure to fetch the database schema to a third-party provider, whoever this is. These langchain packages are not very secure, even if they are used by the community. Secondly, running the generated sql query without verification is a red flag. Yes, you can play with this, but running this in production may cause a mess. Thirdly, the prompt included a very basic query. How does this work with more complex code that is typically required in a production environment? I would really like to see the accuracy of these generated queries and the probability of actually getting a correct query from the get-go. Not to mention, how would you test this in production? How would you assign roles and permissions to run queries on top of the database. Man, there are too many wrongs things with this that seemed to be avoided, because this a new flashy approach versus the traditional way. Just because it's new, it doesn't make it better.

    • @ajayjangid7830
      @ajayjangid7830 2 месяца назад +1

      💯 agreed on your view..still there are challenges LLM struggle on column names which are complex or similar in synonyms although we are providing schema.

    • @LeeYeon-qv1tz
      @LeeYeon-qv1tz 2 месяца назад +1

      I wish I knew this before 😢

    • @AA-hb6sc
      @AA-hb6sc 2 месяца назад

      @@LeeYeon-qv1tz What happened?

    • @LeeYeon-qv1tz
      @LeeYeon-qv1tz 2 месяца назад +2

      @@AA-hb6sc I developed an application which generates query for given data and question. It worked for simple queries. I didn't check for complex query. Later when I showed this to someone, they asked complex queries. None was answered well. Iam really disappointed.

    • @AA-hb6sc
      @AA-hb6sc Месяц назад

      @@wheresthecode Hey buddy! Based on your response, it seems like you don't have a lot of experience with production-level systems. However, I am going to respond back:
      1. sure, you can create a read-only select account. However, if you are going to send a ton of queries to the database, you are going to overload it and you have to have it properly tuned to support all these concurrent queries, especially if you have a lot of users. There are use-cases, especially with more complicated queries whether this cannot be easily achieved and it will take more than to generate the query, if it could be guaranteed that it will be correctly created.
      2. nobody has time to create comments about the database schema and doing this, again adds additional data governance and security issues, which need to be mitigated. In some cases, the people that created the database schemas do not even want to reveal the column names or provide any information, because it is a breach of intellectual property. Having such a trace, could potentially mean that you are actually replicating the database schema.
      3. how do you ensure that this template cannot be hacked or accessed in the process?

  • @KARAN_RANA36
    @KARAN_RANA36 3 месяца назад

    one video on SORA by openai it's look's Amaze and it's may be a Opecity between reality and virtual reality

    • @alejandro_ao
      @alejandro_ao  3 месяца назад +1

      I'll do that as soon as I get my hands on it 😈

  • @matten_zero
    @matten_zero 3 месяца назад

    Can you do this with NoSQL like MongoDB🙏?

  • @mohsenghafari7652
    @mohsenghafari7652 3 месяца назад

    ❤❤❤

  • @user-cx9bs9ig9g
    @user-cx9bs9ig9g 2 месяца назад

    is open ai compulsary?

    • @alejandro_ao
      @alejandro_ao  2 месяца назад +1

      absolutely not. you can import any language model that langchain supports: python.langchain.com/docs/integrations/chat/

  • @seththunder2077
    @seththunder2077 3 месяца назад

    Could you please do with memory

    • @alejandro_ao
      @alejandro_ao  3 месяца назад

      we would have to update the chain and add memory to it! i'll make a video about it!

    • @seththunder2077
      @seththunder2077 3 месяца назад

      @@alejandro_ao update the chain how?

  • @Ans5462
    @Ans5462 2 месяца назад

    Chat with MongoDB Database is Possible?

    • @alejandro_ao
      @alejandro_ao  2 месяца назад

      a bit more complex but totally possible. i'll make a video about it soon

  • @florencia9427
    @florencia9427 3 месяца назад

    tenes un canal en español?

    • @alejandro_ao
      @alejandro_ao  3 месяца назад +1

      hola! lamentablemente no :( pero creo que youtube traduce los subtítulos automáticamente, no?

  • @alejandrocano5323
    @alejandrocano5323 2 месяца назад +1

    how to manage that the first chain doest find the information in the SQL Schema?

  • @drumzed1724
    @drumzed1724 3 месяца назад

    need your email

  • @ArunPrasathR-sp6lt
    @ArunPrasathR-sp6lt Месяц назад

    Should I make predictions about the future based on the data in my table?

    • @alejandro_ao
      @alejandro_ao  Месяц назад +1

      you could, but that would require training a ML model. that's usually something that you would do separately as you will need a lot of data processing and cleaning to do that

  • @nazarmohammed5681
    @nazarmohammed5681 3 месяца назад

    chatting with website using gemini pro plz make a video on this???????

    • @alejandro_ao
      @alejandro_ao  3 месяца назад

      hey again! and huggingface coming soon too!!!!!!!!!

    • @nazarmohammed5681
      @nazarmohammed5681 3 месяца назад

      @@alejandro_ao waiting for that

    • @nazarmohammed5681
      @nazarmohammed5681 3 месяца назад

      @@alejandro_ao hugging face also using gemini