Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
| 4 |
-
from translator_utils import process_rows, revert_rows, download_dataset, LOCAL_FILENAME
|
| 5 |
|
| 6 |
def load_data():
|
| 7 |
"""Load the dataset safely."""
|
|
@@ -97,11 +97,30 @@ def filter_history(date_input):
|
|
| 97 |
df = load_data()
|
| 98 |
return get_history_data(df, date_input)
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
with gr.Blocks(title="Auto AI News Translator") as app:
|
| 101 |
gr.Markdown("# Auto AI News Translator")
|
| 102 |
gr.Markdown("Translate news from Indonesian to English (with Chunking). Select rows to translate.")
|
| 103 |
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
status_output = gr.Textbox(label="Status", value="Ready", interactive=False)
|
| 106 |
|
| 107 |
with gr.Tabs():
|
|
@@ -119,7 +138,6 @@ with gr.Blocks(title="Auto AI News Translator") as app:
|
|
| 119 |
with gr.TabItem("History (Revert Supported)"):
|
| 120 |
gr.Markdown("Select rows to delete translation and move back to Pending.")
|
| 121 |
date_filter = gr.Textbox(label="Filter by Date (YYYY-MM-DD)")
|
| 122 |
-
# History now has checkbox
|
| 123 |
history_df_comp = gr.DataFrame(
|
| 124 |
value=get_history_data(load_data()),
|
| 125 |
label="Translation History",
|
|
@@ -144,4 +162,4 @@ with gr.Blocks(title="Auto AI News Translator") as app:
|
|
| 144 |
)
|
| 145 |
|
| 146 |
if __name__ == "__main__":
|
| 147 |
-
app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
| 4 |
+
from translator_utils import process_rows, revert_rows, download_dataset, LOCAL_FILENAME, ENV_HF_TOKEN
|
| 5 |
|
| 6 |
def load_data():
|
| 7 |
"""Load the dataset safely."""
|
|
|
|
| 97 |
df = load_data()
|
| 98 |
return get_history_data(df, date_input)
|
| 99 |
|
| 100 |
+
# CSS to ensure columns are readable
|
| 101 |
+
custom_css = """
|
| 102 |
+
/* Fix minimum width for content columns */
|
| 103 |
+
table td:nth-child(5), table td:nth-child(6), table td:nth-child(7), table td:nth-child(8) {
|
| 104 |
+
min-width: 300px !important;
|
| 105 |
+
white-space: pre-wrap !important;
|
| 106 |
+
}
|
| 107 |
+
/* Ensure row ID is small */
|
| 108 |
+
table td:nth-child(2) {
|
| 109 |
+
width: 50px !important;
|
| 110 |
+
}
|
| 111 |
+
"""
|
| 112 |
+
|
| 113 |
with gr.Blocks(title="Auto AI News Translator") as app:
|
| 114 |
gr.Markdown("# Auto AI News Translator")
|
| 115 |
gr.Markdown("Translate news from Indonesian to English (with Chunking). Select rows to translate.")
|
| 116 |
|
| 117 |
+
# Inject default value from Env Var
|
| 118 |
+
hf_token = gr.Textbox(
|
| 119 |
+
label="HF Token (Optional for Persistence)",
|
| 120 |
+
placeholder="hf_... (Leave empty if set in ENV)",
|
| 121 |
+
type="password",
|
| 122 |
+
value=ENV_HF_TOKEN
|
| 123 |
+
)
|
| 124 |
status_output = gr.Textbox(label="Status", value="Ready", interactive=False)
|
| 125 |
|
| 126 |
with gr.Tabs():
|
|
|
|
| 138 |
with gr.TabItem("History (Revert Supported)"):
|
| 139 |
gr.Markdown("Select rows to delete translation and move back to Pending.")
|
| 140 |
date_filter = gr.Textbox(label="Filter by Date (YYYY-MM-DD)")
|
|
|
|
| 141 |
history_df_comp = gr.DataFrame(
|
| 142 |
value=get_history_data(load_data()),
|
| 143 |
label="Translation History",
|
|
|
|
| 162 |
)
|
| 163 |
|
| 164 |
if __name__ == "__main__":
|
| 165 |
+
app.launch(css=custom_css)
|