Enhance AI and Redis integration for smoke logging features
- Added AI configuration options to .env.example and config.go for OpenAI integration. - Implemented Redis caching for session management in main.go and auth middleware. - Updated smoke logging service to support real smoking time (`smoke_at`) and AI advice retrieval. - Enhanced API routes to include endpoints for AI advice and unlock functionality for non-members. - Improved database schema with new tables for AI advice and unlock records. - Expanded documentation to cover new AI features and Redis caching implementation.
This commit is contained in:
@@ -17,6 +17,16 @@ SHORT_VIDEO_API_KEY=replace-with-real-key
|
||||
SHORT_VIDEO_FREE_QUOTA=20
|
||||
SHORT_VIDEO_TIMEOUT_SECONDS=5
|
||||
|
||||
# AI 配置(OpenAI-compatible)
|
||||
# 例:OpenAI = https://api.openai.com/v1
|
||||
AI_BASE_URL=https://api.openai.com/v1
|
||||
AI_API_KEY=replace-with-ai-api-key
|
||||
AI_MODEL=gpt-4o-mini
|
||||
AI_TIMEOUT_SECONDS=15
|
||||
|
||||
# 简易后台接口鉴权(用于生成兑换码等)
|
||||
ADMIN_API_TOKEN=replace-with-strong-random-token
|
||||
|
||||
# 七牛直传配置(Kodo)
|
||||
QINIU_ACCESS_KEY=replace-with-access-key
|
||||
QINIU_SECRET_KEY=replace-with-secret-key
|
||||
@@ -34,3 +44,11 @@ QINIU_TOKEN_EXPIRE_SECONDS=300
|
||||
WECHAT_OA_APP_ID=replace-with-oa-appid
|
||||
WECHAT_OA_APP_SECRET=replace-with-oa-appsecret
|
||||
WECHAT_OA_TIMEOUT_SECONDS=5
|
||||
|
||||
# Redis(可选,用于缓存 session_key -> user)
|
||||
# 不配置 REDIS_ADDR 时,程序会自动禁用 Redis,保持原来每次请求查 MySQL 的方式。
|
||||
REDIS_ADDR=127.0.0.1:6379
|
||||
REDIS_PASSWORD=
|
||||
REDIS_DB=0
|
||||
REDIS_KEY_PREFIX=wx_service:
|
||||
REDIS_SESSION_TTL_SECONDS=86400
|
||||
|
||||
Reference in New Issue
Block a user