Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,6 +19,7 @@ import requests
|
|
| 19 |
import asyncio
|
| 20 |
import random
|
| 21 |
import pandas as pd
|
|
|
|
| 22 |
|
| 23 |
load_dotenv(verbose=True)
|
| 24 |
|
|
@@ -145,6 +146,7 @@ def summarize_text(long_text, username):
|
|
| 145 |
#conn.close()
|
| 146 |
return summary
|
| 147 |
|
|
|
|
| 148 |
def respond(ctype, msg, username):
|
| 149 |
conn = psycopg2.connect(
|
| 150 |
dbname="smair",
|
|
@@ -344,6 +346,7 @@ with gr.Blocks(title="Fund Manager Buddy", css="""footer {visibility: hidden;} #
|
|
| 344 |
summary_submit_btn = gr.Button("要約")
|
| 345 |
|
| 346 |
with gr.TabItem("ファンド投資家向け最新情報"):
|
|
|
|
| 347 |
report_input = gr.Textbox(label="投資家向けのアップデート情報を入力", lines=10, value='''
|
| 348 |
自分のプロフィル
|
| 349 |
山田 太郎
|
|
@@ -377,7 +380,7 @@ with gr.Blocks(title="Fund Manager Buddy", css="""footer {visibility: hidden;} #
|
|
| 377 |
|
| 378 |
運用資産総額 (AUM): 125.5 億ドル
|
| 379 |
ファンド設定日: 2025年1月1日''')
|
| 380 |
-
report_output = gr.
|
| 381 |
report_submit_btn = gr.Button("生成")
|
| 382 |
|
| 383 |
logout_btn = gr.Button("ログアウト")
|
|
@@ -484,7 +487,7 @@ with gr.Blocks(title="Fund Manager Buddy", css="""footer {visibility: hidden;} #
|
|
| 484 |
chat_history.append([msg, bot_message])
|
| 485 |
return chat_history, "" # Clear the input after sending
|
| 486 |
|
| 487 |
-
def generate_report(report_input):
|
| 488 |
if not report_input:
|
| 489 |
return "アップデートがありません。"
|
| 490 |
|
|
@@ -532,7 +535,13 @@ with gr.Blocks(title="Fund Manager Buddy", css="""footer {visibility: hidden;} #
|
|
| 532 |
contents=[prompt]
|
| 533 |
)
|
| 534 |
report_update = gresponse.text
|
| 535 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 536 |
|
| 537 |
dialog_submit_btn.click(
|
| 538 |
generate_response,
|
|
@@ -542,7 +551,7 @@ with gr.Blocks(title="Fund Manager Buddy", css="""footer {visibility: hidden;} #
|
|
| 542 |
|
| 543 |
report_submit_btn.click(
|
| 544 |
generate_report,
|
| 545 |
-
inputs=[report_input],
|
| 546 |
outputs=[report_output]
|
| 547 |
)
|
| 548 |
|
|
|
|
| 19 |
import asyncio
|
| 20 |
import random
|
| 21 |
import pandas as pd
|
| 22 |
+
from docx import Document
|
| 23 |
|
| 24 |
load_dotenv(verbose=True)
|
| 25 |
|
|
|
|
| 146 |
#conn.close()
|
| 147 |
return summary
|
| 148 |
|
| 149 |
+
|
| 150 |
def respond(ctype, msg, username):
|
| 151 |
conn = psycopg2.connect(
|
| 152 |
dbname="smair",
|
|
|
|
| 346 |
summary_submit_btn = gr.Button("要約")
|
| 347 |
|
| 348 |
with gr.TabItem("ファンド投資家向け最新情報"):
|
| 349 |
+
report_file = gr.Textbox(label="ファイル名")
|
| 350 |
report_input = gr.Textbox(label="投資家向けのアップデート情報を入力", lines=10, value='''
|
| 351 |
自分のプロフィル
|
| 352 |
山田 太郎
|
|
|
|
| 380 |
|
| 381 |
運用資産総額 (AUM): 125.5 億ドル
|
| 382 |
ファンド設定日: 2025年1月1日''')
|
| 383 |
+
report_output = gr.File(label="ダウンロード")
|
| 384 |
report_submit_btn = gr.Button("生成")
|
| 385 |
|
| 386 |
logout_btn = gr.Button("ログアウト")
|
|
|
|
| 487 |
chat_history.append([msg, bot_message])
|
| 488 |
return chat_history, "" # Clear the input after sending
|
| 489 |
|
| 490 |
+
def generate_report(report_file, report_input):
|
| 491 |
if not report_input:
|
| 492 |
return "アップデートがありません。"
|
| 493 |
|
|
|
|
| 535 |
contents=[prompt]
|
| 536 |
)
|
| 537 |
report_update = gresponse.text
|
| 538 |
+
|
| 539 |
+
doc = Document()
|
| 540 |
+
doc.add_paragraph(report_update)
|
| 541 |
+
file_path = report_file
|
| 542 |
+
doc.save(file_path)
|
| 543 |
+
return file_path
|
| 544 |
+
#return report_update
|
| 545 |
|
| 546 |
dialog_submit_btn.click(
|
| 547 |
generate_response,
|
|
|
|
| 551 |
|
| 552 |
report_submit_btn.click(
|
| 553 |
generate_report,
|
| 554 |
+
inputs=[report_file, report_input],
|
| 555 |
outputs=[report_output]
|
| 556 |
)
|
| 557 |
|