Update app.py
Browse files
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 |
-
|
| 474 |
-
gr.
|
| 475 |
-
|
| 476 |
-
|
| 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 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
"
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
with gr.
|
| 516 |
-
with gr.
|
| 517 |
-
gr.
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 530 |
|
| 531 |
-
|
| 532 |
-
|
|
|
|
| 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()
|