Spaces:
Running
Running
Commit
·
4013483
1
Parent(s):
ac40eee
app: display analysis in progress while waiting
Browse files
app.py
CHANGED
|
@@ -19,6 +19,7 @@ def ask_stock_agent(agent_instance, ticker):
|
|
| 19 |
return 'Stock-Analysis Agent is not initialized. Please initialize first.'
|
| 20 |
ticker_exists = agent_instance.tickerfinder.does_ticker_exist(ticker)
|
| 21 |
if ticker_exists:
|
|
|
|
| 22 |
response = agent_instance.get_formatted_stock_summary(ticker)
|
| 23 |
else:
|
| 24 |
response = f"""
|
|
@@ -26,7 +27,7 @@ def ask_stock_agent(agent_instance, ticker):
|
|
| 26 |
see: https://www.sec.gov/files/company_tickers.json.
|
| 27 |
If you are not sure about the ticker symbol use the Ticker Finder to find the correct ticker.
|
| 28 |
"""
|
| 29 |
-
|
| 30 |
|
| 31 |
def plot_stock(agent_instance, ticker):
|
| 32 |
if agent_instance is None:
|
|
@@ -71,19 +72,19 @@ with gr.Blocks() as demo:
|
|
| 71 |
# Enter stock symbol
|
| 72 |
ticker = gr.Textbox(label="Enter a stock ticker symbol to be analyzed (GOOG, MSFT, etc.)")
|
| 73 |
analyze_button = gr.Button('Analyze Stock')
|
| 74 |
-
plot_output = gr.Plot(label=ticker, format="png")
|
| 75 |
-
analyze_button.click(
|
| 76 |
-
fn=plot_stock,
|
| 77 |
-
inputs=[agent_instance, ticker],
|
| 78 |
-
outputs=[plot_output],
|
| 79 |
-
api_name="plot_stock")
|
| 80 |
md_output = gr.Markdown(label="Output Box")
|
| 81 |
analyze_button.click(
|
| 82 |
fn=ask_stock_agent,
|
| 83 |
inputs=[agent_instance, ticker],
|
| 84 |
outputs=md_output,
|
| 85 |
api_name="ask_stock_agent")
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
if __name__ == "__main__":
|
| 89 |
demo.launch()
|
|
|
|
| 19 |
return 'Stock-Analysis Agent is not initialized. Please initialize first.'
|
| 20 |
ticker_exists = agent_instance.tickerfinder.does_ticker_exist(ticker)
|
| 21 |
if ticker_exists:
|
| 22 |
+
yield "Analysis in progress..."
|
| 23 |
response = agent_instance.get_formatted_stock_summary(ticker)
|
| 24 |
else:
|
| 25 |
response = f"""
|
|
|
|
| 27 |
see: https://www.sec.gov/files/company_tickers.json.
|
| 28 |
If you are not sure about the ticker symbol use the Ticker Finder to find the correct ticker.
|
| 29 |
"""
|
| 30 |
+
yield response
|
| 31 |
|
| 32 |
def plot_stock(agent_instance, ticker):
|
| 33 |
if agent_instance is None:
|
|
|
|
| 72 |
# Enter stock symbol
|
| 73 |
ticker = gr.Textbox(label="Enter a stock ticker symbol to be analyzed (GOOG, MSFT, etc.)")
|
| 74 |
analyze_button = gr.Button('Analyze Stock')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
md_output = gr.Markdown(label="Output Box")
|
| 76 |
analyze_button.click(
|
| 77 |
fn=ask_stock_agent,
|
| 78 |
inputs=[agent_instance, ticker],
|
| 79 |
outputs=md_output,
|
| 80 |
api_name="ask_stock_agent")
|
| 81 |
+
plot_output = gr.Plot(label=ticker, format="png")
|
| 82 |
+
analyze_button.click(
|
| 83 |
+
fn=plot_stock,
|
| 84 |
+
inputs=[agent_instance, ticker],
|
| 85 |
+
outputs=[plot_output],
|
| 86 |
+
api_name="plot_stock")
|
| 87 |
+
|
| 88 |
|
| 89 |
if __name__ == "__main__":
|
| 90 |
demo.launch()
|