Logo Fastapi Notification Module Skill

Fastapi Notification Module Skill

Cộng đồng
jiushiwon
fastapi-notification-module-skill

Python FastAPI 通知模块技能。面向已有 FastAPI 项目的开发者,提供短信发送、邮件推送、站内消息、推送通知等能力的快速集成。触发词:"短信验证码"、"发送短信"、"发送邮件"、"站内消息"、"通知模块"、"sms"、"email"、"mail"、"notification"。

Tổng quan

Nhà phát hànhjiushiwon
Kho mãwg-skills
Tên kỹ năngfastapi-notification-module-skill
Sao
123
Bản fork
38
Tệp đi kèm
1
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 1 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được jiushiwon công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Fastapi Notification Module Skill trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/python/fastapi-module/fastapi-notification-module-skill
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jiushiwon/wg-skills.git /tmp/wg-skills
mkdir -p .claude/skills
cp -r /tmp/wg-skills/vibeCoding/backend/python/fastapi-module/fastapi-notification-module-skill .claude/skills/fastapi-notification-module-skill
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Fastapi Notification Module Skill trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Fastapi Notification Module Skill ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Fastapi Notification Module Skill với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

FastAPI Notification Module Skill

面向已有 FastAPI 项目的开发者,快速集成通知能力。

能力清单

能力说明
短信发送验证码/通知短信
邮件推送HTML/文本邮件/模板邮件
站内消息系统通知/未读消息
推送通知极光/FCM
消息模板模板管理和渲染

触发场景

用户说"帮我加短信"或"集成通知"时触发。

核心实现

依赖配置

bash
# 短信
pip install aliyun-python-sdk-core

# 邮件
pip install aiosmtpd jinja2

# 站内消息
pip install redis

配置

python
# config.py
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    # 短信配置
    sms_access_key: str = ""
    sms_secret_key: str = ""
    sms_sign_name: str = ""
    sms_template_code: str = ""
    
    # 邮件配置
    mail_host: str = "smtp.qq.com"
    mail_port: int = 587
    mail_username: str = ""
    mail_password: str = ""
    
    # Redis 配置
    redis_host: str = "localhost"
    redis_port: int = 6379

数据模型

python
# models.py
from sqlalchemy import Column, BigInteger, String, Text, Integer, DateTime, Enum as SQLEnum
from database import Base
import enum

class NotificationType(str, enum.Enum):
    SYSTEM = "system"
    SMS = "sms"
    EMAIL = "email"
    PUSH = "push"

class Notification(Base):
    __tablename__ = "wg_notification"
    
    id = Column(BigInteger, primary_key=True, autoincrement=True)
    user_id = Column(String(50), nullable=False, index=True)
    title = Column(String(200), nullable=False)
    content = Column(Text, nullable=False)
    type = Column(SQLEnum(NotificationType), default=NotificationType.SYSTEM)
    link = Column(String(500))
    is_read = Column(Integer, default=0)
    created_at = Column(DateTime, server_default=func.now())

class SmsCode(Base):
    __tablename__ = "wg_sms_code"
    
    id = Column(BigInteger, primary_key=True, autoincrement=True)
    phone = Column(String(20), nullable=False, index=True)
    code = Column(String(10), nullable=False)
    template_code = Column(String(50))
    expire_time = Column(DateTime)
    used = Column(Integer, default=0)
    created_at = Column(DateTime, server_default=func.now())

服务层

python
# services/notification_service.py
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest
import random
import string
import redis

