wisruntime 0.4.0__tar.gz → 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {wisruntime-0.4.0/wisruntime.egg-info → wisruntime-0.4.2}/PKG-INFO +1 -1
- {wisruntime-0.4.0 → wisruntime-0.4.2}/pyproject.toml +1 -1
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/conversation/__init__.py +55 -53
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/conversation/client.py +336 -320
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/conversation/model.py +166 -167
- wisruntime-0.4.2/wisruntime/conversation/recorder.py +306 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/server/server.py +19 -9
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/skill/__init__.py +69 -69
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/skill/client.py +629 -629
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/skill/model.py +128 -128
- {wisruntime-0.4.0 → wisruntime-0.4.2/wisruntime.egg-info}/PKG-INFO +1 -1
- wisruntime-0.4.0/wisruntime/conversation/recorder.py +0 -183
- {wisruntime-0.4.0 → wisruntime-0.4.2}/MANIFEST.in +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/README.md +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/setup.cfg +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/__init__.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/adapters/__init__.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/adapters/langgraph/__init__.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/adapters/langgraph/builtin.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/adapters/langgraph/converter.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/adapters/langgraph/tool_adapter.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/adapters/langgraph/wrap_agent.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/config.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/exceptions.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/model.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/server/__init__.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/server/dify_handler.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/server/invoker.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/server/protocol.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/tool/__init__.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/tool/client.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/tool/model.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime/tool/protocol.py +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime.egg-info/SOURCES.txt +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime.egg-info/dependency_links.txt +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime.egg-info/requires.txt +0 -0
- {wisruntime-0.4.0 → wisruntime-0.4.2}/wisruntime.egg-info/top_level.txt +0 -0
|
@@ -1,53 +1,55 @@
|
|
|
1
|
-
"""会话模块 / Conversation Module.
|
|
2
|
-
|
|
3
|
-
wishub-memory 会话服务的薄写客户端 (agent 通道) + 自动持久化记录器。
|
|
4
|
-
框架无关——任何框架都可以使用,也自动集成进 create_server。
|
|
5
|
-
|
|
6
|
-
两种接入模式:
|
|
7
|
-
|
|
8
|
-
**方式一:自动持久化 (推荐,零代码集成)**
|
|
9
|
-
|
|
10
|
-
>>> from wisruntime import create_server
|
|
11
|
-
>>> from wisruntime.conversation import ConversationClient
|
|
12
|
-
>>>
|
|
13
|
-
>>> server = create_server(
|
|
14
|
-
... my_agent,
|
|
15
|
-
... conversation_client=ConversationClient(),
|
|
16
|
-
... )
|
|
17
|
-
>>> # 之后每次请求自动完成:
|
|
18
|
-
>>> # 1. 首轮自动创建会话 (回填 conversation_id 到流式事件)
|
|
19
|
-
>>> # 2. 每轮结束后后台追加 user + assistant 两条消息
|
|
20
|
-
>>> # 3. 持久化失败不影响响应
|
|
21
|
-
|
|
22
|
-
**方式二:手动客户端 (薄写客户端,agent 通道)**
|
|
23
|
-
|
|
24
|
-
>>> from wisruntime.conversation import ConversationClient
|
|
25
|
-
>>>
|
|
26
|
-
>>> async with ConversationClient() as client:
|
|
27
|
-
... conv = await client.create_conversation(user_id="u_001")
|
|
28
|
-
... # 一轮问答需要调用两次:一次 user,一次 assistant
|
|
29
|
-
...
|
|
30
|
-
... await client.append_message(conv.conversation_id, "
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
>>>
|
|
35
|
-
>>> client.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
from wisruntime.conversation.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
1
|
+
"""会话模块 / Conversation Module.
|
|
2
|
+
|
|
3
|
+
wishub-memory 会话服务的薄写客户端 (agent 通道) + 自动持久化记录器。
|
|
4
|
+
框架无关——任何框架都可以使用,也自动集成进 create_server。
|
|
5
|
+
|
|
6
|
+
两种接入模式:
|
|
7
|
+
|
|
8
|
+
**方式一:自动持久化 (推荐,零代码集成)**
|
|
9
|
+
|
|
10
|
+
>>> from wisruntime import create_server
|
|
11
|
+
>>> from wisruntime.conversation import ConversationClient
|
|
12
|
+
>>>
|
|
13
|
+
>>> server = create_server(
|
|
14
|
+
... my_agent,
|
|
15
|
+
... conversation_client=ConversationClient(),
|
|
16
|
+
... )
|
|
17
|
+
>>> # 之后每次请求自动完成:
|
|
18
|
+
>>> # 1. 首轮自动创建会话 (回填 conversation_id 到流式事件)
|
|
19
|
+
>>> # 2. 每轮结束后后台追加 user + assistant 两条消息
|
|
20
|
+
>>> # 3. 持久化失败不影响响应
|
|
21
|
+
|
|
22
|
+
**方式二:手动客户端 (薄写客户端,agent 通道)**
|
|
23
|
+
|
|
24
|
+
>>> from wisruntime.conversation import ConversationClient
|
|
25
|
+
>>>
|
|
26
|
+
>>> async with ConversationClient() as client:
|
|
27
|
+
... conv = await client.create_conversation(user_id="u_001")
|
|
28
|
+
... # 一轮问答需要调用两次:一次 user,一次 assistant
|
|
29
|
+
... # user_id 是归属锚点,必须与创建时一致 (否则 404)
|
|
30
|
+
... await client.append_message(conv.conversation_id, "u_001", "user", "你好")
|
|
31
|
+
... await client.append_message(conv.conversation_id, "u_001", "assistant", "你好!")
|
|
32
|
+
|
|
33
|
+
同步版本 (不能在事件循环中调用):
|
|
34
|
+
>>> client = ConversationClient()
|
|
35
|
+
>>> conv = client.create_conversation_sync(user_id="u_001")
|
|
36
|
+
>>> client.append_message_sync(conv.conversation_id, "u_001", "user", "你好")
|
|
37
|
+
|
|
38
|
+
范围说明:
|
|
39
|
+
- 仅 agent 通道写操作 (创建会话 + 追加消息)。历史消息、会话列表等
|
|
40
|
+
读操作走用户通道 (user JWT),由应用侧调用,不在 SDK 范围。
|
|
41
|
+
- agentCode 由服务端从 API Key 推导,请求体不传 agentId;userId 是
|
|
42
|
+
归属锚点,追加时必传且须等于目标会话归属用户;appCode 可选一致性
|
|
43
|
+
声明,提供时透传。
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
from wisruntime.conversation.client import ConversationClient
|
|
47
|
+
from wisruntime.conversation.model import ConversationInfo, MessageInfo
|
|
48
|
+
from wisruntime.conversation.recorder import ConversationRecorder
|
|
49
|
+
|
|
50
|
+
__all__ = [
|
|
51
|
+
"ConversationClient",
|
|
52
|
+
"ConversationRecorder",
|
|
53
|
+
"ConversationInfo",
|
|
54
|
+
"MessageInfo",
|
|
55
|
+
]
|