修改引用逻辑,修改长期记忆bug

This commit is contained in:
2026-04-20 15:55:58 +08:00
parent 4e981e9dcf
commit 3143e0e4e6
39 changed files with 444 additions and 246 deletions

View File

@@ -3,7 +3,7 @@ AI Agent 前端模块
采用分层架构设计包含配置、状态、API客户端和UI组件
"""
from .logger import debug, info, warning, error
from frontend.logger import debug, info, warning, error
__version__ = "2.0.0"
__all__ = ["debug", "info", "warning", "error"]

View File

@@ -9,8 +9,6 @@ from datetime import datetime
# 使用绝对导入
from frontend.state import AppState
from frontend.api_client import api_client
from frontend.config import config
def render_sidebar():
"""渲染左侧栏"""
@@ -25,7 +23,6 @@ def render_sidebar():
st.divider()
_render_user_section()
def _render_user_section():
"""渲染用户登录区域"""
# st.header("👤 用户") # 移除显眼的标题,改用更柔和的 caption
@@ -36,7 +33,6 @@ def _render_user_section():
else:
_render_user_info()
def _render_login_form():
"""渲染登录表单"""
username = st.text_input(
@@ -54,7 +50,6 @@ def _render_login_form():
# st.info("💡 建议登录以隔离对话历史") # 移除多余色块
def _render_user_info():
"""渲染用户信息"""
st.markdown(f"**当前用户**: `{AppState.get_user_id()}`")
@@ -64,7 +59,6 @@ def _render_user_info():
_refresh_threads()
st.rerun()
def _render_history_section():
"""渲染历史对话列表"""
col1, col2 = st.columns([3, 1])
@@ -76,7 +70,6 @@ def _render_history_section():
_render_thread_list()
def _render_history_actions():
"""渲染历史操作按钮"""
# 移除了 type="primary",让它变成普通的线框按钮,不再是大红块
@@ -84,7 +77,6 @@ def _render_history_actions():
AppState.start_new_thread()
st.rerun()
def _render_thread_list():
"""渲染线程列表"""
# 仅在初次加载时拉取,或由外部主动调用 _refresh_threads() 更新
@@ -101,7 +93,6 @@ def _render_thread_list():
for thread in threads:
_render_thread_item(thread)
def _render_thread_item(thread: dict):
"""
渲染单个线程项
@@ -130,7 +121,6 @@ def _render_thread_item(thread: dict):
):
_load_thread(thread_id)
def _format_time(time_str: str) -> str:
"""
格式化时间字符串
@@ -150,13 +140,11 @@ def _format_time(time_str: str) -> str:
except Exception:
return time_str[:10]
def _refresh_threads():
"""刷新历史线程列表"""
threads = api_client.get_user_threads(AppState.get_user_id())
AppState.set_threads(threads)
def _load_thread(thread_id: str):
"""
加载指定线程的消息历史

View File

@@ -7,7 +7,7 @@ import uuid
from typing import List, Dict, Any
import streamlit as st
from .config import config
from frontend.config import config
class AppState: