npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

union-py-app-stream-chat

v1.1.0

Published

Source package for the union operations stream chat Python app.

Readme

GLM 运维智能助手 (OpsAssistant)

基于智谱 GLM 大模型的运维平台运行表现问答服务。

项目结构

glm-ops-assistant/
├── config/
│   └── config.yaml              # 配置文件(API Key、模型参数、过滤规则等)
├── src/
│   ├── api/
│   │   └── routes.py            # View 层 - FastAPI 路由接口
│   ├── service/
│   │   └── chat_service.py      # Service 层 - 业务逻辑(问题筛选、流程编排)
│   ├── manager/
│   │   └── toolcall_manager.py  # Manager 层 - 工具调用封装
│   ├── core/
│   │   ├── config_loader.py     # 核心工具 - 配置加载(支持环境变量覆盖)
│   │   └── logging_config.py    # 核心工具 - 日志配置
│   └── models/
│       └── schemas.py           # Pydantic 数据模型
├── tests/
│   └── test_chat_service.py     # 单元测试
├── main.py                      # 服务入口
├── requirements.txt             # 依赖清单
└── README.md

快速开始

1. 安装依赖

pip install -r requirements.txt

2. 配置

编辑 config/config.yaml,填入你的 GLM API Key:

llm:
  api_key: "your-api-key-here"
  model: "glm-4-flash"

或通过环境变量覆盖:

export APP_CONFIG_PATH="/path/to/config.yaml"
export LLM_API_KEY="your-api-key"
export LLM_MODEL="glm-4-flash"
export RAG_ENABLED="true"

3. 启动服务

uvicorn main:app --host 0.0.0.0 --port 8000 --reload

启动后访问文档:http://localhost:8000/docs

API 接口

| 方法 | 路径 | 说明 | |------|------|------| | POST | /api/v1/chat/stream | 流式对话(SSE) | | GET | /api/v1/health | 健康检查 |

多轮对话

通过 session_id 标识会话,系统自动维护上下文历史。历史记录保存在内存中,支持 TTL 过期清理。

问题筛选

服务会自动判断用户问题是否与系统运行表现相关(CPU、内存、磁盘、网络、告警、故障等)。

不符合条件的问题会被直接拒绝,返回预设提示语。筛选关键词和提示语可在 config.yaml 中自定义。

流式输出

调用 /api/v1/chat/stream 接口,服务端使用 SSE 协议逐字推送模型生成内容。

每条 message 事件的 dataChatResponse JSON:

{
  "session_id": "sess-xxx",
  "content": "正式回复增量",
  "reasoning_content": null,
  "tool_call": null,
  "tool_result": null,
  "finish_reason": null
}

模型正式回复写入 content,推理内容写入 reasoning_content,工具过程写入 tool_call / tool_result