Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -138,6 +138,9 @@ def ImageChat(image, chart_type, ticker, prompt="Analyze", analyze_more=None):
|
|
138 |
def populate_questions(chart_type):
|
139 |
return questions.get(chart_type, [])
|
140 |
|
|
|
|
|
|
|
141 |
app = gr.Interface(
|
142 |
fn=ImageChat,
|
143 |
inputs=[
|
@@ -152,9 +155,26 @@ app = gr.Interface(
|
|
152 |
theme=gr.themes.Soft()
|
153 |
)
|
154 |
|
155 |
-
#
|
156 |
-
|
157 |
-
|
158 |
-
return gr.Dropdown.update(choices=
|
159 |
-
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
def populate_questions(chart_type):
|
139 |
return questions.get(chart_type, [])
|
140 |
|
141 |
+
def update_analyze_more(chart_type):
|
142 |
+
return gr.Dropdown.update(choices=populate_questions(chart_type))
|
143 |
+
|
144 |
app = gr.Interface(
|
145 |
fn=ImageChat,
|
146 |
inputs=[
|
|
|
155 |
theme=gr.themes.Soft()
|
156 |
)
|
157 |
|
158 |
+
# Create a function to dynamically update the dropdown based on the selected chart type
|
159 |
+
def dynamic_analyze_more(chart_type):
|
160 |
+
questions_list = populate_questions(chart_type)
|
161 |
+
return gr.Dropdown.update(choices=questions_list)
|
162 |
+
|
163 |
+
# Create a new Gradio Block to handle interactions
|
164 |
+
with gr.Blocks() as demo:
|
165 |
+
chart_type = gr.Dropdown(label="Chart Type", choices=["Forex", "Crypto", "Stocks"], type="value", value="Stocks")
|
166 |
+
ticker = gr.Textbox(label="Ticker", placeholder="Enter ticker symbol")
|
167 |
+
prompt = gr.Textbox(label="Prompt", value="Analyze")
|
168 |
+
analyze_more = gr.Dropdown(label="Analyze more", choices=[], type="value", interactive=True)
|
169 |
+
image = gr.Image(label="Image")
|
170 |
+
response = gr.Textbox(label="Response")
|
171 |
+
|
172 |
+
chart_type.change(dynamic_analyze_more, inputs=chart_type, outputs=analyze_more)
|
173 |
+
|
174 |
+
gr.Interface(
|
175 |
+
fn=ImageChat,
|
176 |
+
inputs=[image, chart_type, ticker, prompt, analyze_more],
|
177 |
+
outputs=response
|
178 |
+
).launch()
|
179 |
+
|
180 |
+
demo.launch()
|