NexAgent
AI 对话框架,支持多模型、多会话、工具调用、MCP 协议、深度思考、记忆功能、角色卡。
特性
- 🔄 多模型切换 - 支持 OpenAI、DeepSeek 等兼容 API
- 💬 多会话管理 - 独立上下文,消息编辑/重新生成
- 🎭 角色卡 - 自定义 AI 人设和参数
- 🧠 记忆功能 - 基于向量的长期记忆
- 🔧 工具调用 - 内置 + 自定义 + MCP 工具
- 🧩 插件系统 - 扩展功能,注册工具和API路由
- 💭 深度思考 - 展示 AI 推理过程
- 📡 流式输出 - 实时返回内容
- 🌐 WebUI - 现代化界面,深色/浅色主题
快速开始
pip install nex-agent
nex init # 初始化工作目录
nex serve # 启动服务 (默认 6321 端口)
打开 http://localhost:6321,在设置中添加服务商和模型即可使用。
代码使用
from nex_agent import NexFramework
nex = NexFramework("./my_project")
# 创建会话并对话
session_id = nex.create_session("测试", "user1")
reply = nex.chat("user1", "你好", session_id=session_id)
# 流式对话
for chunk in nex.chat_stream("user1", "讲个故事", session_id=session_id):
print(chunk, end="", flush=True)
📖 更多使用示例: 查看 USAGE_EXAMPLE.md 了解完整的API使用方法,包括会话管理、角色卡系统、工具调用、向量记忆等功能。
自定义工具与插件
自定义工具
在 tools/ 目录创建 Python 文件:
# tools/calculator.py
TOOL_DEF = {
"name": "calculator",
"description": "计算器",
"parameters": {
"type": "object",
"properties": {"expression": {"type": "string"}},
"required": ["expression"]
}
}
def execute(args):
return str(eval(args["expression"]))
插件系统
插件可以扩展 NexAgent 功能,访问核心 API,注册自定义路由。
查看完整文档:插件开发示例
API
主要接口:
| 接口 | 说明 |
|---|---|
POST /nex/chat |
对话(支持流式) |
GET/POST/DELETE /nex/sessions |
会话管理 |
GET/POST/DELETE /nex/models |
模型管理 |
GET/POST/DELETE /nex/providers |
服务商管理 |
GET/POST/DELETE /nex/personas |
角色卡管理 |
GET/POST/DELETE /nex/memories |
记忆管理 |
GET/POST/DELETE /nex/mcp/servers |
MCP 服务器 |
License
MIT
Metadata
Release files for nex-agent 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nex_agent-0.6.0.tar.gz | 383.6 kB | Without provenance | Details for nex_agent-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nex_agent-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for nex_agent-0.6.0-py3-none-any.whl |
Total release size: 768.3 kB
Release files / nex_agent-0.6.0.tar.gz
| Download URL | nex_agent-0.6.0.tar.gz |
|---|---|
| Size | 383.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d879e82bf7ccc26a111efbe15fb39a567c76402fcc40aeecd573601d09429ea9
|
|
BLAKE2b-256 checksum How to use checksums |
1e9b1e49c9f06c52295d7b6b78acbd5480fcb1bd9670683292f936c4814d7a97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / nex_agent-0.6.0-py3-none-any.whl
| Download URL | nex_agent-0.6.0-py3-none-any.whl |
|---|---|
| Size | 384.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa5b996d46354022abc39f6a4744cad8f16823fa801fd383ad9e13068053bee2
|
|
BLAKE2b-256 checksum How to use checksums |
dec7f2c4e9ddf3136f87fccd747eadf4f04606c32f006a38561faad4199e4475
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for nex-agent 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.