heysho commited on
Commit
d2ecd91
1 Parent(s): 042fa9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -20,14 +20,7 @@ PROMPT = """
20
  4. その日の計画: {plan}.
21
  5. 日本語で100語以内で説明してください。
22
  """
23
- html_code = """
24
- <script>
25
- window.addEventListener('message', (_ev) => {
26
- const elmIframe = document.querySelector('#parentframe');
27
- elmIframe.style.height = _ev.data + 'px';
28
- });
29
- </script>
30
- """
31
 
32
  def init_page():
33
  st.set_page_config(
@@ -57,7 +50,16 @@ def init_chain():
57
  output_parser = StrOutputParser()
58
  chain = prompt | llm | output_parser
59
  return chain
60
-
 
 
 
 
 
 
 
 
 
61
 
62
 
63
  def main():
@@ -66,7 +68,7 @@ def main():
66
  st.markdown("""<style>.st-emotion-cache-15ecox0 { display: none !important; }
67
  @media (max-width: 50.5rem) {.st-emotion-cache-13ln4jf {max-width: calc(0rem + 100vw);}}
68
  </style>""",unsafe_allow_html=True,)
69
- components.html(html_code, height=0)
70
  chain = init_chain()
71
  if chain:
72
  feeling = st.selectbox(
 
20
  4. その日の計画: {plan}.
21
  5. 日本語で100語以内で説明してください。
22
  """
23
+
 
 
 
 
 
 
 
24
 
25
  def init_page():
26
  st.set_page_config(
 
50
  output_parser = StrOutputParser()
51
  chain = prompt | llm | output_parser
52
  return chain
53
+
54
+ def send_height():
55
+ st.components.v1.html("""
56
+ <script>
57
+ window.onload = () => {
58
+ const height = document.body.scrollHeight;
59
+ window.parent.postMessage({ type: 'resize', height: height }, '*');
60
+ };
61
+ </script>
62
+ """, height=0)
63
 
64
 
65
  def main():
 
68
  st.markdown("""<style>.st-emotion-cache-15ecox0 { display: none !important; }
69
  @media (max-width: 50.5rem) {.st-emotion-cache-13ln4jf {max-width: calc(0rem + 100vw);}}
70
  </style>""",unsafe_allow_html=True,)
71
+ send_height()
72
  chain = init_chain()
73
  if chain:
74
  feeling = st.selectbox(