Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,8 @@ import gradio as gr
|
|
8 |
import gspread
|
9 |
from oauth2client.service_account import ServiceAccountCredentials
|
10 |
import json
|
|
|
|
|
11 |
|
12 |
def connect_gspread(spread_sheet_key):
|
13 |
"""Google スプレッドシートに接続。"""
|
@@ -92,7 +94,16 @@ def find_paper_in_sheet(paper_id):
|
|
92 |
return None
|
93 |
|
94 |
def gradio_interface():
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
paper_ids = set(link.split('/')[-1] for link in paper_links)
|
97 |
|
98 |
total_tokens_used = 0
|
@@ -113,9 +124,12 @@ def gradio_interface():
|
|
113 |
summaries_markdown = "\n---\n".join(summaries) # 要約を水平線で区切る
|
114 |
return summaries_markdown
|
115 |
|
|
|
|
|
|
|
116 |
iface = gr.Interface(
|
117 |
fn=gradio_interface,
|
118 |
-
inputs=
|
119 |
outputs=gr.Markdown(),
|
120 |
title="Dairy Papers 日本語要約ツール",
|
121 |
description="[Daily Papers](https://huggingface.co/papers)に掲載された論文を日本語で要約します。"
|
|
|
8 |
import gspread
|
9 |
from oauth2client.service_account import ServiceAccountCredentials
|
10 |
import json
|
11 |
+
from datetime import datetime
|
12 |
+
|
13 |
|
14 |
def connect_gspread(spread_sheet_key):
|
15 |
"""Google スプレッドシートに接続。"""
|
|
|
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 |
+
date = selected_date.strftime("%Y-%m-%d")
|
104 |
+
url = f"https://huggingface.co/papers?date={date}"
|
105 |
+
paper_links = fetch_paper_links(url)
|
106 |
+
|
107 |
paper_ids = set(link.split('/')[-1] for link in paper_links)
|
108 |
|
109 |
total_tokens_used = 0
|
|
|
124 |
summaries_markdown = "\n---\n".join(summaries) # 要約を水平線で区切る
|
125 |
return summaries_markdown
|
126 |
|
127 |
+
# 日付選択器と「Today」ボタンを入力として設定
|
128 |
+
inputs = [gr.Date(label="日付を選択"), gr.Button("Today")]
|
129 |
+
|
130 |
iface = gr.Interface(
|
131 |
fn=gradio_interface,
|
132 |
+
inputs=inputs,
|
133 |
outputs=gr.Markdown(),
|
134 |
title="Dairy Papers 日本語要約ツール",
|
135 |
description="[Daily Papers](https://huggingface.co/papers)に掲載された論文を日本語で要約します。"
|