Jelajahi Sumber

added readme to text2sql end to end usecase (#875)

Igor Kasianenko 2 bulan lalu
induk
melakukan
31a951ade7

+ 30 - 0
end-to-end-use-cases/coding/text2sql/README.md

@@ -0,0 +1,30 @@
+## Text2SQL: Natural Language to SQL Interface
+
+This project provides a set of scripts to convert natural language queries into SQL statements using Meta's Llama model. The goal is to enable users to interact with databases using natural language inputs, making it easier for non-technical users to access and analyze data. 
+
+For detailed instructions on setting up the environment, creating a database, and executing natural language queries using the Text2SQL interface, please refer to the quickstart.ipynb notebook.
+
+### Structure:
+
+- quickstart.ipynb: A Quick Demo of Text2SQL Using Llama 3.3. This Jupyter Notebook includes examples of how to use the interface to execute natural language queries on the sample data. It uses Llama 3.3 to answer questions about a SQLite database using LangChain and the Llama cloud provider Together.ai.
+- nba.txt: A text file containing NBA roster information, which is used as sample data for demonstration purposes.
+- txt2csv.py: A script that converts text data into a CSV format. This script is used to preprocess the input data before it is fed into csv2db.py.
+- csv2db.py: A script that imports data from a CSV file into a SQLite database. This script is used to populate the database with sample data.
+- nba_roster.db: A SQLite database file created from the nba.txt data, used to test the Text2SQL interface.
+
+### Detailed steps on running the notebook:
+
+- Before getting started, please make sure to setup Together.ai and get an API key from [here](https://www.together.ai/). 
+
+- First, please install the requirements from [here](https://github.com/meta-llama/llama-cookbook/blob/main/end-to-end-use-cases/coding/text2sql/requierements.txt) by running inside the folder:
+
+```
+git clone https://github.com/meta-llama/llama-cookbook.git
+cd llama-cookbook/end-to-end-use-cases/coding/text2sql/
+pip install -r requirements.txt
+```
+
+### Contributing
+Contributions are welcome! If you'd like to add new features or improve existing ones, please submit a pull request. We encourage contributions in the following areas:
+- Adding support for additional databases
+- Developing new interfaces or applications that use the Text2SQL interface

+ 2 - 2
end-to-end-use-cases/coding/text2sql/quickstart.ipynb

@@ -11,7 +11,7 @@
     "\n",
     "This demo shows how to use Llama 3.3 to answer questions about a SQLite DB. \n",
     "\n",
-    "We'll use LangChain and the Llama cloud provider [Together.ai](https://api.together.ai/), where you can easily get a free API key (or you can use any other Llama cloud provider or even Ollama running Llama locally - see [here](https://github.com/meta-llama/llama-recipes/tree/main/recipes/quickstart) for examples)."
+    "We'll use LangChain and the Llama cloud provider [Together.ai](https://api.together.ai/), where you can easily get a free API key (or you can use any other Llama cloud provider or even Ollama running Llama locally)."
    ]
   },
   {
@@ -21,7 +21,7 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "!pip install -U langchain langchain-community langchain-together"
+    "!pip install --upgrade -r requirements.txt"
    ]
   },
   {

+ 3 - 0
end-to-end-use-cases/coding/text2sql/requirements.txt

@@ -0,0 +1,3 @@
+langchain
+langchain-community
+langchain-together