Skip to content

Commit

Permalink
streamlit_app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Richjerk committed May 21, 2024
1 parent 9b6482c commit 1fac522
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions streamlit_app.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import streamlit as st
from geopy.geocoders import Nominatim
import requests
from PIL import Image
import os
import ollama
import streamlit as st
from PIL import Image

with open('style.css') as f:
css = f.read()



# Function for LLM interaction using Ollama3
# Mock function for LLM interaction using Ollama3
def query_ollama3(input_text):
try:
response = ollama.chat(model='llama3', messages=[{'role': 'user', 'content': input_text}])
return response['message']['content']
except Exception as e:
st.error(f"Error querying Ollama3 API: {e}")
return None
response = requests.post("https://api.ollama3.com/query", json={"input": input_text})
return response.json()["response"]

# Streamlit App
st.title("Township Small Business Chatbot")
Expand All @@ -28,7 +22,7 @@ def authenticate():
password = st.text_input("Password", type="password")
if st.button("Login"):
if username == "admin" and password == "password":
st.session_state["authenticated"] = True
st.session_state.authenticated = True
else:
st.error("Invalid credentials")

Expand All @@ -39,9 +33,9 @@ def register():
st.success("Registration successful! Please log in.")

if "authenticated" not in st.session_state:
st.session_state["authenticated"] = False
st.session_state.authenticated = False

if not st.session_state["authenticated"]:
if not st.session_state.authenticated:
st.sidebar.header("Login / Register")
auth_option = st.sidebar.radio("Choose an option", ["Login", "Register"])
if auth_option == "Login":
Expand All @@ -50,7 +44,6 @@ def register():
register()
st.stop()

857ed2c (Commit local changes)
# Business Profile Input
st.header("Business Profile")
business_name = st.text_input("Business Name")
Expand All @@ -65,8 +58,8 @@ def register():
loc = geolocator.geocode(location)
if loc:
st.write(f"Coordinates: {loc.latitude}, {loc.longitude}")
st.session_state["latitude"] = loc.latitude
st.session_state["longitude"] = loc.longitude
st.session_state.latitude = loc.latitude
st.session_state.longitude = loc.longitude
else:
st.error("Location not found!")

Expand All @@ -77,9 +70,11 @@ def register():
# Image Upload
st.header("Upload Business Images")
uploaded_files = st.file_uploader("Upload Images", accept_multiple_files=True, type=["jpg", "png", "jpeg"])
images = []
if uploaded_files:
for uploaded_file in uploaded_files:
img = Image.open(uploaded_file)
images.append(img)
st.image(img, caption=uploaded_file.name)

# Save Business Profile (Mock)
Expand All @@ -91,7 +86,7 @@ def save_business_profile():
"latitude": st.session_state.get("latitude"),
"longitude": st.session_state.get("longitude"),
"product_services": product_services,
"images": [uploaded_file.name for uploaded_file in uploaded_files]
"images": [img.filename for img in images]
}
st.success("Business profile saved successfully!")
return business_profile
Expand All @@ -105,8 +100,7 @@ def save_business_profile():
if st.button("Send Query"):
if user_query:
response = query_ollama3(user_query)
if response:
st.write("Response:", response)
st.write("Response:", response)
else:
st.error("Please enter a query")

Expand Down

0 comments on commit 1fac522

Please sign in to comment.