This commit is contained in:
4
frontend/requirements.txt
Normal file
4
frontend/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
# Frontend - Lightweight dependencies only
|
||||
streamlit==1.39.0
|
||||
requests==2.32.3
|
||||
python-dotenv==1.2.2
|
||||
@@ -3,7 +3,7 @@ AI Agent 前端模块
|
||||
采用分层架构设计,包含配置、状态、API客户端和UI组件
|
||||
"""
|
||||
|
||||
from frontend.logger import debug, info, warning, error
|
||||
from .logger import debug, info, warning, error
|
||||
|
||||
__version__ = "2.0.0"
|
||||
__all__ = ["debug", "info", "warning", "error"]
|
||||
@@ -7,9 +7,9 @@ import json
|
||||
from typing import List, Dict, Any, Generator
|
||||
import requests
|
||||
|
||||
# 使用绝对导入
|
||||
from frontend.config import config
|
||||
from frontend.logger import error, warning
|
||||
# 使用相对导入
|
||||
from .config import config
|
||||
from .logger import error, warning
|
||||
|
||||
|
||||
class APIClient:
|
||||
@@ -6,10 +6,10 @@
|
||||
import re
|
||||
import streamlit as st
|
||||
|
||||
# 使用绝对导入
|
||||
from frontend.state import AppState
|
||||
from frontend.api_client import api_client
|
||||
from frontend.config import config
|
||||
# 使用相对导入
|
||||
from ..state import AppState
|
||||
from ..api_client import api_client
|
||||
from ..config import config
|
||||
|
||||
|
||||
def render_chat_area():
|
||||
@@ -325,7 +325,7 @@ def _handle_ai_response():
|
||||
|
||||
# 消息发送完毕后,静默刷新历史记录列表
|
||||
# (因为可能生成了新对话,或者旧对话摘要已更新)
|
||||
from frontend.components.sidebar import _refresh_threads
|
||||
from .sidebar import _refresh_threads
|
||||
_refresh_threads()
|
||||
|
||||
# 强制重绘页面,使侧边栏立即显示最新记录
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
import streamlit as st
|
||||
|
||||
# 使用绝对导入
|
||||
from frontend.state import AppState
|
||||
# 使用相对导入
|
||||
from ..state import AppState
|
||||
|
||||
|
||||
def render_info_panel():
|
||||
@@ -6,9 +6,9 @@
|
||||
import streamlit as st
|
||||
from datetime import datetime
|
||||
|
||||
# 使用绝对导入
|
||||
from frontend.state import AppState
|
||||
from frontend.api_client import api_client
|
||||
# 使用相对导入
|
||||
from ..state import AppState
|
||||
from ..api_client import api_client
|
||||
|
||||
def render_sidebar():
|
||||
"""渲染左侧栏"""
|
||||
@@ -7,16 +7,17 @@ import sys
|
||||
import os
|
||||
|
||||
# 添加项目根目录到 Python 路径,支持绝对导入
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
# 现在的结构: frontend/src/frontend_main.py,所以要获取 frontend/ 目录作为根
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
import streamlit as st
|
||||
|
||||
# 使用绝对导入
|
||||
from frontend.config import config
|
||||
from frontend.state import AppState
|
||||
from frontend.components.sidebar import render_sidebar
|
||||
from frontend.components.chat_area import render_chat_area
|
||||
from frontend.components.info_panel import render_info_panel
|
||||
# 使用相对导入
|
||||
from .config import config
|
||||
from .state import AppState
|
||||
from .components.sidebar import render_sidebar
|
||||
from .components.chat_area import render_chat_area
|
||||
from .components.info_panel import render_info_panel
|
||||
|
||||
|
||||
# =============================================================================
|
||||
@@ -7,7 +7,7 @@ import uuid
|
||||
from typing import List, Dict, Any
|
||||
import streamlit as st
|
||||
|
||||
from frontend.config import config
|
||||
from .config import config
|
||||
|
||||
|
||||
class AppState:
|
||||
Reference in New Issue
Block a user