Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add jiushiwon/wg-skills --skill fastapi-ai-chat-module-skillgit clone --depth 1 https://github.com/jiushiwon/wg-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/jiushiwon/wg-skills/fastapi-ai-chat-module-skill)<a href="https://agentmods.dev/skills/jiushiwon/wg-skills/fastapi-ai-chat-module-skill"><img src="https://agentmods.dev/badge/skills/jiushiwon/wg-skills/fastapi-ai-chat-module-skill/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/jiushiwon/wg-skills/fastapi-ai-chat-module-skill"><img src="https://agentmods.dev/badge/skills/jiushiwon/wg-skills/fastapi-ai-chat-module-skill.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector warn
SkillSpector: 1 finding, up to medium
These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →
- medium Data Exfiltration · line 41 Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00179 | $0.07083 |
| Opus 5.5 | $0.00072 | $0.02833 |
| Sonnet 5.5 | $0.00036 | $0.01417 |
| Haiku 4.5 | $0.00018 | $0.00708 |
Grade A, and why
fastapi-ai-chat-module-skill scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 916 lines — stays where its author put it; the contents beside it link to each section on GitHub.
FastAPI AI Chat Module Skill
面向已有 FastAPI 项目的开发者,快速集成 AI 对话 Agent 能力。
版本对标:本模块对齐 Spring Boot 版
springboot-agent-module-skill的能力矩阵(Function Calling、Tool、限流、审计等),确保两套体系的 AI 能力对齐。
骨架依赖
本模块依赖
fastapi-init-skill骨架 +fastapi-auth-module-skill鉴权模块。
使用前必须满足:
- ✅ 已安装
fastapi-init-skill(项目骨架) - ✅ 已安装
fastapi-auth-module-skill(用户鉴权)
对接规范:
- ✅ 使用骨架的
ApiResponse统一响应 - ✅ 使用骨架的
BusinessException异常处理(负数错误码 -1001 ~ -2000) - ✅ 使用骨架的
get_current_user()获取当前用户 - ✅ 使用骨架的数据库配置(SQLAlchemy + Alembic)
- ✅ 使用骨架的 Redis 配置(如有,用于限流/缓存)
- ✅ 使用骨架的
restart.sh部署脚本
核心能力清单
| # | 能力 | 说明 |
|---|---|---|
| 1 | Function Calling | 基于 OpenAI/Claude SDK,AI 可调用外部 Tool |
| 2 | Tool 系统 | 声明式 Tool 定义,自动参数校验,权限注入 |
| 3 | 多模型接入 | 统一 ChatModel 接口,支持 OpenAI/Claude/DeepSeek/Ollama |
| 4 | 多轮对话 | 上下文记忆,会话级别历史,LRU 自动裁剪 |
| 5 | 对话管理 | 创建/查询/删除/清除会话(软删除 + 级联硬删除) |
| 6 | 租户隔离 | 所有 Tool 按 tenant_id 过滤,多租户安全 |
| 7 | 流式输出 | SSE 流式返回 token,含断连检测 |
| 8 | Rate Limiting | Redis 实现,每用户 10 次/分钟(防 LLM 财务风险) |
| 9 | 审计日志 | 独立 logger,记录 tool_call/tool_failure/chat_failure/token_usage/rate_limit |
| 10 | 上下文记忆 | Deque 自动裁剪 + LRU 内存缓冲 |
| 11 | Token 统计 | 消耗统计与限额控制 |
| 12 | PII 加密 | Fernet 对称加密,日志自动脱敏 |
| 13 | trace_id 追踪 | MDC 注入 trace_id,跨服务追踪支持 |
| 14 | 模型白名单 | 客户端无法指定白名单外模型(防财务风险) |
用户问题(最多 3 个)
1. 用什么模型?(默认 gpt-4o-mini,可选 Claude/DeepSeek/Ollama)
2. 需要哪些内置 Tool?(默认:查用户信息、查角色、查菜单)
3. 是否开启历史消息?(默认开启,保留 20 轮)
依赖配置
# 核心依赖
pip install openai anthropic httpx sse-starlette
# 可选:Ollama 本地模型
pip install ollama
# 限流
pip install redis龟
# 加密
pip install cryptography
# 重试
pip install tenacity
# 工具
pip install pydantic pydantic-settings
配置
# config.py
from pydantic_settings import BaseSettings
from typing import Optional
class Settings(BaseSettings):
# ====== AI 模型配置 ======
ai_provider: str = "openai" # openai / claude / deepseek / ollama
# OpenAI
openai_api_key: str = ""
openai_base_url: str = "https://api.openai.com/v1"
openai_model: str = "gpt-4o-mini"
# Claude
anthropic_api_key: str = ""
anthropic_model: str = "claude-3-haiku-20240307"
# DeepSeek
deepseek_api_key: str = ""
deepseek_base_url: str = "https://api.deepseek.com/v1"
deepseek_model: str = "deepseek-chat"
# Ollama
ollama_base_url: str = "http://localhost:11434"
ollama_model: str = "llama3"
# ====== 会话配置 ======
chat_max_history: int = 20 # 保留轮数
chat_max_tokens: int = 4000
# ====== 限流配置 ======
rate_limit_enabled: bool = True
rate_limit_requests: int = 10 # 每分钟
rate_limit_window: int = 60 # 秒
# ====== 安全配置 ======
pii_encryption_key: str = "" # Fernet key
enable_audit: bool = True
# ====== Tool 白名单 ======
allowed_tools: list[str] = [
"get_user_info", "get_user_roles", "get_user_menus",
"search_users", "get_org_tree"
]
class Config:
env_file = ".env"
settings = Settings()
What ships with it
1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago Changed · +716 lines · +73 tokens per session 319e01032433
- 3mo ago First seen · 200 lines · 106 tokens per session scan A cc28afba0e45
fastapi-ai-chat-module-skill is a skill published in the GitHub repository jiushiwon/wg-skills (154 stars, last pushed 6d ago), licensed Apache-2.0. It adds 179 tokens to every session and 7,083 once invoked, about $0.0007 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
fastapi-ai-chat-module-skill compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| fastapi-ai-chat-module-skilljiushiwon/wg-skills | Skill | 154 | 6d ago | Apache-2.0 | A | 179 | Claude Code, Codex |
| open-sourcebrowser-use/browser-use | Skill | 122k | today | MIT | A | 101 | Claude Code |
| gemini-api-agent-platformdavila7/claude-code-templates | Skill | 35k | today | MIT | A | 61 | Claude Code, Codex |
| prowler-mcpprowler-cloud/prowler | Skill | 15k | today | Apache-2.0 | A | 67 | Claude Code |
| deepstream-sopNVIDIA/skills | Skill | 4.2k | today | Apache-2.0 | A | 219 | Claude Code |
| tao-run-inference-serviceNVIDIA/skills | Skill | 4.2k | today | Apache-2.0 | A | 92 | Claude Code |
| gemini-api-devgoogle-gemini/gemini-skills | Skill | 5.0k | 11d ago | Apache-2.0 | A | 96 | Claude Code |