Skip to content

Commit 4073d30

Browse files
committed
use streamlit page feature to unify apps
1 parent 7ab5fab commit 4073d30

File tree

14 files changed

+70
-71
lines changed

14 files changed

+70
-71
lines changed

Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,14 @@ ci-test-docker: docker-compose-lint ## run CI test for Docker
101101
# ---
102102
# Application
103103
# ---
104-
SOLUTION_NAME ?= "SANDBOX"
105-
BACKEND_URL ?= "http://localhost:8000"
106-
107104
.PHONY: backend
108105
backend: ## run backend
109106
poetry run python main.py backend --reload
110107

111108
.PHONY: frontend
112109
frontend: ## run frontend
113-
poetry run streamlit run main.py -- frontend -- \
114-
--solution-name=$(SOLUTION_NAME) \
115-
--backend-url=$(BACKEND_URL)
110+
cd frontend \
111+
&& poetry run streamlit run main.py
116112

117113
# ---
118114
# Azure Functions
File renamed without changes.

frontend/__init__.py

Whitespace-only changes.

frontend/entrypoint.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

frontend/main.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import streamlit as st
2+
3+
4+
def init_page():
5+
st.set_page_config(page_title="Azure AI Solutions", page_icon="🧐")
6+
7+
8+
def main():
9+
init_page()
10+
11+
st.sidebar.success("Please select apps from the sidebar menu")
12+
13+
st.markdown(
14+
"""
15+
### Welcome to Azure AI Solutions
16+
17+
- This app shows some use cases with Azure AI Services
18+
- Got to the pages from the left menu
19+
"""
20+
)
21+
22+
23+
if __name__ == "__main__":
24+
main()

frontend/solutions/azure_ai_vision.py renamed to frontend/pages/azure_ai_vision.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
from urllib.parse import urljoin
55

66
import streamlit as st
7-
8-
from frontend.solutions.utilities import http_post_file
7+
from utilities import http_post_file
98

109
logger = logging.getLogger(__name__)
1110

1211

13-
def start(
12+
def main(
1413
backend_url: str,
1514
log_level: int,
1615
):
@@ -43,3 +42,10 @@ def start(
4342
st.write(response)
4443
else:
4544
st.warning("Please upload a file first")
45+
46+
47+
if __name__ == "__main__":
48+
main(
49+
backend_url="http://localhost:8000",
50+
log_level=logging.DEBUG,
51+
)

frontend/solutions/chat.py renamed to frontend/pages/chat.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from openai import AzureOpenAI
77

88
logger = logging.getLogger(__name__)
9-
load_dotenv("./settings/frontend.env")
9+
load_dotenv()
1010

1111

12-
def start(
12+
def main(
1313
backend_url: str,
1414
log_level: int,
1515
):
@@ -52,3 +52,10 @@ def start(
5252
assistant_text += content
5353
placeholder.write(assistant_text)
5454
st.session_state.messages.append({"role": "assistant", "content": assistant_text})
55+
56+
57+
if __name__ == "__main__":
58+
main(
59+
backend_url="http://localhost:8000",
60+
log_level=logging.DEBUG,
61+
)

frontend/solutions/document_intelligence.py renamed to frontend/pages/document_intelligence.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
from urllib.parse import urljoin
55

66
import streamlit as st
7-
8-
from frontend.solutions.utilities import http_post_file
7+
from utilities import http_post_file
98

109
logger = logging.getLogger(__name__)
1110

1211

13-
def start(
12+
def main(
1413
backend_url: str,
1514
log_level: int,
1615
):
@@ -41,3 +40,10 @@ def start(
4140
)
4241
)
4342
st.write(response)
43+
44+
45+
if __name__ == "__main__":
46+
main(
47+
backend_url="http://localhost:8000",
48+
log_level=logging.DEBUG,
49+
)

frontend/solutions/sandbox.py renamed to frontend/pages/sandbox.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from urllib.parse import urljoin
44

55
import streamlit as st
6-
7-
from frontend.solutions.utilities import http_get
6+
from utilities import http_get
87

98
logger = logging.getLogger(__name__)
109

@@ -34,7 +33,7 @@ async def chat_completions_post(
3433
return response.content
3534

3635

37-
def start(
36+
def main(
3837
backend_url: str,
3938
log_level: int,
4039
):
@@ -75,3 +74,10 @@ def start(
7574
except Exception as e:
7675
st.write(f"Error: {e}")
7776
logger.error(f"Error: {e}")
77+
78+
79+
if __name__ == "__main__":
80+
main(
81+
backend_url="http://localhost:8000",
82+
log_level=logging.DEBUG,
83+
)

frontend/solutions/transcription.py renamed to frontend/pages/transcription.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_transcription(file_path: str) -> Transcription:
2525
)
2626

2727

28-
def start(
28+
def main(
2929
backend_url: str,
3030
log_level: int,
3131
):
@@ -63,3 +63,10 @@ def start(
6363
# Get transcription
6464
transcription = get_transcription(audio_file_path)
6565
st.write(f"Transcription: {transcription.text}")
66+
67+
68+
if __name__ == "__main__":
69+
main(
70+
backend_url="http://localhost:8000",
71+
log_level=logging.DEBUG,
72+
)

0 commit comments

Comments
 (0)