ll7098ll commited on
Commit
a4863ca
·
verified ·
1 Parent(s): cd470ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -12
app.py CHANGED
@@ -9,9 +9,9 @@ st.set_page_config(page_title="MBTI 관계 시뮬레이터", page_icon="🤝", l
9
 
10
  # --- Configuration ---
11
 
12
- # Google Gemini API Key 설정 (환경 변수에서 가져오기)
13
  try:
14
- genai.configure(api_key=st.secrets["GEMINI_API_KEY"]) # Use Streamlit secrets
15
  except KeyError:
16
  st.error("GEMINI_API_KEY 환경 변수를 설정해주세요.")
17
  st.stop()
@@ -42,7 +42,8 @@ try:
42
  # {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
43
  # ]
44
  )
45
- st.info(f"Using model: {target_model_name}") # 어떤 모델 사용되는지 명시
 
46
  except Exception as e:
47
  st.error(f"Gemini 모델 '{target_model_name}' 로딩 중 오류 발생: {e}")
48
  st.error("모델 이름을 다시 확인하거나, 사용 가능한 모델 목록을 확인하여 다른 모델을 시도해보세요.")
@@ -176,14 +177,25 @@ colored_header(
176
  color_name="blue-70"
177
  )
178
 
179
- # 사이드바 설정
180
- with st.sidebar:
181
- st.header("⚙️ 설정")
 
 
 
 
 
 
 
 
 
182
 
 
 
183
  # 참여자 정보 입력 섹션
184
  st.subheader("👥 참여자 정보")
185
  num_people = st.number_input("참여자 수", min_value=2, max_value=5, value=2, key="num_people",
186
- help="최소 2명, 최대 5명까지 설정할 수 있습니다.")
187
 
188
  people = []
189
  # 참여자 수에 맞춰 동적으로 입력 필드 생성
@@ -192,10 +204,10 @@ with st.sidebar:
192
  with cols[i % len(cols)]: # 컬럼 순환 배치
193
  with st.expander(f"👤 참여자 {i+1}", expanded=True): # 기본적으로 펼쳐진 상태
194
  person = {}
195
- person['name'] = st.text_input(f"이름/닉네임", key=f"name_{i}", placeholder=f"예: 철수")
196
  # 성별 선택을 가로로 배치하여 공간 절약
197
- person['gender'] = st.radio("성별", ["남성", "여성", "기타"], key=f"gender_{i}", horizontal=True)
198
- person['type'] = st.selectbox(f"MBTI 유형", list(mbti_types.keys()), key=f"type_{i}", index=i % len(mbti_types)) # 기본값 분산
199
  # 이름과 유형이 입력되었는지 확인 (간단한 유효성 검사)
200
  if not person['name']:
201
  st.warning(f"참여자 {i+1}의 이름을 입력해주세요.")
@@ -211,10 +223,10 @@ with st.sidebar:
211
  relationship_options = relationship_types_two
212
  else:
213
  relationship_options = relationship_types_multiple
214
- relationship = st.selectbox("관계 유형", list(relationship_options.keys()), key="relationship")
215
 
216
  situation = st.text_area("구체적인 상황", key="situation", height=150,
217
- placeholder="예: 중요한 프로젝트 마감일을 앞두고 의견 충돌이 발생함 / 함께 여름 휴가 계획을 세우는 중 / 사소한 오해로 인해 서로 서먹해진 상태")
218
 
219
  st.divider()
220
 
 
9
 
10
  # --- Configuration ---
11
 
12
+ # Google Gemini API Key 설정 (Streamlit secrets 사용)
13
  try:
14
+ genai.configure(api_key=st.secrets["GEMINI_API_KEY"])
15
  except KeyError:
16
  st.error("GEMINI_API_KEY 환경 변수를 설정해주세요.")
17
  st.stop()
 
42
  # {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
43
  # ]
44
  )
45
+ # 모델 정보 표시 제거 (사용 요청)
46
+ # st.info(f"Using model: {target_model_name}")
47
  except Exception as e:
48
  st.error(f"Gemini 모델 '{target_model_name}' 로딩 중 오류 발생: {e}")
49
  st.error("모델 이름을 다시 확인하거나, 사용 가능한 모델 목록을 확인하여 다른 모델을 시도해보세요.")
 
177
  color_name="blue-70"
178
  )
179
 
180
+ # 넓은 사이드바 설정 (Streamlit 자체 최대 너비까지 확장)
181
+ st.markdown(
182
+ """
183
+ <style>
184
+ [data-testid="stSidebar"] {
185
+ width: 100% !important; /* Important to override default styles */
186
+ max-width: 100% !important; /* Important to override default styles */
187
+ }
188
+ </style>
189
+ """,
190
+ unsafe_allow_html=True,
191
+ )
192
 
193
+ # 사이드바 설정
194
+ with st.sidebar.expander("⚙️ 설정", expanded=True): # 사이드바를 기본적으로 확장
195
  # 참여자 정보 입력 섹션
196
  st.subheader("👥 참여자 정보")
197
  num_people = st.number_input("참여자 수", min_value=2, max_value=5, value=2, key="num_people",
198
+ help="최소 2명, 최대 5명까지 설정할 수 있습니다.", use_container_width=True) # use_container_width 추가
199
 
200
  people = []
201
  # 참여자 수에 맞춰 동적으로 입력 필드 생성
 
204
  with cols[i % len(cols)]: # 컬럼 순환 배치
205
  with st.expander(f"👤 참여자 {i+1}", expanded=True): # 기본적으로 펼쳐진 상태
206
  person = {}
207
+ person['name'] = st.text_input(f"이름/닉네임", key=f"name_{i}", placeholder=f"예: 철수", use_container_width=True) # use_container_width 추가
208
  # 성별 선택을 가로로 배치하여 공간 절약
209
+ person['gender'] = st.radio("성별", ["남성", "여성", "기타"], key=f"gender_{i}", horizontal=True, use_container_width=True) # use_container_width 추가
210
+ person['type'] = st.selectbox(f"MBTI 유형", list(mbti_types.keys()), key=f"type_{i}", index=i % len(mbti_types), use_container_width=True) # use_container_width 추가
211
  # 이름과 유형이 입력되었는지 확인 (간단한 유효성 검사)
212
  if not person['name']:
213
  st.warning(f"참여자 {i+1}의 이름을 입력해주세요.")
 
223
  relationship_options = relationship_types_two
224
  else:
225
  relationship_options = relationship_types_multiple
226
+ relationship = st.selectbox("관계 유형", list(relationship_options.keys()), key="relationship", use_container_width=True) # use_container_width 추가
227
 
228
  situation = st.text_area("구체적인 상황", key="situation", height=150,
229
+ placeholder="예: 중요한 프로젝트 마감일을 앞두고 의견 충돌이 발생함 / 함께 여름 휴가 계획을 세우는 중 / 사소한 오해로 인해 서로 서먹해진 상태", use_container_width=True) # use_container_width 추가
230
 
231
  st.divider()
232