The app interface has three main components: a real-time map, a chatbot interface, and clinic information query boxes. When a user enters information into the chatbot, it classifies the questions into different categories and runs the appropriate LLM (Large Language Model) routing for each type of question. The map zooms in on the relevant location for questions associated with geolocated data in the database and displays the related clinic and services. The clinic details, including reviews and services, are retrieved from Google Maps and the clinic's website, which is crawled for information. This data is added to the database for future queries, eliminating the need to fetch it from Google Maps again.
We used Dash Plotly to construct the web app. The source code can be found at Shengting Cao repo.
conda create -n OKN python=3.10
pip install dash
pip install pandas
OKN/
├── assets/
├── Datasets/ # For survey data
├── pages/
├── app.py
└── README.md
Refer to Dash's documentation for Multipage Design.
To customize the map style, use the following in fig.update()
:
"open-street-map", "carto-positron", "carto-darkmatter",
"stamen-terrain", "stamen-toner", "stamen-watercolor",
"white-bg", "basic", "streets", "outdoors",
"light", "dark", "satellite", "satellite-streets"
pip install dash psycopg2 sqlalchemy
postgresql+psycopg2://username:password@host:port/database
import os
os.environ['okn_database'] = "password"
os.environ['OPENAI_API_KEY'] = "password"
Or set them in your system environment variables and restart the terminal.
tabula-py
for extracting tables from PDFs: pip install tabula-py
Java is required to run tabula-py
: Java Download
jpype1
: pip install jpype1
Alternatively, use camelot-py
which is less dependent on Java:
pip install camelot-py[cv]
pip install 'PyPDF2<3.0'
import camelot
pdf_path = "path/to/your/pdf_file.pdf"
tables = camelot.read_pdf(pdf_path, pages='all')
for i, table in enumerate(tables):
print(f"Table {i}")
table.to_csv(f"table_{i}.csv")
geopy
We used geopy
to retrieve latitude and longitude for addresses. Documentation: geopy.
Install geopy
:
pip install geopy
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="geoapiExercises")
address = "1600 Amphitheatre Parkway, Mountain View, CA"
location = geolocator.geocode(address)
if location:
print(f"Latitude: {location.latitude}, Longitude: {location.longitude}")
else:
print("Location not found")
For Google API, use the Google Geocoding API.