Skip to content

ArsLinear/reminderapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

日程/待办解析中间层

输入自然语言、群通知、邮件或公告文本,服务调用 DeepSeek 解析并返回干净 JSON,供 iPhone Shortcuts 创建 Apple Calendar/Reminders。服务器直接操作 Apple 日历或提醒事项。

快速启动

  1. 准备环境变量:
cp .env.example .env

.env 中填入:

  • DEEPSEEK_API_KEY(必填)
  • DEEPSEEK_BASE_URL(默认:https://api.deepseek.com)
  • DEEPSEEK_MODEL(默认:deepseek-v4-pro)
  • DEEPSEEK_DISABLE_THINKING(默认:true)
  • DEFAULT_TZ(默认:Asia/Shanghai)
  • API_KEY(可选,设置后需在请求头传入 X-API-Key
  1. 启动服务:
docker compose up --build

默认地址:http://localhost:8000

公网访问(可选)

如需从外网(如 iPhone Shortcuts)访问本地服务,推荐使用 Cloudflare Tunnel:

  1. 在 Cloudflare Zero Trust 中创建 Tunnel,获取 token
  2. docker-compose.yml 中添加 cloudflared sidecar 容器:
  reminder-cloudflared:
    image: cloudflare/cloudflared:latest
    restart: unless-stopped
    command: tunnel --no-autoupdate run
    environment:
      - TUNNEL_TOKEN=<your-tunnel-token>
    depends_on:
      - reminderapi
  1. docker compose up -d 启动后,通过 Cloudflare 分配的域名即可访问 /parse 接口。

接口

POST /parse

请求体支持两种格式:

  1. text/plain(推荐)
  2. application/json{"text": "..."}

示例:

curl -X POST http://localhost:8000/parse \
  -H 'Content-Type: text/plain' \
  --data '明天下午三点交材料'

或:

curl -X POST http://localhost:8000/parse \
  -H 'Content-Type: application/json' \
  --data '{"text":"下周五上午十点组会"}'

服务会自动注入当前时间与时区(DEFAULT_TZ),用于解析“明天/下周”等相对时间。

返回结构

成功示例:

{
  "ok": true,
  "need_confirm": false,
  "question": "",
  "items": [
    {
      "type": "calendar",
      "title": "组会",
      "start": "2026-05-23T10:00:00+08:00",
      "end": "2026-05-23T11:00:00+08:00",
      "alert_minutes": 30
    }
  ]
}

信息不足示例:

{
  "ok": false,
  "need_confirm": true,
  "question": "这条通知没有明确截止时间,需要创建提醒吗?",
  "items": []
}

校验规则(服务端)

  • type 只能是 calendarreminder
  • calendar 必须有 titlestartend
  • reminder 必须有 titledue
  • 时间必须是 ISO 8601(包含时区)
  • end 必须晚于 start
  • title 不能为空
  • API 最多返回 3 个 items — 长文本中若包含更多事件,仅提取最核心的前 3 个
  • 模型输出不合法时,返回 ok=false 与简短 question

调整返回数量上限

限制由两处控制,修改后重启服务即可:

  1. SYSTEM_PROMPT(第 37 行):提示词第 7 条 "默认最多 3 个 items",将数字改大以告知模型输出更多条目。
  2. normalize_items 截断(第 102 行)raw_items[:3] 切片,改为目标上限(如 raw_items[:5])。

增大上限意味着返回体更大、模型解析可能变慢,建议根据实际场景控制在 5 以内。

iPhone Shortcuts 调用建议

使用“获取 URL 内容(Get Contents of URL)”:

  • 方法:POST
  • URL:http://<你的服务器>:8000/parse
  • 请求体:原始文本(Text)
  • Content-Type:text/plain
  • 返回解析:按 JSON 读取 okitems 并创建日历或提醒事项

About

自建日程解析服务。可以调用大语言模型对日程/通知信息进行清洗,返回结构化数据以便于输入电子日历。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors