Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ In this video tutorial I will show you how you can use streamlit, Ollama llama3
[Watch the video](https://www.youtube.com/watch?v=1Q1wv6J2Z1A)

## Installation
1. Clone the repository
2. Install the required libraries
1. install ollama
2. download and integrate llama3.1
```bash
ollama pull llama3.1
```
3. serve ollama
```bash
ollama serve
```
4. Clone the repository
5. Install the required libraries
```bash
pip install -r requirements.txt
```
3. Run the app
6. Run the app
```bash
streamlit run app.py
```
Expand Down
16 changes: 12 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
from langchain_community.chat_models import ChatOllama
from langchain_community.utilities import SQLDatabase
from langchain_core.prompts import ChatPromptTemplate
from urllib.parse import quote_plus


# def connectDatabase(username, port, host, password, database):
# mysql_uri = f"mysql+mysqlconnector://{username}:{password}@{host}:{port}/{database}"
# print(mysql_uri)
# st.session_state.db = SQLDatabase.from_uri(mysql_uri)
def connectDatabase(username, port, host, password, database):
mysql_uri = f"mysql+mysqlconnector://{username}:{password}@{host}:{port}/{database}"
st.session_state.db = SQLDatabase.from_uri(mysql_uri)
# URL encode the password to handle special characters
encoded_password = quote_plus(password)
mysql_uri = f"mysql+mysqlconnector://{username}:{encoded_password}@{host}:{port}/{database}"
print(mysql_uri)
st.session_state.db = SQLDatabase.from_uri(mysql_uri)



def runQuery(query):
Expand All @@ -17,7 +25,7 @@ def getDatabaseSchema():
return st.session_state.db.get_table_info() if st.session_state.db else "Please connect to database"


llm = ChatOllama(model="llama3")
llm = ChatOllama(model="llama3.1")


def getQueryFromLLM(question):
Expand Down