Skip to content

Commit 79bfab1

Browse files
refactor(chat): remove get_friends action and auto-include friends list in prompt
Remove the GetFriendsAction class and its corresponding handler, replacing the action-based retrieval with automatic inclusion of friends list data in the prompt template. This simplifies the available actions for the AI by providing friend information as static context rather than requiring an explicit action call.
1 parent 19a9664 commit 79bfab1

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/lang/zh_hans/chat.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,14 +1345,6 @@ main_session:
13451345
"subject": "和他聊聊关于XXX" // 简单描述你想要给 TA 发送的内容(概括主题)。
13461346
}}
13471347
1348-
### 获取好友列表
1349-
1350-
> 这个动作能让你看到你的好友列表,包括好友的介绍、好感度、上次与你互动的时间等信息。
1351-
1352-
{{
1353-
"type": "get_friends"
1354-
}}
1355-
13561348
### 跳过处理
13571349
13581350
{{
@@ -1373,6 +1365,8 @@ main_session:
13731365
13741366
{}
13751367
1368+
{}
1369+
13761370
## 附加信息
13771371
13781372
{}

src/plugins/nonebot_plugin_chat/core/main_session.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class CustomAction(BaseModel):
4040
estimated_time: int
4141

4242

43-
class GetFriendsAction(BaseModel):
44-
type: Literal["get_friends"]
43+
# class GetFriendsAction(BaseModel):
44+
# type: Literal["get_friends"]
4545

4646

4747
class SendPrivateMsgAction(BaseModel):
@@ -55,7 +55,7 @@ class RestAction(BaseModel):
5555
time: int
5656

5757

58-
BoredAction = Union[SkipAction, CustomAction, GetFriendsAction, SendPrivateMsgAction, RestAction]
58+
BoredAction = Union[SkipAction, CustomAction, SendPrivateMsgAction, RestAction]
5959

6060

6161
class BoredActionResponse(BaseModel):
@@ -206,6 +206,7 @@ async def generate_system_prompt(self) -> str:
206206
"main_session.prompt",
207207
self.lang_str,
208208
await lang.text("prompt_group.identify", self.lang_str),
209+
await self.get_friends(),
209210
await lang.text("prompt_group.time", self.lang_str, datetime.now().isoformat()),
210211
state_str,
211212
"\n".join(
@@ -257,8 +258,8 @@ async def process_boredom(self) -> None:
257258

258259
async def handle_action(self, action: BoredAction, fetcher: MessageFetcher) -> None:
259260
match action.type:
260-
case "get_friends":
261-
fetcher.session.insert_message(generate_message(await self.get_friends(), "user"))
261+
# case "get_friends":
262+
# fetcher.session.insert_message(generate_message(await self.get_friends(), "user"))
262263
case "send_private_message":
263264
# 记录发送私聊前的状态,用于后续判断用户是否回复
264265
self._current_action_send_private_time = datetime.now()

0 commit comments

Comments
 (0)