Skip to content

Commit

Permalink
Fix issue with ENV mismatch between app and service (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaC215 authored Dec 1, 2024
1 parent 58a56ce commit 76702ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ MODE=
# OpenWeatherMap API key
OPENWEATHERMAP_API_KEY=

# Agent URL (used in Streamlit app, it usually should be the same as HOST:PORT)
AGENT_URL=http://localhost:80
# Agent URL: used in Streamlit app - if not set, defaults to http://{HOST}:{PORT}
# AGENT_URL=http://localhost:80
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

httpx~=0.27.2
pydantic ~=2.10.1
python-dotenv ~=1.0.1
streamlit~=1.40.1
11 changes: 8 additions & 3 deletions src/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections.abc import AsyncGenerator

import streamlit as st
from dotenv import load_dotenv
from pydantic import ValidationError
from streamlit.runtime.scriptrunner import get_script_run_ctx

Expand Down Expand Up @@ -57,9 +58,13 @@ async def main() -> None:
st.rerun()

if "agent_client" not in st.session_state:
st.session_state.agent_client = AgentClient(
base_url=os.getenv("AGENT_URL", "http://localhost")
)
load_dotenv()
agent_url = os.getenv("AGENT_URL")
if not agent_url:
host = os.getenv("HOST", "0.0.0.0")
port = os.getenv("PORT", 80)
agent_url = f"http://{host}:{port}"
st.session_state.agent_client = AgentClient(base_url=agent_url)
agent_client: AgentClient = st.session_state.agent_client

if "thread_id" not in st.session_state:
Expand Down

0 comments on commit 76702ef

Please sign in to comment.