cutechicken commited on
Commit
917cf8a
·
verified ·
1 Parent(s): e7403d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -58
app.py CHANGED
@@ -470,63 +470,66 @@ def convert_to_dataframe(analyzed_articles):
470
 
471
  return df[["Sentiment", "Title", "Description", "Date", "Base Score", "Weight", "Total Score"]]
472
 
473
- with gr.Blocks() as iface:
474
- gr.Markdown("# Trading Asset Sentiment Analysis")
475
- gr.Markdown(
476
- "Enter the name of a trading asset, and I'll fetch recent articles and analyze their sentiment!"
477
- )
478
-
479
- with gr.Row():
480
- input_asset = gr.Textbox(
481
- label="Asset Name",
482
- lines=1,
483
- placeholder="Enter the name of the trading asset...",
484
  )
485
-
486
- with gr.Row():
487
- analyze_button = gr.Button("Analyze Sentiment", size="sm")
488
-
489
- gr.Examples(
490
- examples=[
491
- "Bitcoin",
492
- "Tesla",
493
- "Apple",
494
- "Amazon",
495
- ],
496
- inputs=input_asset,
497
- )
498
-
499
- # 주식 차트 영역 추가
500
- with gr.Row():
501
- with gr.Column():
502
- with gr.Blocks():
503
- gr.Markdown("## Stock Chart")
504
- with gr.Row():
505
- stock_chart = gr.Image(type="filepath", label="Stock Price Chart")
506
- ticker_info = gr.Textbox(label="Ticker Symbol")
507
-
508
- with gr.Row():
509
- with gr.Column():
510
- with gr.Blocks():
511
- gr.Markdown("## Sentiment Summary")
512
- sentiment_summary = gr.Image(type="filepath", label="Sentiment Analysis Summary")
513
-
514
- with gr.Row():
515
- with gr.Column():
516
- with gr.Blocks():
517
- gr.Markdown("## Articles and Sentiment Analysis")
518
- articles_output = gr.Dataframe(
519
- headers=["Sentiment", "Title", "Description", "Date", "Base Score", "Weight", "Total Score"],
520
- datatype=["markdown", "html", "markdown", "markdown", "number", "markdown", "markdown"],
521
- wrap=False,
522
- )
523
-
524
- # 분석 버튼 콜백 함수 연결
525
- analyze_button.click(
526
- analyze_asset_sentiment,
527
- inputs=[input_asset],
528
- outputs=[articles_output, sentiment_summary, stock_chart, ticker_info],
529
- )
 
 
 
 
 
 
 
 
 
530
 
531
- logging.info("Launching Gradio interface")
532
- iface.queue().launch()
 
470
 
471
  return df[["Sentiment", "Title", "Description", "Date", "Base Score", "Weight", "Total Score"]]
472
 
473
+ def main():
474
+ with gr.Blocks() as iface:
475
+ gr.Markdown("# Trading Asset Sentiment Analysis")
476
+ gr.Markdown(
477
+ "Enter the name of a trading asset, and I'll fetch recent articles and analyze their sentiment!"
 
 
 
 
 
 
478
  )
479
+
480
+ with gr.Row():
481
+ input_asset = gr.Textbox(
482
+ label="Asset Name",
483
+ lines=1,
484
+ placeholder="Enter the name of the trading asset...",
485
+ )
486
+
487
+ with gr.Row():
488
+ analyze_button = gr.Button("Analyze Sentiment", size="sm")
489
+
490
+ gr.Examples(
491
+ examples=[
492
+ "Bitcoin",
493
+ "Tesla",
494
+ "Apple",
495
+ "Amazon",
496
+ ],
497
+ inputs=input_asset,
498
+ )
499
+
500
+ # 주식 차트 영역 추가
501
+ with gr.Row():
502
+ with gr.Column():
503
+ with gr.Blocks():
504
+ gr.Markdown("## Stock Chart")
505
+ with gr.Row():
506
+ stock_chart = gr.Image(type="filepath", label="Stock Price Chart")
507
+ ticker_info = gr.Textbox(label="Ticker Symbol")
508
+
509
+ with gr.Row():
510
+ with gr.Column():
511
+ with gr.Blocks():
512
+ gr.Markdown("## Sentiment Summary")
513
+ sentiment_summary = gr.Image(type="filepath", label="Sentiment Analysis Summary")
514
+
515
+ with gr.Row():
516
+ with gr.Column():
517
+ with gr.Blocks():
518
+ gr.Markdown("## Articles and Sentiment Analysis")
519
+ articles_output = gr.Dataframe(
520
+ headers=["Sentiment", "Title", "Description", "Date", "Base Score", "Weight", "Total Score"],
521
+ datatype=["markdown", "html", "markdown", "markdown", "number", "markdown", "markdown"],
522
+ wrap=False,
523
+ )
524
+
525
+ analyze_button.click(
526
+ analyze_asset_sentiment,
527
+ inputs=[input_asset],
528
+ outputs=[articles_output, sentiment_summary, stock_chart, ticker_info],
529
+ )
530
+
531
+ logging.info("Launching Gradio interface")
532
+ iface.queue().launch()
533
 
534
+ if __name__ == "__main__":
535
+ main()