-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
62 lines (56 loc) · 1.97 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import streamlit as st
from Modules.ModuleImport import * # 모든 모듈을 불러옵니다.
from Modules.VectorStore import *
load_dotenv()
from Modules.prompt import contextual_prompt
from Modules.prompt import translate_template1
from Modules.prompt import summary_prompt
from Modules.prompt import image_prompt_template
from Modules.ContextToPrompt import ContextToPrompt
from Modules.RetrieverWrapper import RetrieverWrapper
import Modules.Speech as Speech
from pages.chatbot_main import chatbot_main
from pages.image_main import image_main
from streamlit_option_menu import option_menu
def init():
# 경로가 없으면 생성
if not os.path.exists("History"):
os.makedirs("History")
if "openai_model" not in st.session_state:
st.session_state["openai_model"] = "gpt-4o-mini"
if "messages" not in st.session_state: # 입력값에 대한 메시지
st.session_state["messages"] = []
if "active" not in st.session_state: # 선택한 대화방
st.session_state["active"] = ""
if "side_data" not in st.session_state: # 사이드바에 표시하기위한 데이터
st.session_state["side_data"] = []
if 'rerun' not in st.session_state:
st.session_state["rerun"] = False
if 'menu' not in st.session_state:
st.session_state["menu"] = ""
st.markdown(
"""
<style>
div[data-testid="stToolbar"] {
display:none;
}
</style>
""",
unsafe_allow_html=True,
)
st.title("🚘 과시리")
# 사이드바
with st.sidebar:
def on_change(key):
st.session_state["menu"] = key
selected = option_menu(None, ["Home", 'Image'],
icons=['house', 'camera'], menu_icon="cast", key="menu_key", default_index=0, on_change=on_change)
init()
menu_dict = {
"Home" : {"fn": chatbot_main},
"Image" : {"fn": image_main},
}
if 'menu_key' in st.session_state and st.session_state["menu_key"]:
menu_dict[st.session_state["menu_key"]]["fn"]()
else:
chatbot_main()