Update app.py
Browse files
app.py
CHANGED
@@ -93,14 +93,20 @@ def find_paper_in_sheet(paper_id):
|
|
93 |
# 該当する行がない場合はNoneを返す
|
94 |
return None
|
95 |
|
96 |
-
def gradio_interface(
|
97 |
# 「Today」ボタンが押されたかどうかをチェック
|
98 |
if today_pressed:
|
99 |
# 「Today」ボタンが押された場合、現在の日付を使用
|
100 |
paper_links = fetch_paper_links("https://huggingface.co/papers")
|
101 |
else:
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
url = f"https://huggingface.co/papers?date={date}"
|
105 |
paper_links = fetch_paper_links(url)
|
106 |
|
@@ -124,8 +130,10 @@ def gradio_interface(selected_date, today_pressed):
|
|
124 |
summaries_markdown = "\n---\n".join(summaries) # 要約を水平線で区切る
|
125 |
return summaries_markdown
|
126 |
|
127 |
-
|
128 |
-
|
|
|
|
|
129 |
|
130 |
iface = gr.Interface(
|
131 |
fn=gradio_interface,
|
|
|
93 |
# 該当する行がない場合はNoneを返す
|
94 |
return None
|
95 |
|
96 |
+
def gradio_interface(selected_date_str, today_pressed):
|
97 |
# 「Today」ボタンが押されたかどうかをチェック
|
98 |
if today_pressed:
|
99 |
# 「Today」ボタンが押された場合、現在の日付を使用
|
100 |
paper_links = fetch_paper_links("https://huggingface.co/papers")
|
101 |
else:
|
102 |
+
try:
|
103 |
+
# 日付文字列を検証します。
|
104 |
+
datetime.strptime(selected_date_str, "%Y-%m-%d")
|
105 |
+
date = selected_date_str
|
106 |
+
except ValueError:
|
107 |
+
# 日付形式が無効な場合、エラーメッセージを返します。
|
108 |
+
return "入力された日付が無効です。YYYY-MM-DD形式で入力してください。"
|
109 |
+
|
110 |
url = f"https://huggingface.co/papers?date={date}"
|
111 |
paper_links = fetch_paper_links(url)
|
112 |
|
|
|
130 |
summaries_markdown = "\n---\n".join(summaries) # 要約を水平線で区切る
|
131 |
return summaries_markdown
|
132 |
|
133 |
+
inputs = [
|
134 |
+
gr.Text(label="日付をYYYY-MM-DD形式で入力", placeholder="例: 2024-03-28"),
|
135 |
+
gr.Button("Today")
|
136 |
+
]
|
137 |
|
138 |
iface = gr.Interface(
|
139 |
fn=gradio_interface,
|