class NotificationService:
    def __init__(self):
        self.sms_client = AcsClient(
            settings.sms_access_key,
            settings.sms_secret_key,
            'cn-hangzhou'
        )
        self.redis = redis.Redis(
            host=settings.redis_host,
            port=settings.redis_port,
            decode_responses=True
        )
    
    # 短信验证码
    async def send_sms_code(self, phone: str, template_code: str = None):
        code = ''.join(random.choices(string.digits, k=6))
        
        # 调用短信API
        request = CommonRequest()
        request.set_accept_format('json')
        request.set_domain('dysmsapi.aliyuncs.com')
        request.set_method('POST')
        request.set_protocol_type('https')
        request.set_version('2017-05-25')
        request.set_action_name('SendSms')
        
        request.add_query_param('PhoneNumbers', phone)
        request.add_query_param('SignName', settings.sms_sign_name)
        request.add_query_param('TemplateCode', template_code or settings.sms_template_code)
        request.add_query_param('TemplateParam', f'{{"code":"{code}"}}')
        
        response = self.sms_client.do_action_with_exception(request)
        
        # 保存验证码到 Redis
        key = f"sms:code:{phone}"
        self.redis.setex(key, 300, code)  # 5分钟过期
        
        return code
    
    async def verify_sms_code(self, phone: str, code: str) -> bool:
        key = f"sms:code:{phone}"
        saved_code = self.redis.get(key)
        if saved_code == code:
            self.redis.delete(key)
            return True
        return False
    
    # 发送邮件
    async def send_email(self, to: str, subject: str, content: str):
        import aiosmtplib
        from email.mime.text import MIMEText
        
        msg = MIMEText(content, 'html', 'utf-8')
        msg['Subject'] = subject
        msg['From'] = settings.mail_username
        msg['To'] = to
        
        await aiosmtplib.send(
            msg,
            hostname=settings.mail_host,
            port=settings.mail_port,
            username=settings.mail_username,
            password=settings.mail_password,
            use_tls=True
        )
    
    # 站内消息
    async def send_notification(
        self,
        user_id: str,
        title: str,
        content: str,
        notification_type: NotificationType = NotificationType.SYSTEM,
        link: str = None
    ):
        notification = Notification(
            user_id=user_id,
            title=title,
            content=content,
            type=notification_type,
            link=link
        )
        db.add(notification)
        db.commit()
        
        # Redis 推送
        self.redis.publish(f"notification:{user_id}", json.dumps({
            "title": title,
            "content": content,
            "type": notification_type.value
        }))
        
        return notification
    
    # 获取未读消息
    async def get_unread_notifications(self, user_id: str) -> List[Notification]:
        return db.query(Notification).filter(
            Notification.user_id == user_id,
            Notification.is_read == 0
        ).order_by(Notification.created_at.desc()).all()

API 路由

python
# routers/notification.py
from fastapi import APIRouter, Depends

router = APIRouter(prefix="/api/notification", tags=["通知"])

@router.post("/sms/send")
async def send_sms(phone: str):
    await notification_service.send_sms_code(phone)
    return ApiResponse.ok(None)

@router.post("/sms/verify")
async def verify_sms(phone: str, code: str):
    valid = await notification_service.verify_sms_code(phone, code)
    return ApiResponse.ok(valid)

@router.post("/email/send")
async def send_email(to: str, subject: str, content: str):
    await notification_service.send_email(to, subject, content)
    return ApiResponse.ok(None)

@router.post("/send")
async def send_notification(
    user_id: str,
    title: str,
    content: str,
    notification_type: NotificationType = NotificationType.SYSTEM
):
    await notification_service.send_notification(user_id, title, content, notification_type)
    return ApiResponse.ok(None)

@router.get("/unread")
async def get_unread(user_id: str):
    notifications = await notification_service.get_unread_notifications(user_id)
    return ApiResponse.ok(notifications)

不做

  • 不负责短信/邮件服务商账号配置
  • 不处理复杂的推送策略
  • 不提供 UI 相关代码

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Fastapi Notification Module Skill làm được gì?

Python FastAPI 通知模块技能。面向已有 FastAPI 项目的开发者,提供短信发送、邮件推送、站内消息、推送通知等能力的快速集成。触发词:"短信验证码"、"发送短信"、"发送邮件"、"站内消息"、"通知模块"、"sms"、"email"、"mail"、"notification"。

Vì sao nên dùng Fastapi Notification Module Skill trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Fastapi Notification Module Skill là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Fastapi Notification Module Skill trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/python/fastapi-module/fastapi-notification-module-skill. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Fastapi Notification Module Skill?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Fastapi Notification Module Skill với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Fastapi Notification Module Skill với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Fastapi Notification Module Skill có miễn phí không?

Có. Kỹ năng này được jiushiwon phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