Spaces:
Sleeping
Sleeping
fileのstateを確認するように変更
Browse files
app.py
CHANGED
@@ -143,30 +143,33 @@ def gemini(api_key, input_file, meeting_name, members, point, keyword, model, ta
|
|
143 |
raise gr.Error("No api_key submitted!")
|
144 |
if input_file is None:
|
145 |
raise gr.Error("No input_file submitted! Please upload or record an file before submitting your request.")
|
146 |
-
|
147 |
# 音声 or 動画
|
148 |
if task == "audio":
|
149 |
system_prompt = audio_system_prompt(meeting_name, members, point, keyword)
|
150 |
-
|
151 |
-
# 処理の実行
|
152 |
-
chat_session = model_settings(api_key, system_prompt, model)
|
153 |
-
logging.warning(f"input file: {input_file}")
|
154 |
-
upload_file = genai.upload_file(input_file)
|
155 |
-
logging.warning(f"upload file: {upload_file}")
|
156 |
-
time.sleep(15)
|
157 |
-
|
158 |
else:
|
159 |
-
|
160 |
system_prompt = video_system_prompt(meeting_name, members, point, keyword)
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
response = chat_session.send_message([upload_file])
|
171 |
|
172 |
upload_file.delete()
|
@@ -183,7 +186,7 @@ audio = gr.Interface(
|
|
183 |
gr.TextArea(label="参加者: 1名ずつ改行して入力", show_label=True, placeholder="不明"),
|
184 |
gr.Textbox(label="抽出事項: 概要、何が議論されたのか、会議の結論、アクションアイテム以外に抽出したいこと", show_label=True),
|
185 |
gr.Textbox(label="固有名詞: 企業名など", show_label=True),
|
186 |
-
gr.Radio(["gemini-1.5-flash-latest", "gemini-1.5-pro-latest"], label="使用モデル", show_label=True, value="gemini-1.5-
|
187 |
gr.Textbox(value="audio", visible=False),
|
188 |
],
|
189 |
outputs=[gr.Chatbot(show_copy_button=True, render_markdown=True, height=1000, value=[[None, demo_markdown]])],
|
|
|
143 |
raise gr.Error("No api_key submitted!")
|
144 |
if input_file is None:
|
145 |
raise gr.Error("No input_file submitted! Please upload or record an file before submitting your request.")
|
146 |
+
|
147 |
# 音声 or 動画
|
148 |
if task == "audio":
|
149 |
system_prompt = audio_system_prompt(meeting_name, members, point, keyword)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
else:
|
|
|
151 |
system_prompt = video_system_prompt(meeting_name, members, point, keyword)
|
152 |
+
|
153 |
+
|
154 |
+
# 処理の実行
|
155 |
+
chat_session = model_settings(api_key, system_prompt, model)
|
156 |
+
logging.warning(f"input file: {input_file}")
|
157 |
+
upload_file = genai.upload_file(input_file)
|
158 |
+
logging.warning(f"upload file: {upload_file}")
|
159 |
+
|
160 |
+
|
161 |
+
# 処理の実行
|
162 |
+
# APIがファイルを受信したことを確認
|
163 |
+
while upload_file.state.name == "PROCESSING":
|
164 |
+
print('Waiting for processed.')
|
165 |
+
time.sleep(10)
|
166 |
+
upload_file = genai.get_file(upload_file.name)
|
167 |
+
|
168 |
+
if upload_file.state.name == "FAILED":
|
169 |
+
raise ValueError(upload_file.state.name)
|
170 |
+
print("upload processing complete:", upload_file.uri)
|
171 |
+
chat_session = model_settings(api_key, system_prompt, model)
|
172 |
+
|
173 |
response = chat_session.send_message([upload_file])
|
174 |
|
175 |
upload_file.delete()
|
|
|
186 |
gr.TextArea(label="参加者: 1名ずつ改行して入力", show_label=True, placeholder="不明"),
|
187 |
gr.Textbox(label="抽出事項: 概要、何が議論されたのか、会議の結論、アクションアイテム以外に抽出したいこと", show_label=True),
|
188 |
gr.Textbox(label="固有名詞: 企業名など", show_label=True),
|
189 |
+
gr.Radio(["gemini-1.5-flash-latest", "gemini-1.5-pro-latest"], label="使用モデル", show_label=True, value="gemini-1.5-pro-latest"),
|
190 |
gr.Textbox(value="audio", visible=False),
|
191 |
],
|
192 |
outputs=[gr.Chatbot(show_copy_button=True, render_markdown=True, height=1000, value=[[None, demo_markdown]])],
|