This demonstrates a simple UI (using Streamlit's Chat elements) that uses interacts with an AI via an api (Google's Gemini model here).
- Ideally create a new Python environment (
venv
,conda
, etc.).- Tested on Python 3.11.5
- Run
pip install -r requirements.txt
to install relevant packages. - Get an API key from Google's Google AI Studio formerly MakerSuite.
- See the Gemini API docs for more details.
- Add your API key as an environment variable called
GOOGLE_API_KEY
.- If you are on a Mac, this likely is editing
~/.zshrc
or~/.bashrc
and addingexport GOOGLE_API_KEY=...
with your own key. Make sure you reload the shell. - If you're having trouble and like to just get it to work, you can change the app script
app_chat.py
so the variableGOOGLE_API_KEY
is set to the string value of your key. Note this is a bit more risky but probably fine if you're testing out without public access.
- If you are on a Mac, this likely is editing
- Run in your terminal:
streamlit run app_chat.py
.- When using a Python environment, make sure
streamlit
is the correct one associated with your environment. Seen some weirdness before withconda
and the shell not picking up the correctstreamlit
; had to manually call it with something likeMyUser/conda/envs/my_env/bin/streamlit
.
- When using a Python environment, make sure
- Browser should open where you can now interact with the UI! Otherwise, you might have to go to http://localhost:8501/ manually.