tina-python 0.6.8__tar.gz → 0.7.1__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.
- {tina_python-0.6.8 → tina_python-0.7.1}/PKG-INFO +57 -14
- tina_python-0.6.8/tina_python.egg-info/PKG-INFO → tina_python-0.7.1/README.md +52 -47
- {tina_python-0.6.8 → tina_python-0.7.1}/pyproject.toml +8 -3
- {tina_python-0.6.8 → tina_python-0.7.1}/setup.py +6 -1
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/__init__.py +3 -1
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/agent.py +13 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/core/agent_runtime.py +97 -51
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/core/context_manager.py +8 -3
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/core/events.py +105 -1
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/core/executor.py +154 -43
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/core/tools.py +130 -14
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/core/error.py +54 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/llm/__init__.py +4 -3
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/llm/base_api.py +14 -11
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/llm/base_multimodal_api.py +6 -2
- tina_python-0.7.1/tina/llm/files_api.py +544 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/mcp/client.py +55 -5
- tina_python-0.7.1/tina/mcp/mcp_tools_executor.py +108 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/utils/__init__.py +3 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/utils/deepseek.py +31 -4
- tina_python-0.7.1/tina/utils/multi_agent/__init__.py +26 -0
- tina_python-0.7.1/tina/utils/multi_agent/environment.py +3 -0
- tina_python-0.7.1/tina/utils/multi_agent/message.py +3 -0
- tina_python-0.7.1/tina/utils/multi_agent/message_bus.py +3 -0
- tina_python-0.7.1/tina/utils/multi_agent/web/__init__.py +3 -0
- tina_python-0.7.1/tina/utils/multi_agent/web/server.py +3 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/utils/multimodal_formatter.py +10 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/utils/output_parser.py +258 -27
- tina_python-0.7.1/tina/utils/tui/__init__.py +41 -0
- tina_python-0.7.1/tina/utils/tui/context_manager.py +3 -0
- tina_python-0.7.1/tina/utils/tui/token.py +3 -0
- tina_python-0.7.1/tina/utils/tui/tui.py +3 -0
- tina_python-0.7.1/tina/utils/url.py +32 -0
- tina_python-0.7.1/tina/utils/usage.py +120 -0
- tina_python-0.6.8/README.md → tina_python-0.7.1/tina_python.egg-info/PKG-INFO +90 -12
- {tina_python-0.6.8 → tina_python-0.7.1}/tina_python.egg-info/SOURCES.txt +9 -3
- {tina_python-0.6.8 → tina_python-0.7.1}/tina_python.egg-info/requires.txt +6 -2
- tina_python-0.6.8/tina/llm/BaseNewAPI.py +0 -5
- tina_python-0.6.8/tina/llm/ollama_api.py +0 -81
- tina_python-0.6.8/tina/mcp/mcp_tools_executor.py +0 -88
- tina_python-0.6.8/tina/utils/timer.py +0 -59
- tina_python-0.6.8/tina/utils/tui/__init__.py +0 -34
- tina_python-0.6.8/tina/utils/tui/context_manager.py +0 -603
- tina_python-0.6.8/tina/utils/tui/token.py +0 -89
- tina_python-0.6.8/tina/utils/tui/tui.py +0 -1545
- {tina_python-0.6.8 → tina_python-0.7.1}/LICENSE +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/MANIFEST.in +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/setup.cfg +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/__init__.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/core/__init__.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/core/agent_response.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/core/keyword_actions.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/core/prompt.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/core/state.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/agent/multimodal_agent.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/core/__init__.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/core/logger.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/mcp/__init__.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/py.typed +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/utils/agent_worker.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/utils/doc_parser.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/utils/env_reader.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/utils/run_agent_in_cli.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/utils/system_tools.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina/utils/type_mapper.py +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina_python.egg-info/dependency_links.txt +0 -0
- {tina_python-0.6.8 → tina_python-0.7.1}/tina_python.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tina-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.1
|
|
4
4
|
Summary: tina is in your computer!
|
|
5
5
|
Home-page: https://gitee.com/wang-churi/tina
|
|
6
6
|
Author: 王出日
|
|
@@ -18,7 +18,9 @@ License-File: LICENSE
|
|
|
18
18
|
Requires-Dist: httpx
|
|
19
19
|
Requires-Dist: python-dotenv
|
|
20
20
|
Provides-Extra: tui
|
|
21
|
-
Requires-Dist:
|
|
21
|
+
Requires-Dist: tina-tui>=0.1.0; extra == "tui"
|
|
22
|
+
Provides-Extra: multi-agent
|
|
23
|
+
Requires-Dist: tina-multi-agent>=0.1.0; extra == "multi-agent"
|
|
22
24
|
Provides-Extra: mcp
|
|
23
25
|
Requires-Dist: mcp>=2.0; extra == "mcp"
|
|
24
26
|
Provides-Extra: test
|
|
@@ -26,7 +28,8 @@ Requires-Dist: pytest>=9.0; extra == "test"
|
|
|
26
28
|
Requires-Dist: pytest-asyncio>=1.4; extra == "test"
|
|
27
29
|
Requires-Dist: pytest-cov>=7.0; extra == "test"
|
|
28
30
|
Provides-Extra: all
|
|
29
|
-
Requires-Dist:
|
|
31
|
+
Requires-Dist: tina-tui>=0.1.0; extra == "all"
|
|
32
|
+
Requires-Dist: tina-multi-agent>=0.1.0; extra == "all"
|
|
30
33
|
Requires-Dist: mcp>=2.0; extra == "all"
|
|
31
34
|
Dynamic: author
|
|
32
35
|
Dynamic: home-page
|
|
@@ -50,10 +53,13 @@ pip install tina-python
|
|
|
50
53
|
# 如果需要使用 MCP(模型上下文协议)服务
|
|
51
54
|
pip install tina-python[mcp]
|
|
52
55
|
|
|
53
|
-
# 如果需要 TUI
|
|
56
|
+
# 如果需要 TUI 终端界面(独立发行包 tina-tui)
|
|
54
57
|
pip install tina-python[tui]
|
|
55
58
|
|
|
56
|
-
#
|
|
59
|
+
# 如果需要多 Agent 环境 + Web 调试控制台(独立发行包 tina-multi-agent)
|
|
60
|
+
pip install tina-python[multi-agent]
|
|
61
|
+
|
|
62
|
+
# 一次装齐所有可选功能(TUI + 多 Agent + MCP)
|
|
57
63
|
pip install tina-python[all]
|
|
58
64
|
|
|
59
65
|
# 如果需要运行测试
|
|
@@ -110,7 +116,7 @@ for chunk in result:
|
|
|
110
116
|
- [四、MCP 支持 —— 模型上下文协议](#四mcp-支持--模型上下文协议)
|
|
111
117
|
- [五、多模态支持](#五多模态支持)
|
|
112
118
|
- [六、快速开发工具](#六快速开发工具)
|
|
113
|
-
- [
|
|
119
|
+
- [七、拓展包(可选)](#七拓展包可选)
|
|
114
120
|
|
|
115
121
|
---
|
|
116
122
|
|
|
@@ -138,7 +144,8 @@ tina 是一个轻量、模块化的 AI 智能体框架,专注于让开发者
|
|
|
138
144
|
| **MCPClient** | MCP 集成 | 连接 MCP 服务器生态(stdio/SSE) |
|
|
139
145
|
| **ContextManager** | 上下文管理 | 滚动窗口策略,自动截断 |
|
|
140
146
|
| **AgentEvents** | 事件系统 | 贯穿 Agent 生命周期的回调钩子 |
|
|
141
|
-
| **TUI(可选)** | 终端界面 |
|
|
147
|
+
| **TUI(可选)** | 终端界面 | 独立包 `tina-tui`:测试 Agent 的交互控制台,也可当作自己的 TUI 使用 |
|
|
148
|
+
| **多 Agent(可选)** | 多 Agent 环境 | 独立包 `tina-multi-agent`:消息总线 + Web 调试控制台 |
|
|
142
149
|
|
|
143
150
|
---
|
|
144
151
|
|
|
@@ -704,7 +711,7 @@ tina 支持通过 MCP(Model Context Protocol)连接外部工具生态。
|
|
|
704
711
|
pip install tina-python[mcp]
|
|
705
712
|
```
|
|
706
713
|
|
|
707
|
-
> 想一次装齐所有可选功能(TUI + MCP):`pip install tina-python[all]`
|
|
714
|
+
> 想一次装齐所有可选功能(TUI + 多 Agent + MCP):`pip install tina-python[all]`
|
|
708
715
|
|
|
709
716
|
### 4.2 使用 MCP 客户端
|
|
710
717
|
|
|
@@ -1028,18 +1035,24 @@ print(message)
|
|
|
1028
1035
|
# {"role": "user", "content": [{"type": "text", "text": "..."}, {"type": "image_url", ...}]}
|
|
1029
1036
|
```
|
|
1030
1037
|
|
|
1031
|
-
|
|
1038
|
+
---
|
|
1039
|
+
|
|
1040
|
+
## 七、拓展包(可选)
|
|
1032
1041
|
|
|
1033
|
-
|
|
1042
|
+
tina 核心保持轻量:终端界面与多 Agent 环境这两块较大的功能,拆成**独立发行包**,按需安装、独立更新与发布。主包内不再包含它们的实现(仅保留 `tina.utils.*` 兼容转发壳)。
|
|
1043
|
+
|
|
1044
|
+
### 7.1 终端界面 TUI(`tina-tui`)
|
|
1045
|
+
|
|
1046
|
+
终端界面由配套包 **`tina-tui`**(基于 [Textual](https://textual.textualize.io/))提供,作为**可选扩展**单独发行:方便你测试自己写的 Agent,也可以直接当作自己的 TUI 来用。核心不依赖它,需要额外安装:
|
|
1034
1047
|
|
|
1035
1048
|
```bash
|
|
1036
|
-
pip install tina-python[tui]
|
|
1049
|
+
pip install tina-python[tui] # 等价于安装 tina-tui
|
|
1037
1050
|
```
|
|
1038
1051
|
|
|
1039
1052
|
```python
|
|
1040
1053
|
from tina import Agent, Tools
|
|
1041
1054
|
from tina.llm import BaseAPI
|
|
1042
|
-
from
|
|
1055
|
+
from tina_tui import run_agent_in_tui
|
|
1043
1056
|
|
|
1044
1057
|
agent = Agent(llm=BaseAPI(), tools=Tools())
|
|
1045
1058
|
|
|
@@ -1073,10 +1086,39 @@ run_agent_in_tui(agent, max_tokens=32000)
|
|
|
1073
1086
|
|
|
1074
1087
|
快捷键:`Ctrl+↑/↓` 跳转消息、`Ctrl+Home/End` 首/末条、`Ctrl+R` 折叠思考、`Ctrl+T` 折叠工具与结果、`Ctrl+O` 查看完整工具参数、`Esc` 关闭弹窗/取消确认 / 打断本轮回复。
|
|
1075
1088
|
|
|
1076
|
-
> 界面是可选的:数据层 `TuiMessageStore`(渲染块列表)和 `TokenCounter`(token
|
|
1089
|
+
> 界面是可选的:数据层 `TuiMessageStore`(渲染块列表)和 `TokenCounter`(token 计数)在 `tina_tui` 里**不依赖 textual**,可以单独导入,用来接入你自己的界面。
|
|
1077
1090
|
|
|
1078
1091
|
完整说明(安装、指令、快捷键、自建界面)见 [`docs/tui.md`](./docs/tui.md)。
|
|
1079
1092
|
|
|
1093
|
+
### 7.2 多 Agent 环境(`tina-multi-agent`)
|
|
1094
|
+
|
|
1095
|
+
多 Agent 场景由独立发行包 **`tina-multi-agent`** 提供:把多个各自独立的 `Agent`(含 `MultimodalAgent`)注册进一个「环境」,通过消息总线互相通信,并带一个 Web 调试控制台用于观测与介入。
|
|
1096
|
+
|
|
1097
|
+
```bash
|
|
1098
|
+
pip install tina-python[multi-agent] # 等价于安装 tina-multi-agent
|
|
1099
|
+
```
|
|
1100
|
+
|
|
1101
|
+
```python
|
|
1102
|
+
from tina import Agent
|
|
1103
|
+
from tina.llm import BaseAPI
|
|
1104
|
+
from tina_multi_agent import MultiAgentEnvironment, MultiAgentWeb
|
|
1105
|
+
|
|
1106
|
+
llm = BaseAPI()
|
|
1107
|
+
|
|
1108
|
+
env = MultiAgentEnvironment(name="room")
|
|
1109
|
+
env.add_agent(Agent(llm=llm, name="alice", system_prompt="你是 alice"))
|
|
1110
|
+
env.add_agent(Agent(llm=llm, name="bob", system_prompt="你是 bob"))
|
|
1111
|
+
|
|
1112
|
+
# 带 Web 控制台启动(自动启动环境):打开 http://127.0.0.1:7077
|
|
1113
|
+
MultiAgentWeb(env, port=7077).run()
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
- 每个 Agent 一个收信队列;外部指令走 `add_user_message`,同伴消息作为带 `name` 的 assistant 消息注入。
|
|
1117
|
+
- 支持**回合中途注入**(`before_llm_call`)、打断(`env.interrupt`)、工具确认与权限表。
|
|
1118
|
+
- Web 控制台能力、消息总线、`POST /instruction`、`WS /ws` 事件等完整说明见 [`packages/tina-multi-agent/README.md`](./packages/tina-multi-agent/README.md)。
|
|
1119
|
+
|
|
1120
|
+
> 兼容提示:旧路径 `tina.utils.multi_agent` 仍可用(主包内保留转发壳);未安装 `tina-multi-agent` 时会提示安装。
|
|
1121
|
+
|
|
1080
1122
|
---
|
|
1081
1123
|
|
|
1082
1124
|
## 附录
|
|
@@ -1098,7 +1140,8 @@ MAX_INPUT=8000
|
|
|
1098
1140
|
|------|------|
|
|
1099
1141
|
| 核心功能 | `httpx`, `python-dotenv` |
|
|
1100
1142
|
| MCP 支持 | `mcp` |
|
|
1101
|
-
| TUI
|
|
1143
|
+
| TUI 界面(可选,`tina-tui`) | `textual` |
|
|
1144
|
+
| 多 Agent(可选,`tina-multi-agent`) | `fastapi`, `uvicorn`, `websockets` |
|
|
1102
1145
|
| 测试 | `pytest`, `pytest-asyncio`, `pytest-cov` |
|
|
1103
1146
|
|
|
1104
1147
|
### 许可证
|
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: tina-python
|
|
3
|
-
Version: 0.6.8
|
|
4
|
-
Summary: tina is in your computer!
|
|
5
|
-
Home-page: https://gitee.com/wang-churi/tina
|
|
6
|
-
Author: 王出日
|
|
7
|
-
Author-email: 王出日 <wangchuri@163.com>
|
|
8
|
-
License: Apache Software License
|
|
9
|
-
Project-URL: Homepage, https://gitee.com/wang-churi/tina
|
|
10
|
-
Project-URL: Repository, https://gitee.com/wang-churi/tina.git
|
|
11
|
-
Project-URL: GitHub, https://github.com/XIMOCY/tina.git
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
-
Classifier: Operating System :: OS Independent
|
|
15
|
-
Requires-Python: >=3.10
|
|
16
|
-
Description-Content-Type: text/markdown
|
|
17
|
-
License-File: LICENSE
|
|
18
|
-
Requires-Dist: httpx
|
|
19
|
-
Requires-Dist: python-dotenv
|
|
20
|
-
Provides-Extra: tui
|
|
21
|
-
Requires-Dist: textual>=0.80; extra == "tui"
|
|
22
|
-
Provides-Extra: mcp
|
|
23
|
-
Requires-Dist: mcp>=2.0; extra == "mcp"
|
|
24
|
-
Provides-Extra: test
|
|
25
|
-
Requires-Dist: pytest>=9.0; extra == "test"
|
|
26
|
-
Requires-Dist: pytest-asyncio>=1.4; extra == "test"
|
|
27
|
-
Requires-Dist: pytest-cov>=7.0; extra == "test"
|
|
28
|
-
Provides-Extra: all
|
|
29
|
-
Requires-Dist: textual>=0.80; extra == "all"
|
|
30
|
-
Requires-Dist: mcp>=2.0; extra == "all"
|
|
31
|
-
Dynamic: author
|
|
32
|
-
Dynamic: home-page
|
|
33
|
-
Dynamic: license-file
|
|
34
|
-
Dynamic: requires-python
|
|
35
|
-
|
|
36
1
|
# tina
|
|
37
2
|
|
|
38
3
|

|
|
@@ -50,10 +15,13 @@ pip install tina-python
|
|
|
50
15
|
# 如果需要使用 MCP(模型上下文协议)服务
|
|
51
16
|
pip install tina-python[mcp]
|
|
52
17
|
|
|
53
|
-
# 如果需要 TUI
|
|
18
|
+
# 如果需要 TUI 终端界面(独立发行包 tina-tui)
|
|
54
19
|
pip install tina-python[tui]
|
|
55
20
|
|
|
56
|
-
#
|
|
21
|
+
# 如果需要多 Agent 环境 + Web 调试控制台(独立发行包 tina-multi-agent)
|
|
22
|
+
pip install tina-python[multi-agent]
|
|
23
|
+
|
|
24
|
+
# 一次装齐所有可选功能(TUI + 多 Agent + MCP)
|
|
57
25
|
pip install tina-python[all]
|
|
58
26
|
|
|
59
27
|
# 如果需要运行测试
|
|
@@ -110,7 +78,7 @@ for chunk in result:
|
|
|
110
78
|
- [四、MCP 支持 —— 模型上下文协议](#四mcp-支持--模型上下文协议)
|
|
111
79
|
- [五、多模态支持](#五多模态支持)
|
|
112
80
|
- [六、快速开发工具](#六快速开发工具)
|
|
113
|
-
- [
|
|
81
|
+
- [七、拓展包(可选)](#七拓展包可选)
|
|
114
82
|
|
|
115
83
|
---
|
|
116
84
|
|
|
@@ -138,7 +106,8 @@ tina 是一个轻量、模块化的 AI 智能体框架,专注于让开发者
|
|
|
138
106
|
| **MCPClient** | MCP 集成 | 连接 MCP 服务器生态(stdio/SSE) |
|
|
139
107
|
| **ContextManager** | 上下文管理 | 滚动窗口策略,自动截断 |
|
|
140
108
|
| **AgentEvents** | 事件系统 | 贯穿 Agent 生命周期的回调钩子 |
|
|
141
|
-
| **TUI(可选)** | 终端界面 |
|
|
109
|
+
| **TUI(可选)** | 终端界面 | 独立包 `tina-tui`:测试 Agent 的交互控制台,也可当作自己的 TUI 使用 |
|
|
110
|
+
| **多 Agent(可选)** | 多 Agent 环境 | 独立包 `tina-multi-agent`:消息总线 + Web 调试控制台 |
|
|
142
111
|
|
|
143
112
|
---
|
|
144
113
|
|
|
@@ -704,7 +673,7 @@ tina 支持通过 MCP(Model Context Protocol)连接外部工具生态。
|
|
|
704
673
|
pip install tina-python[mcp]
|
|
705
674
|
```
|
|
706
675
|
|
|
707
|
-
> 想一次装齐所有可选功能(TUI + MCP):`pip install tina-python[all]`
|
|
676
|
+
> 想一次装齐所有可选功能(TUI + 多 Agent + MCP):`pip install tina-python[all]`
|
|
708
677
|
|
|
709
678
|
### 4.2 使用 MCP 客户端
|
|
710
679
|
|
|
@@ -1028,18 +997,24 @@ print(message)
|
|
|
1028
997
|
# {"role": "user", "content": [{"type": "text", "text": "..."}, {"type": "image_url", ...}]}
|
|
1029
998
|
```
|
|
1030
999
|
|
|
1031
|
-
|
|
1000
|
+
---
|
|
1001
|
+
|
|
1002
|
+
## 七、拓展包(可选)
|
|
1003
|
+
|
|
1004
|
+
tina 核心保持轻量:终端界面与多 Agent 环境这两块较大的功能,拆成**独立发行包**,按需安装、独立更新与发布。主包内不再包含它们的实现(仅保留 `tina.utils.*` 兼容转发壳)。
|
|
1005
|
+
|
|
1006
|
+
### 7.1 终端界面 TUI(`tina-tui`)
|
|
1032
1007
|
|
|
1033
|
-
|
|
1008
|
+
终端界面由配套包 **`tina-tui`**(基于 [Textual](https://textual.textualize.io/))提供,作为**可选扩展**单独发行:方便你测试自己写的 Agent,也可以直接当作自己的 TUI 来用。核心不依赖它,需要额外安装:
|
|
1034
1009
|
|
|
1035
1010
|
```bash
|
|
1036
|
-
pip install tina-python[tui]
|
|
1011
|
+
pip install tina-python[tui] # 等价于安装 tina-tui
|
|
1037
1012
|
```
|
|
1038
1013
|
|
|
1039
1014
|
```python
|
|
1040
1015
|
from tina import Agent, Tools
|
|
1041
1016
|
from tina.llm import BaseAPI
|
|
1042
|
-
from
|
|
1017
|
+
from tina_tui import run_agent_in_tui
|
|
1043
1018
|
|
|
1044
1019
|
agent = Agent(llm=BaseAPI(), tools=Tools())
|
|
1045
1020
|
|
|
@@ -1073,10 +1048,39 @@ run_agent_in_tui(agent, max_tokens=32000)
|
|
|
1073
1048
|
|
|
1074
1049
|
快捷键:`Ctrl+↑/↓` 跳转消息、`Ctrl+Home/End` 首/末条、`Ctrl+R` 折叠思考、`Ctrl+T` 折叠工具与结果、`Ctrl+O` 查看完整工具参数、`Esc` 关闭弹窗/取消确认 / 打断本轮回复。
|
|
1075
1050
|
|
|
1076
|
-
> 界面是可选的:数据层 `TuiMessageStore`(渲染块列表)和 `TokenCounter`(token
|
|
1051
|
+
> 界面是可选的:数据层 `TuiMessageStore`(渲染块列表)和 `TokenCounter`(token 计数)在 `tina_tui` 里**不依赖 textual**,可以单独导入,用来接入你自己的界面。
|
|
1077
1052
|
|
|
1078
1053
|
完整说明(安装、指令、快捷键、自建界面)见 [`docs/tui.md`](./docs/tui.md)。
|
|
1079
1054
|
|
|
1055
|
+
### 7.2 多 Agent 环境(`tina-multi-agent`)
|
|
1056
|
+
|
|
1057
|
+
多 Agent 场景由独立发行包 **`tina-multi-agent`** 提供:把多个各自独立的 `Agent`(含 `MultimodalAgent`)注册进一个「环境」,通过消息总线互相通信,并带一个 Web 调试控制台用于观测与介入。
|
|
1058
|
+
|
|
1059
|
+
```bash
|
|
1060
|
+
pip install tina-python[multi-agent] # 等价于安装 tina-multi-agent
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
```python
|
|
1064
|
+
from tina import Agent
|
|
1065
|
+
from tina.llm import BaseAPI
|
|
1066
|
+
from tina_multi_agent import MultiAgentEnvironment, MultiAgentWeb
|
|
1067
|
+
|
|
1068
|
+
llm = BaseAPI()
|
|
1069
|
+
|
|
1070
|
+
env = MultiAgentEnvironment(name="room")
|
|
1071
|
+
env.add_agent(Agent(llm=llm, name="alice", system_prompt="你是 alice"))
|
|
1072
|
+
env.add_agent(Agent(llm=llm, name="bob", system_prompt="你是 bob"))
|
|
1073
|
+
|
|
1074
|
+
# 带 Web 控制台启动(自动启动环境):打开 http://127.0.0.1:7077
|
|
1075
|
+
MultiAgentWeb(env, port=7077).run()
|
|
1076
|
+
```
|
|
1077
|
+
|
|
1078
|
+
- 每个 Agent 一个收信队列;外部指令走 `add_user_message`,同伴消息作为带 `name` 的 assistant 消息注入。
|
|
1079
|
+
- 支持**回合中途注入**(`before_llm_call`)、打断(`env.interrupt`)、工具确认与权限表。
|
|
1080
|
+
- Web 控制台能力、消息总线、`POST /instruction`、`WS /ws` 事件等完整说明见 [`packages/tina-multi-agent/README.md`](./packages/tina-multi-agent/README.md)。
|
|
1081
|
+
|
|
1082
|
+
> 兼容提示:旧路径 `tina.utils.multi_agent` 仍可用(主包内保留转发壳);未安装 `tina-multi-agent` 时会提示安装。
|
|
1083
|
+
|
|
1080
1084
|
---
|
|
1081
1085
|
|
|
1082
1086
|
## 附录
|
|
@@ -1098,7 +1102,8 @@ MAX_INPUT=8000
|
|
|
1098
1102
|
|------|------|
|
|
1099
1103
|
| 核心功能 | `httpx`, `python-dotenv` |
|
|
1100
1104
|
| MCP 支持 | `mcp` |
|
|
1101
|
-
| TUI
|
|
1105
|
+
| TUI 界面(可选,`tina-tui`) | `textual` |
|
|
1106
|
+
| 多 Agent(可选,`tina-multi-agent`) | `fastapi`, `uvicorn`, `websockets` |
|
|
1102
1107
|
| 测试 | `pytest`, `pytest-asyncio`, `pytest-cov` |
|
|
1103
1108
|
|
|
1104
1109
|
### 许可证
|
|
@@ -1107,4 +1112,4 @@ Apache License 2.0
|
|
|
1107
1112
|
|
|
1108
1113
|
### 贡献
|
|
1109
1114
|
|
|
1110
|
-
欢迎提交 Issue 和 PR!项目地址:https://github.com/XIMOCY/tina
|
|
1115
|
+
欢迎提交 Issue 和 PR!项目地址:https://github.com/XIMOCY/tina
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tina-python"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.7.1"
|
|
8
8
|
description = "tina is in your computer!"
|
|
9
9
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -29,7 +29,10 @@ GitHub = "https://github.com/XIMOCY/tina.git"
|
|
|
29
29
|
|
|
30
30
|
[project.optional-dependencies]
|
|
31
31
|
tui = [
|
|
32
|
-
"
|
|
32
|
+
"tina-tui>=0.1.0",
|
|
33
|
+
]
|
|
34
|
+
multi-agent = [
|
|
35
|
+
"tina-multi-agent>=0.1.0",
|
|
33
36
|
]
|
|
34
37
|
mcp = [
|
|
35
38
|
"mcp>=2.0",
|
|
@@ -40,12 +43,14 @@ test = [
|
|
|
40
43
|
"pytest-cov>=7.0",
|
|
41
44
|
]
|
|
42
45
|
all = [
|
|
43
|
-
"
|
|
46
|
+
"tina-tui>=0.1.0",
|
|
47
|
+
"tina-multi-agent>=0.1.0",
|
|
44
48
|
"mcp>=2.0",
|
|
45
49
|
]
|
|
46
50
|
|
|
47
51
|
[tool.pytest.ini_options]
|
|
48
52
|
testpaths = ["test"]
|
|
53
|
+
pythonpath = ["packages/tina-tui", "packages/tina-multi-agent"]
|
|
49
54
|
asyncio_mode = "auto"
|
|
50
55
|
markers = [
|
|
51
56
|
"slow: 需要 LLM 实际调用的测试(默认跳过)",
|
|
@@ -2,10 +2,15 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="tina-python",
|
|
5
|
-
version="0.
|
|
5
|
+
version="0.7.1",
|
|
6
6
|
packages=find_packages(),
|
|
7
7
|
package_data={"tina": ["py.typed"]},
|
|
8
8
|
install_requires=["httpx", "python-dotenv"],
|
|
9
|
+
extras_require={
|
|
10
|
+
"tui": ["tina-tui>=0.1.0"],
|
|
11
|
+
"multi-agent": ["tina-multi-agent>=0.1.0"],
|
|
12
|
+
"mcp": ["mcp>=2.0"],
|
|
13
|
+
},
|
|
9
14
|
description="tina is in your computer!",
|
|
10
15
|
long_description=open("README.md", encoding="utf-8").read(),
|
|
11
16
|
long_description_content_type="text/markdown",
|
|
@@ -8,6 +8,7 @@ from tina.agent import (
|
|
|
8
8
|
AgentState,
|
|
9
9
|
AgentEvents,
|
|
10
10
|
)
|
|
11
|
+
from tina.llm.files_api import FilesAPI
|
|
11
12
|
|
|
12
13
|
__all__ = [
|
|
13
14
|
"Agent",
|
|
@@ -18,5 +19,6 @@ __all__ = [
|
|
|
18
19
|
"MultimodalAgent",
|
|
19
20
|
"AgentState",
|
|
20
21
|
"AgentEvents",
|
|
22
|
+
"FilesAPI",
|
|
21
23
|
]
|
|
22
|
-
__version__ = "0.
|
|
24
|
+
__version__ = "0.7.1"
|
|
@@ -339,6 +339,19 @@ class Agent:
|
|
|
339
339
|
"""
|
|
340
340
|
self.events.add_on_turn_end_handler(func)
|
|
341
341
|
|
|
342
|
+
def before_llm_call(self):
|
|
343
|
+
"""
|
|
344
|
+
在每一次 LLM 调用之前触发(含工具循环的每一轮),不需要参数。
|
|
345
|
+
这是安全的上下文注入点。
|
|
346
|
+
"""
|
|
347
|
+
return self.events.before_llm_call()
|
|
348
|
+
|
|
349
|
+
def add_before_llm_call_handler(self, func: callable | list[callable]):
|
|
350
|
+
"""
|
|
351
|
+
在每一次 LLM 调用之前触发(含工具循环的每一轮),不需要参数。
|
|
352
|
+
"""
|
|
353
|
+
self.events.add_before_llm_call_handler(func)
|
|
354
|
+
|
|
342
355
|
def _mcp_to_tools(self, MCP):
|
|
343
356
|
"""如果传入了MCP,则将MCP的工具集加入到当前的工具集中"""
|
|
344
357
|
try:
|