Skip to main content

NexAgent - AI 对话框架,支持多服务商、多模型切换、深度思考、工具调用、流式输出、多会话管理

Project description

NexAgent

PyPI version Python versions License

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)

自定义工具与插件

自定义工具

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nex_agent-0.5.0.tar.gz (100.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nex_agent-0.5.0-py3-none-any.whl (104.2 kB view details)

Uploaded Python 3

File details

Details for the file nex_agent-0.5.0.tar.gz.

File metadata

  • Download URL: nex_agent-0.5.0.tar.gz
  • Upload date:
  • Size: 100.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for nex_agent-0.5.0.tar.gz
Algorithm Hash digest
SHA256 64e9af2508973879a134a5e7f9cae1bae1e3d66b2ea75a9ccd180f2fdf8d5dac
MD5 d8f71012f22794946b7e4f8f85320434
BLAKE2b-256 c09b34c0ffbcb9ca68352780769f3c9b9bcb3f6251f42e38b4d6c39c4a278392

See more details on using hashes here.

File details

Details for the file nex_agent-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: nex_agent-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 104.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for nex_agent-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae5ff7adee158df9098d743d78faa33a8598d8a047cc37019b495dae82b7fe8a
MD5 ff85c7121432456a6e1e6a6dab71b646
BLAKE2b-256 4c3175f614fd7458edfd7e3c64803a5e1abbd9ac8fb8316942744da8e65ccfac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page