streamlit-app
template provides codebase with Streamlit & PostgreSQL, a stack we love for its simplicity. Its simple but not to be underestimated.
Setup
1
Create a virtual environment
2
Install phidata
3
Install docker
Install docker desktop to run your app locally
4
Export your OpenAI key
You can get an API key from here.
Create your codebase
Create your codebase using thestreamlit-app
template
streamlit-app
with the following structure:
Set OpenAI Key
Set yourOPENAI_API_KEY
as an environment variable. You can get one from OpenAI.
Local Streamlit App
Streamlit allows us to build micro front-ends and is an extremely useful tool for building basic applications in pure python. Start your workspace using:Follow these steps to only run Streamlit without Postgres.
Run Streamlit without Postgres
Run Streamlit without Postgres
A common use case is to just use Streamlit without the database. In that case, deactivate the database from the
workspace/settings.py
file and update the agents to not use storage or knowledge base.1
Disable database
Update the
workspace/settings.py
file and set dev_db_enabled=False
and prd_db_enabled=False
workspace/settings.py
2
Remove knowledge base and storage from the Agents
Update each file in the
ai/agents
folder to remove the storage and knowledge base from the Agents
.Add your data
The PDF Agent uses thepdf_knowledge_base
defined in the ai/knowledge_base.py
file. To add your own PDFs:
1
Create a folder with your data
Create a folder
data/pdfs
in the root directory of your app2
Add your data
Add your files to the
data/pdfs
folder3
Update Knowledge Base
Click on the
Update Knowledge Base
button to load the knowledge base.ai/knowledge_base.py
file for more information.
How this App works
The streamlit apps are defined in theapp
folder and the Agents
powering these apps are defined in the ai/agents
folder. Checkout the files in the ai/agents
folder for more information.
Delete local resources
Play around and stop the workspace using:Next
Congratulations on running your Streamlit App locally. Next Steps:- Run your Streamlit App on AWS
- Read how to update workspace settings
- Read how to create a git repository for your workspace
- Read how to manage the development application
- Read how to format and validate your code
- Read how to add python libraries
- Chat with us on discord