feat: 添加起卦教程首次访问追踪和Agent时间上下文
- 后端 ProfileSettingsV1 添加 DivinationTutorialSettings 字段 - 前端三个起卦页面添加首次访问检测,自动弹出教程 - 教程展示后更新 settings 标记,避免重复弹出 - 使用本地状态管理避免并发更新覆盖问题 - Agent 系统提示添加时间上下文信息
This commit is contained in:
@@ -2,6 +2,8 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Sequence
|
||||
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from ag_ui.core.types import Tool
|
||||
from core.agentscope.prompts.agent_prompt import build_agent_prompt
|
||||
from core.agentscope.prompts.sections import wrap_section
|
||||
@@ -48,14 +50,31 @@ def _build_output_rules(*, ai_language: str) -> str:
|
||||
return wrap_section("output", "\n".join(rules))
|
||||
|
||||
|
||||
def _build_time_context(*, now_utc: datetime | None) -> str:
|
||||
if now_utc is None:
|
||||
now_utc = datetime.now(timezone.utc)
|
||||
if now_utc.tzinfo is None:
|
||||
now_utc = now_utc.replace(tzinfo=timezone.utc)
|
||||
else:
|
||||
now_utc = now_utc.astimezone(timezone.utc)
|
||||
|
||||
return (
|
||||
"[Time Context]\n"
|
||||
f"- current_time_utc: {now_utc.isoformat()}\n"
|
||||
f"- This helps you understand the current time (distinct from divination_time in user input)."
|
||||
)
|
||||
|
||||
|
||||
def build_system_prompt(
|
||||
*,
|
||||
agent_type: AgentType,
|
||||
ai_language: str,
|
||||
llm_config: SystemAgentLLMConfig | None = None,
|
||||
tools: Sequence[Tool | dict[str, Any]] | None = None,
|
||||
now_utc: datetime | None = None,
|
||||
) -> str:
|
||||
sections: list[str | None] = [
|
||||
_build_time_context(now_utc=now_utc),
|
||||
_build_safety_section(),
|
||||
build_agent_prompt(
|
||||
agent_type=agent_type,
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
import contextlib
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any, Awaitable, Callable
|
||||
|
||||
from ag_ui.core.types import RunAgentInput
|
||||
@@ -275,6 +276,7 @@ class AgentScopeRunner:
|
||||
ai_language=ai_language,
|
||||
llm_config=stage_config.llm_config,
|
||||
tools=None,
|
||||
now_utc=datetime.now(timezone.utc),
|
||||
)
|
||||
|
||||
_, worker_payload_raw = await finalize_json_response(
|
||||
|
||||
@@ -46,11 +46,20 @@ class NotificationSettings(BaseModel):
|
||||
allow_vibration: bool = True
|
||||
|
||||
|
||||
class DivinationTutorialSettings(BaseModel):
|
||||
divination_entry_shown: bool = False
|
||||
auto_divination_shown: bool = False
|
||||
manual_divination_shown: bool = False
|
||||
|
||||
|
||||
class ProfileSettingsV1(BaseModel):
|
||||
version: Literal[1] = 1
|
||||
preferences: PreferenceSettings = Field(default_factory=PreferenceSettings)
|
||||
privacy: dict[str, object] = Field(default_factory=dict)
|
||||
notification: NotificationSettings = Field(default_factory=NotificationSettings)
|
||||
divination_tutorial: DivinationTutorialSettings = Field(
|
||||
default_factory=DivinationTutorialSettings
|
||||
)
|
||||
|
||||
|
||||
ProfileSettingsUnion = ProfileSettingsV1
|
||||
|
||||
Reference in New Issue
Block a user