Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -909,17 +909,36 @@ footer {
|
|
| 909 |
}
|
| 910 |
"""
|
| 911 |
|
| 912 |
-
# --- Gradio Interface ---
|
| 913 |
with gr.Blocks(css=css, title="NewsAI Service") as iface:
|
|
|
|
| 914 |
init_db()
|
| 915 |
|
| 916 |
with gr.Tabs():
|
| 917 |
-
with gr.Tab("
|
| 918 |
-
|
| 919 |
gr.Markdown(
|
| 920 |
-
"
|
| 921 |
-
|
| 922 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 923 |
)
|
| 924 |
|
| 925 |
# User custom search section
|
|
@@ -939,7 +958,11 @@ with gr.Blocks(css=css, title="NewsAI Service") as iface:
|
|
| 939 |
label="Select Country"
|
| 940 |
)
|
| 941 |
with gr.Column():
|
| 942 |
-
custom_search_btn = gr.Button(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 943 |
|
| 944 |
custom_search_output = gr.Markdown()
|
| 945 |
|
|
@@ -951,7 +974,11 @@ with gr.Blocks(css=css, title="NewsAI Service") as iface:
|
|
| 951 |
|
| 952 |
# Button to generate a full report
|
| 953 |
with gr.Row():
|
| 954 |
-
full_report_btn = gr.Button(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 955 |
full_report_display = gr.Markdown()
|
| 956 |
|
| 957 |
full_report_btn.click(
|
|
@@ -969,8 +996,16 @@ with gr.Blocks(css=css, title="NewsAI Service") as iface:
|
|
| 969 |
with gr.Group():
|
| 970 |
gr.Markdown(f"### {company}")
|
| 971 |
with gr.Row():
|
| 972 |
-
search_btn = gr.Button(
|
| 973 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 974 |
result_display = gr.Markdown()
|
| 975 |
|
| 976 |
search_btn.click(
|
|
@@ -989,8 +1024,16 @@ with gr.Blocks(css=css, title="NewsAI Service") as iface:
|
|
| 989 |
with gr.Group():
|
| 990 |
gr.Markdown(f"### {company}")
|
| 991 |
with gr.Row():
|
| 992 |
-
search_btn = gr.Button(
|
| 993 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 994 |
result_display = gr.Markdown()
|
| 995 |
|
| 996 |
search_btn.click(
|
|
@@ -1002,10 +1045,11 @@ with gr.Blocks(css=css, title="NewsAI Service") as iface:
|
|
| 1002 |
outputs=result_display
|
| 1003 |
)
|
| 1004 |
|
| 1005 |
-
|
| 1006 |
-
|
| 1007 |
-
|
| 1008 |
-
|
| 1009 |
-
|
| 1010 |
-
|
| 1011 |
-
|
|
|
|
|
|
| 909 |
}
|
| 910 |
"""
|
| 911 |
|
| 912 |
+
# --- Gradio Interface (UI portion only) ---
|
| 913 |
with gr.Blocks(css=css, title="NewsAI Service") as iface:
|
| 914 |
+
# Initialize the database first (keeping the call to init_db(), unchanged)
|
| 915 |
init_db()
|
| 916 |
|
| 917 |
with gr.Tabs():
|
| 918 |
+
with gr.Tab("MoneyRadar"):
|
| 919 |
+
# Added usage instructions and feature explanations here:
|
| 920 |
gr.Markdown(
|
| 921 |
+
"""
|
| 922 |
+
## MoneyRadar: Implies scanning the market to spot money-making opportunities.
|
| 923 |
+
|
| 924 |
+
**How to Use This Service**:
|
| 925 |
+
1. **Custom Search**: Enter any keyword and choose a target country to fetch the latest news. The system automatically performs sentiment analysis and stores results in the database.
|
| 926 |
+
2. **Generate Full Analysis Summary Report**: This will automatically:
|
| 927 |
+
- Search all predefined companies (in parallel),
|
| 928 |
+
- Store the articles and sentiment analysis,
|
| 929 |
+
- Display a combined overall report.
|
| 930 |
+
3. **Individual Companies**:
|
| 931 |
+
- **Search**: Fetch and analyze the latest news from Google (for the chosen company).
|
| 932 |
+
- **Load from DB**: Retrieve the most recent saved news and sentiment analysis from the local database.
|
| 933 |
+
|
| 934 |
+
**Features**:
|
| 935 |
+
- **Real-time News Scraping**: Retrieves fresh articles from multiple regions.
|
| 936 |
+
- **Advanced Sentiment Analysis**: Uses state-of-the-art NLP models via the OpenAI API.
|
| 937 |
+
- **Data Persistence**: Automatically saves and retrieves search results in a local SQLite database for quick reference.
|
| 938 |
+
- **Flexible**: Ability to search any keyword/country or select from predefined Big Tech & finance-related terms.
|
| 939 |
+
|
| 940 |
+
---
|
| 941 |
+
"""
|
| 942 |
)
|
| 943 |
|
| 944 |
# User custom search section
|
|
|
|
| 958 |
label="Select Country"
|
| 959 |
)
|
| 960 |
with gr.Column():
|
| 961 |
+
custom_search_btn = gr.Button(
|
| 962 |
+
"Search",
|
| 963 |
+
variant="primary",
|
| 964 |
+
elem_classes="primary-btn"
|
| 965 |
+
)
|
| 966 |
|
| 967 |
custom_search_output = gr.Markdown()
|
| 968 |
|
|
|
|
| 974 |
|
| 975 |
# Button to generate a full report
|
| 976 |
with gr.Row():
|
| 977 |
+
full_report_btn = gr.Button(
|
| 978 |
+
"Generate Full Analysis Summary Report",
|
| 979 |
+
variant="primary",
|
| 980 |
+
elem_classes="primary-btn"
|
| 981 |
+
)
|
| 982 |
full_report_display = gr.Markdown()
|
| 983 |
|
| 984 |
full_report_btn.click(
|
|
|
|
| 996 |
with gr.Group():
|
| 997 |
gr.Markdown(f"### {company}")
|
| 998 |
with gr.Row():
|
| 999 |
+
search_btn = gr.Button(
|
| 1000 |
+
"Search",
|
| 1001 |
+
variant="primary",
|
| 1002 |
+
elem_classes="primary-btn"
|
| 1003 |
+
)
|
| 1004 |
+
load_btn = gr.Button(
|
| 1005 |
+
"Load from DB",
|
| 1006 |
+
variant="secondary",
|
| 1007 |
+
elem_classes="secondary-btn"
|
| 1008 |
+
)
|
| 1009 |
result_display = gr.Markdown()
|
| 1010 |
|
| 1011 |
search_btn.click(
|
|
|
|
| 1024 |
with gr.Group():
|
| 1025 |
gr.Markdown(f"### {company}")
|
| 1026 |
with gr.Row():
|
| 1027 |
+
search_btn = gr.Button(
|
| 1028 |
+
"Search",
|
| 1029 |
+
variant="primary",
|
| 1030 |
+
elem_classes="primary-btn"
|
| 1031 |
+
)
|
| 1032 |
+
load_btn = gr.Button(
|
| 1033 |
+
"Load from DB",
|
| 1034 |
+
variant="secondary",
|
| 1035 |
+
elem_classes="secondary-btn"
|
| 1036 |
+
)
|
| 1037 |
result_display = gr.Markdown()
|
| 1038 |
|
| 1039 |
search_btn.click(
|
|
|
|
| 1045 |
outputs=result_display
|
| 1046 |
)
|
| 1047 |
|
| 1048 |
+
# Launch the Gradio interface
|
| 1049 |
+
iface.launch(
|
| 1050 |
+
server_name="0.0.0.0",
|
| 1051 |
+
server_port=7860,
|
| 1052 |
+
share=True,
|
| 1053 |
+
ssl_verify=False,
|
| 1054 |
+
show_error=True
|
| 1055 |
+
)
|