初始提交: Qihu-AIFlow v2.0.1 完整项目
- 前端 React+TypeScript (源码+构建产物) - 后端 Python FastAPI - 数据库迁移 001-015 - Docker部署配置 - 微信ClawBot API频道绑定 - 项目文档 README.md
This commit is contained in:
commit
78ff261b5a
199 files changed
+69126
No files matched your search
@@ -0,0 +1,540 @@
|
||||
// ===== AIFlow Type Definitions =====
|
||||
|
||||
// 用户
|
||||
export interface User {
|
||||
id: string;
|
||||
username: string;
|
||||
email: string;
|
||||
phone?: string;
|
||||
avatar?: string;
|
||||
role: 'user' | 'admin';
|
||||
status: 'active' | 'banned';
|
||||
realNameStatus?: 'unverified' | 'pending' | 'verified';
|
||||
realName?: string;
|
||||
idCard?: string;
|
||||
membership_level?: number;
|
||||
createdAt: string;
|
||||
membership?: UserMembership;
|
||||
}
|
||||
|
||||
export interface UserMembership {
|
||||
planId: string;
|
||||
planName: string;
|
||||
level: number;
|
||||
expireAt: string;
|
||||
autoRenew: boolean;
|
||||
}
|
||||
|
||||
// 注册方式设置
|
||||
export interface RegisterSettings {
|
||||
phoneRequired: boolean;
|
||||
phoneSmsRequired: boolean;
|
||||
emailRequired: boolean;
|
||||
emailVerifyRequired: boolean;
|
||||
realNameRequired: boolean;
|
||||
aliyunAccessKey?: string;
|
||||
aliyunSecretKey?: string;
|
||||
aliyunEndpoint?: string;
|
||||
smsSignName?: string;
|
||||
smsTemplateCode?: string;
|
||||
}
|
||||
|
||||
// 对话
|
||||
export interface Conversation {
|
||||
id: string;
|
||||
userId: string;
|
||||
title: string;
|
||||
modelId: string;
|
||||
status: 'active' | 'archived';
|
||||
pinned?: boolean;
|
||||
knowledgeGraphCount?: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
lastMessage?: string;
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
id: string;
|
||||
conversationId: string;
|
||||
role: 'user' | 'assistant' | 'system';
|
||||
content: string;
|
||||
tokenUsed: number;
|
||||
createdAt: string;
|
||||
used_skills?: string[];
|
||||
}
|
||||
|
||||
// 频道
|
||||
// IM账户绑定频道
|
||||
export type IMPlatform = 'feishu' | 'wechat' | 'dingtalk' | 'whatsapp' | 'telegram' | 'slack';
|
||||
|
||||
export interface Channel {
|
||||
id: string;
|
||||
userId: string;
|
||||
platform: IMPlatform;
|
||||
name: string;
|
||||
accountName: string;
|
||||
agentId?: string;
|
||||
knowledgeBaseId?: string;
|
||||
status: 'connected' | 'disconnected' | 'pending';
|
||||
lastActive?: string;
|
||||
boundModel: string;
|
||||
features: string[];
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
// 知识库
|
||||
export interface KnowledgeBase {
|
||||
id: string;
|
||||
userId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
documentCount: number;
|
||||
directoryPath: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface KnowledgeDocument {
|
||||
id: string;
|
||||
knowledgeBaseId: string;
|
||||
filename: string;
|
||||
fileType: string;
|
||||
fileSize: number;
|
||||
status: 'processing' | 'completed' | 'failed';
|
||||
chunkCount: number;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
// 应用市场
|
||||
export type AppType = 'skill' | 'agent' | 'mcp';
|
||||
|
||||
export interface MarketApp {
|
||||
id: string;
|
||||
name: string;
|
||||
type: AppType;
|
||||
source: 'official' | 'user';
|
||||
publisherId: string;
|
||||
publisherName: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
price: number;
|
||||
isMemberFree: boolean;
|
||||
joinPromotion: boolean;
|
||||
status: 'pending' | 'published' | 'removed';
|
||||
ratingAvg: number;
|
||||
reviewCount: number;
|
||||
installCount: number;
|
||||
installed?: boolean;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface AppReview {
|
||||
id: string;
|
||||
userId: string;
|
||||
userName: string;
|
||||
appId: string;
|
||||
rating: number;
|
||||
content: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
// Token
|
||||
export interface TokenUsageLog {
|
||||
id: string;
|
||||
userId: string;
|
||||
modelId: string;
|
||||
modelName: string;
|
||||
appId?: string;
|
||||
appName?: string;
|
||||
promptTokens: number;
|
||||
completionTokens: number;
|
||||
totalTokens: number;
|
||||
cost: number;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface TokenBalance {
|
||||
userId: string;
|
||||
totalConsumed: number;
|
||||
balance: number;
|
||||
}
|
||||
|
||||
// 订单
|
||||
export interface Order {
|
||||
id: string;
|
||||
userId: string;
|
||||
orderType: 'membership' | 'service' | 'app';
|
||||
itemName: string;
|
||||
amount: number;
|
||||
paymentMethod: 'wechat' | 'alipay';
|
||||
status: 'pending' | 'paid' | 'refunded';
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
// 会员
|
||||
export interface MembershipPlan {
|
||||
id: string;
|
||||
name: string;
|
||||
level: number;
|
||||
durationType: 'month' | 'quarter' | 'year';
|
||||
price: number;
|
||||
dailyFreeTokens: number;
|
||||
features: string[];
|
||||
freeAppIds?: string[];
|
||||
freeModelIds?: string[];
|
||||
}
|
||||
|
||||
// 优惠券
|
||||
export interface Coupon {
|
||||
id: string;
|
||||
code: string;
|
||||
type: 'fixed' | 'percent';
|
||||
value: number;
|
||||
minAmount: number;
|
||||
validFrom: string;
|
||||
validTo: string;
|
||||
status: 'active' | 'expired';
|
||||
}
|
||||
|
||||
export interface UserCoupon {
|
||||
id: string;
|
||||
userId: string;
|
||||
couponId: string;
|
||||
coupon: Coupon;
|
||||
status: 'unused' | 'used' | 'expired';
|
||||
}
|
||||
|
||||
// 通知
|
||||
export interface Notification {
|
||||
id: string;
|
||||
userId: string;
|
||||
type: 'announcement' | 'reminder' | 'renewal' | 'order' | 'update';
|
||||
title: string;
|
||||
content: string;
|
||||
isRead: boolean;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
// 后台
|
||||
export interface ModelProvider {
|
||||
id: string;
|
||||
name: string;
|
||||
protocol: string;
|
||||
apiKey: string;
|
||||
apiBaseUrl: string;
|
||||
createdAt: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface AIModel {
|
||||
id: string;
|
||||
providerId: string;
|
||||
providerName?: string;
|
||||
name: string;
|
||||
apiKey: string;
|
||||
endpoint: string;
|
||||
capabilities?: string[];
|
||||
timeout: number;
|
||||
status: 'free' | 'paid';
|
||||
pricePerMillionTokens: number;
|
||||
isEnabled: boolean;
|
||||
totalCalls?: number;
|
||||
totalTokens?: number;
|
||||
}
|
||||
|
||||
export interface ProtocolDef {
|
||||
id: string;
|
||||
name: string;
|
||||
base_path: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface FetchableModel {
|
||||
id: string;
|
||||
name: string;
|
||||
capabilities: string[];
|
||||
pricing: string;
|
||||
}
|
||||
|
||||
export interface SiteSettings {
|
||||
logo: string;
|
||||
siteName: string;
|
||||
announcement: string;
|
||||
icpNumber: string;
|
||||
contactEmail: string;
|
||||
contactPhone: string;
|
||||
}
|
||||
|
||||
export interface PaymentConfig {
|
||||
id: string;
|
||||
type: 'wechat' | 'alipay';
|
||||
app_id: string;
|
||||
merchant_id?: string;
|
||||
api_key: string;
|
||||
api_v3_key?: string;
|
||||
cert_path?: string;
|
||||
cert_serial_no?: string;
|
||||
gateway_url?: string;
|
||||
notify_url?: string;
|
||||
return_url?: string;
|
||||
app_private_key?: string;
|
||||
alipay_public_key?: string;
|
||||
status: 'active' | 'inactive';
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
// 日志
|
||||
export interface OperationLog {
|
||||
id: string;
|
||||
userId: string;
|
||||
username: string;
|
||||
action: string;
|
||||
target: string;
|
||||
detail: string;
|
||||
ip: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface AuditLog {
|
||||
id: string;
|
||||
adminId: string;
|
||||
adminName: string;
|
||||
action: string;
|
||||
targetType: string;
|
||||
targetId: string;
|
||||
detail: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
// 广告位
|
||||
export interface AdBanner {
|
||||
id: string;
|
||||
title: string;
|
||||
imageUrl: string;
|
||||
linkAppId?: string;
|
||||
linkAppName?: string;
|
||||
sortOrder: number;
|
||||
clickCount: number;
|
||||
status: 'active' | 'inactive';
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
// 风控
|
||||
export interface RiskRule {
|
||||
id: string;
|
||||
name: string;
|
||||
type: 'rate_limit' | 'ban' | 'alert';
|
||||
threshold: number;
|
||||
duration: number;
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
// 资产
|
||||
export type AssetFileType = 'word' | 'excel' | 'ppt' | 'pdf' | 'txt' | 'md' | 'doc' | 'other';
|
||||
export type AssetCategory = 'file' | 'novel' | 'image' | 'video' | 'audio' | 'other' | 'custom';
|
||||
|
||||
export interface AssetCategoryDef {
|
||||
id: string;
|
||||
name: string;
|
||||
type: AssetCategory;
|
||||
icon: string;
|
||||
color: string;
|
||||
isDefault: boolean;
|
||||
}
|
||||
|
||||
export interface NovelChapter {
|
||||
id: string;
|
||||
novelId: string;
|
||||
title: string;
|
||||
wordCount: number;
|
||||
sortOrder: number;
|
||||
content: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface NovelWorldView {
|
||||
summary: string;
|
||||
rules: string[];
|
||||
timeline: { era: string; events: string }[];
|
||||
}
|
||||
|
||||
export interface NovelCharacter {
|
||||
id: string;
|
||||
name: string;
|
||||
role: string;
|
||||
description: string;
|
||||
relationships: string[];
|
||||
}
|
||||
|
||||
export interface NovelMeta {
|
||||
hooks: string[];
|
||||
anchors: string[];
|
||||
worldView: NovelWorldView;
|
||||
characters: NovelCharacter[];
|
||||
}
|
||||
|
||||
export interface Asset {
|
||||
id: string;
|
||||
userId: string;
|
||||
name: string;
|
||||
category: AssetCategory;
|
||||
subCategory?: string;
|
||||
fileType?: AssetFileType;
|
||||
size?: number;
|
||||
description?: string;
|
||||
coverUrl?: string;
|
||||
novelMeta?: NovelMeta;
|
||||
chapters?: NovelChapter[];
|
||||
url: string;
|
||||
content?: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ===== AI Evolution Types =====
|
||||
|
||||
export type SkillState = 'baby' | 'main' | 'staging' | 'frozen';
|
||||
|
||||
export interface EvolutionSkill {
|
||||
id: string;
|
||||
skill_name: string;
|
||||
description: string;
|
||||
tags: string[];
|
||||
category: string;
|
||||
state: SkillState;
|
||||
use_count: number;
|
||||
version: number;
|
||||
last_used_at: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
skill_md_content?: string | null;
|
||||
}
|
||||
|
||||
export interface EvolutionEvent {
|
||||
id: string;
|
||||
skill_name: string;
|
||||
event_type: string;
|
||||
description: string;
|
||||
version_before: number | null;
|
||||
version_after: number | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface EvolutionTrajectory {
|
||||
id: string;
|
||||
conversation_id: string;
|
||||
file_path: string;
|
||||
status: string;
|
||||
atom_count: number;
|
||||
token_used: number;
|
||||
created_at: string;
|
||||
processed_at: string | null;
|
||||
}
|
||||
|
||||
export interface AbilityDimension {
|
||||
label: string;
|
||||
value: number;
|
||||
maxValue: number;
|
||||
}
|
||||
|
||||
export interface EvolutionProfile {
|
||||
level: number;
|
||||
level_title: string;
|
||||
total_skills: number;
|
||||
active_skills: number;
|
||||
staging_skills: number;
|
||||
baby_skills: number;
|
||||
total_use_count: number;
|
||||
dimensions: AbilityDimension[];
|
||||
tags: string[];
|
||||
growth_suggestions: string[];
|
||||
}
|
||||
|
||||
export interface SkillCategory {
|
||||
name: string;
|
||||
skills: EvolutionSkill[];
|
||||
}
|
||||
|
||||
export interface SkillTreeData {
|
||||
categories: SkillCategory[];
|
||||
total_count: number;
|
||||
main_count: number;
|
||||
baby_count: number;
|
||||
staging_count: number;
|
||||
frozen_count: number;
|
||||
}
|
||||
|
||||
export interface SkillUsageStat {
|
||||
skill_name: string;
|
||||
category: string;
|
||||
use_count: number;
|
||||
state: string;
|
||||
last_used_at: string | null;
|
||||
}
|
||||
|
||||
export interface CategoryDistribution {
|
||||
category: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface DailyTrend {
|
||||
date: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface StatisticsData {
|
||||
ranking: SkillUsageStat[];
|
||||
total_use_count: number;
|
||||
category_distribution: CategoryDistribution[];
|
||||
daily_trend: DailyTrend[];
|
||||
low_use_skills: EvolutionSkill[];
|
||||
}
|
||||
|
||||
// Evolution v2 types
|
||||
export interface VersionEntry {
|
||||
version: number;
|
||||
event_type: string;
|
||||
description: string;
|
||||
created_at: string;
|
||||
version_before?: number | null;
|
||||
version_after?: number | null;
|
||||
}
|
||||
|
||||
export interface PipelineStatus {
|
||||
scheduler_running: boolean;
|
||||
watcher_status: string;
|
||||
pipeline_status: string;
|
||||
discovered_count: number;
|
||||
done_count: number;
|
||||
total_skills: number;
|
||||
total_trajectories: number;
|
||||
}
|
||||
|
||||
export interface WatcherStatus {
|
||||
watcher_status: string;
|
||||
pipeline_status: string;
|
||||
pipeline_processed: number;
|
||||
watcher_error: string | null;
|
||||
scheduler_running: boolean;
|
||||
skill_count: number;
|
||||
trajectory_count: number;
|
||||
}
|
||||
|
||||
export interface EvolutionReport {
|
||||
id: string;
|
||||
report_type: 'weekly' | 'monthly';
|
||||
period_start: string;
|
||||
period_end: string;
|
||||
report_data: any;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface PublishRecord {
|
||||
id: string;
|
||||
skill_name: string;
|
||||
market_app_id: string;
|
||||
price: number;
|
||||
status: string;
|
||||
published_at: string;
|
||||
}
|
||||
Reference in new issue
Block a user