bstraehle commited on
Commit
5574740
·
verified ·
1 Parent(s): 9a34b97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -57
app.py CHANGED
@@ -68,59 +68,6 @@ with gr.Blocks() as gaia:
68
  gr.Markdown("## General AI Assistant")
69
 
70
  gr.Markdown(os.environ.get("DESCRIPTION"))
71
-
72
- def inject_js():
73
- return None
74
-
75
- gaia.load(
76
- fn=inject_js,
77
- js="""
78
- () => {
79
- const STYLE_ID = 'auto-expand-style';
80
- if (!document.getElementById(STYLE_ID)) {
81
- const style = document.createElement('style');
82
- style.id = STYLE_ID;
83
- style.textContent = '.auto-expand textarea { overflow-y: hidden !important; resize: none !important; min-height: 48px !important; }';
84
- document.head.appendChild(style);
85
- }
86
-
87
- function resize(textarea) {
88
- if (!textarea) return;
89
- textarea.style.setProperty('height', '48px', 'important');
90
- const maxHeight = 10 * 24;
91
- const newHeight = Math.min(textarea.scrollHeight, maxHeight);
92
- textarea.style.setProperty('height', newHeight + 'px', 'important');
93
- if (textarea.scrollHeight > maxHeight) {
94
- textarea.style.setProperty('overflow-y', 'auto', 'important');
95
- } else {
96
- textarea.style.setProperty('overflow-y', 'hidden', 'important');
97
- }
98
- }
99
-
100
- function setupAutoExpand() {
101
- const wrappers = document.querySelectorAll('.auto-expand textarea');
102
- wrappers.forEach(textarea => {
103
- if (textarea.dataset.autoExpandSetup) return;
104
- textarea.dataset.autoExpandSetup = 'true';
105
-
106
- resize(textarea);
107
- textarea.addEventListener('input', () => resize(textarea));
108
- textarea.addEventListener('change', () => resize(textarea));
109
-
110
- const observer = new MutationObserver(() => resize(textarea));
111
- observer.observe(textarea, { attributes: true, childList: true, characterData: true, subtree: true });
112
- });
113
- }
114
-
115
- setupAutoExpand();
116
- const intervals = [100, 500, 1000, 2000];
117
- intervals.forEach(delay => setTimeout(setupAutoExpand, delay));
118
-
119
- const docObserver = new MutationObserver(setupAutoExpand);
120
- docObserver.observe(document.body, { childList: true, subtree: true });
121
- }
122
- """
123
- )
124
 
125
  with gr.Row():
126
  with gr.Column(scale=3):
@@ -128,8 +75,7 @@ with gr.Blocks() as gaia:
128
  question = gr.Textbox(
129
  label="Question *",
130
  placeholder=DEFAULT_QUESTION,
131
- interactive=True,
132
- elem_classes="auto-expand"
133
  )
134
  with gr.Row():
135
  ground_truth = gr.Textbox(
@@ -172,8 +118,7 @@ with gr.Blocks() as gaia:
172
  with gr.Column(scale=1):
173
  answer = gr.Textbox(
174
  label="Answer",
175
- interactive=False,
176
- elem_classes="auto-expand"
177
  )
178
 
179
  submit_btn.click(
 
68
  gr.Markdown("## General AI Assistant")
69
 
70
  gr.Markdown(os.environ.get("DESCRIPTION"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  with gr.Row():
73
  with gr.Column(scale=3):
 
75
  question = gr.Textbox(
76
  label="Question *",
77
  placeholder=DEFAULT_QUESTION,
78
+ interactive=True
 
79
  )
80
  with gr.Row():
81
  ground_truth = gr.Textbox(
 
118
  with gr.Column(scale=1):
119
  answer = gr.Textbox(
120
  label="Answer",
121
+ interactive=False
 
122
  )
123
 
124
  submit_btn.click(