Upload app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from sqlalchemy import true
|
|
| 9 |
# # 加载.env文件中的环境变量
|
| 10 |
# load_dotenv()
|
| 11 |
# from EasyFinancialAgent.chat import query_company
|
| 12 |
-
from EasyFinancialAgent.chat_direct import advanced_search_company_detailed, search_and_format, search_company_direct, chatbot_response
|
| 13 |
from chatbot.chat_main import respond
|
| 14 |
import globals as g
|
| 15 |
from service.mysql_service import get_companys, insert_company, get_company_by_name
|
|
@@ -201,14 +201,23 @@ label.selected {
|
|
| 201 |
|
| 202 |
/* ChatInterface标题样式 */
|
| 203 |
.chatbot > .wrap > .head {
|
| 204 |
-
height:
|
| 205 |
display: flex !important;
|
| 206 |
align-items: center !important;
|
| 207 |
-
padding:
|
| 208 |
border-bottom: 1px solid #e5e7eb !important;
|
| 209 |
background: #f9fafb !important;
|
| 210 |
}
|
| 211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
/* Tabs标签栏样式 */
|
| 213 |
.tab-container {
|
| 214 |
height: 48px !important;
|
|
@@ -217,6 +226,11 @@ label.selected {
|
|
| 217 |
border-bottom: 1px solid #e5e7eb !important;
|
| 218 |
background: #f9fafb !important;
|
| 219 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
"""
|
| 221 |
|
| 222 |
# 全局变量用于存储公司映射关系
|
|
@@ -431,17 +445,15 @@ def update_company_choices(user_input: str):
|
|
| 431 |
), gr.update(visible=False, value="") # 添加第二个返回值
|
| 432 |
|
| 433 |
# 第二次:执行耗时操作(调用 LLM)
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
#
|
| 437 |
-
|
| 438 |
-
# print(f"参数:{user_input}---新接口2---查到的公司: {choices}")
|
| 439 |
-
# choices = search_company(user_input) # 这是你原来的同步函数
|
| 440 |
|
| 441 |
# 检查choices是否为错误信息
|
| 442 |
-
if len(choices)
|
| 443 |
# 如果是错误信息或非正常格式,显示提示消息
|
| 444 |
-
error_message =
|
| 445 |
# 使用Ant Design风格的错误提示
|
| 446 |
error_html = f'''
|
| 447 |
<div class="ant-message ant-message-error" style="
|
|
@@ -1737,9 +1749,6 @@ def main():
|
|
| 1737 |
# 主内容区域
|
| 1738 |
with gr.Column(scale=9):
|
| 1739 |
|
| 1740 |
-
# 指标仪表板
|
| 1741 |
-
create_metrics_dashboard()
|
| 1742 |
-
|
| 1743 |
with gr.Row(elem_classes=["main-content-box"]):
|
| 1744 |
with gr.Column(scale=8):
|
| 1745 |
# Tab内容
|
|
@@ -1876,6 +1885,9 @@ def main():
|
|
| 1876 |
),
|
| 1877 |
submit_btn="📤 Send" # ✅ 添加发送按钮
|
| 1878 |
)
|
|
|
|
|
|
|
|
|
|
| 1879 |
|
| 1880 |
# 在页面加载时设置默认选中的公司并加载数据
|
| 1881 |
def load_default_company():
|
|
|
|
| 9 |
# # 加载.env文件中的环境变量
|
| 10 |
# load_dotenv()
|
| 11 |
# from EasyFinancialAgent.chat import query_company
|
| 12 |
+
from EasyFinancialAgent.chat_direct import advanced_search_company_detailed, search_and_format, search_company_direct, chatbot_response, format_search_result_for_display
|
| 13 |
from chatbot.chat_main import respond
|
| 14 |
import globals as g
|
| 15 |
from service.mysql_service import get_companys, insert_company, get_company_by_name
|
|
|
|
| 201 |
|
| 202 |
/* ChatInterface标题样式 */
|
| 203 |
.chatbot > .wrap > .head {
|
| 204 |
+
height: 40px !important;
|
| 205 |
display: flex !important;
|
| 206 |
align-items: center !important;
|
| 207 |
+
padding: 8px 16px !important;
|
| 208 |
border-bottom: 1px solid #e5e7eb !important;
|
| 209 |
background: #f9fafb !important;
|
| 210 |
}
|
| 211 |
|
| 212 |
+
/* ✅ 缩小Easy Financial AI Assistant标题 */
|
| 213 |
+
.chatbot > .wrap > .head h1,
|
| 214 |
+
.chatbot > .wrap > .head h2,
|
| 215 |
+
.chatbot > .wrap > .head h3 {
|
| 216 |
+
font-size: 14px !important;
|
| 217 |
+
margin: 0 !important;
|
| 218 |
+
font-weight: 600 !important;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
/* Tabs标签栏样式 */
|
| 222 |
.tab-container {
|
| 223 |
height: 48px !important;
|
|
|
|
| 226 |
border-bottom: 1px solid #e5e7eb !important;
|
| 227 |
background: #f9fafb !important;
|
| 228 |
}
|
| 229 |
+
|
| 230 |
+
/* ✅ 移除Tabs底部横线 */
|
| 231 |
+
.tabs {
|
| 232 |
+
border-bottom: none !important;
|
| 233 |
+
}
|
| 234 |
"""
|
| 235 |
|
| 236 |
# 全局变量用于存储公司映射关系
|
|
|
|
| 445 |
), gr.update(visible=False, value="") # 添加第二个返回值
|
| 446 |
|
| 447 |
# 第二次:执行耗时操作(调用 LLM)
|
| 448 |
+
search_result = advanced_search_company_detailed(user_input)
|
| 449 |
+
|
| 450 |
+
# ✅ 使用新的显示格式:"公司名 (Ticker)"
|
| 451 |
+
choices = format_search_result_for_display(search_result)
|
|
|
|
|
|
|
| 452 |
|
| 453 |
# 检查choices是否为错误信息
|
| 454 |
+
if len(choices) == 0:
|
| 455 |
# 如果是错误信息或非正常格式,显示提示消息
|
| 456 |
+
error_message = "未找到匹配的公司"
|
| 457 |
# 使用Ant Design风格的错误提示
|
| 458 |
error_html = f'''
|
| 459 |
<div class="ant-message ant-message-error" style="
|
|
|
|
| 1749 |
# 主内容区域
|
| 1750 |
with gr.Column(scale=9):
|
| 1751 |
|
|
|
|
|
|
|
|
|
|
| 1752 |
with gr.Row(elem_classes=["main-content-box"]):
|
| 1753 |
with gr.Column(scale=8):
|
| 1754 |
# Tab内容
|
|
|
|
| 1885 |
),
|
| 1886 |
submit_btn="📤 Send" # ✅ 添加发送按钮
|
| 1887 |
)
|
| 1888 |
+
|
| 1889 |
+
# ✅ 将指标仪表板移到ChatInterface下方
|
| 1890 |
+
create_metrics_dashboard()
|
| 1891 |
|
| 1892 |
# 在页面加载时设置默认选中的公司并加载数据
|
| 1893 |
def load_default_company():
|