99 lines
2.6 KiB
TypeScript
99 lines
2.6 KiB
TypeScript
|
|
/**
|
|||
|
|
* 会话与线索 API 骨架(Phase 3 Task 3)
|
|||
|
|
*
|
|||
|
|
* 端点事实源:app/platform/routes/data_routes.py
|
|||
|
|
* (会话列表/详情/删除、推送日志)。本文件只建类型与端点常量——
|
|||
|
|
* 调用函数在 Task 5(会话与线索)实装。
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
/** 意向层级(Evaluation.intent_level) */
|
|||
|
|
export type IntentLevel = 'high' | 'medium' | 'low' | 'none' | null
|
|||
|
|
|
|||
|
|
/** 联系方式(评估产出) */
|
|||
|
|
export interface ContactInfo {
|
|||
|
|
email?: string | null
|
|||
|
|
whatsapp?: string | null
|
|||
|
|
phone?: string | null
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** 会话列表行(GET /api/platform/tenants/{slug}/conversations) */
|
|||
|
|
export interface ConversationListItem {
|
|||
|
|
id: string
|
|||
|
|
session_id: string
|
|||
|
|
status: string
|
|||
|
|
source: string
|
|||
|
|
site: string | null
|
|||
|
|
ip: string
|
|||
|
|
device: string
|
|||
|
|
country: string | null
|
|||
|
|
intent_level: IntentLevel
|
|||
|
|
reasoning: string | null
|
|||
|
|
contact_info: ContactInfo | null
|
|||
|
|
email_sent: boolean
|
|||
|
|
message_count: number
|
|||
|
|
preview: string
|
|||
|
|
created_at: string | null
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** 会话列表查询参数(intent 白名单校验在后端;from/to 为闭区间日期) */
|
|||
|
|
export interface ConversationListParams {
|
|||
|
|
intent?: string
|
|||
|
|
site?: string
|
|||
|
|
from?: string
|
|||
|
|
to?: string
|
|||
|
|
page?: number
|
|||
|
|
page_size?: number
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** 会话列表响应 */
|
|||
|
|
export interface ConversationListResponse {
|
|||
|
|
total: number
|
|||
|
|
page: number
|
|||
|
|
page_size: number
|
|||
|
|
items: ConversationListItem[]
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** 会话详情消息行(时间升序) */
|
|||
|
|
export interface ConversationMessage {
|
|||
|
|
role: 'user' | 'assistant' | 'system' | string
|
|||
|
|
content: string
|
|||
|
|
created_at: string | null
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** 会话详情响应(GET .../conversations/{convId}) */
|
|||
|
|
export interface ConversationDetailResponse extends ConversationListItem {
|
|||
|
|
client_info: Record<string, unknown>
|
|||
|
|
messages: ConversationMessage[]
|
|||
|
|
profile: {
|
|||
|
|
chips: Record<string, unknown>
|
|||
|
|
summary: string | null
|
|||
|
|
} | null
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** 推送日志行(GET .../push-logs) */
|
|||
|
|
export interface PushLogItem {
|
|||
|
|
id: number
|
|||
|
|
conversation_id: string
|
|||
|
|
status: string
|
|||
|
|
error: string | null
|
|||
|
|
created_at: string | null
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** 推送日志响应 */
|
|||
|
|
export interface PushLogResponse {
|
|||
|
|
total: number
|
|||
|
|
page: number
|
|||
|
|
page_size: number
|
|||
|
|
items: PushLogItem[]
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** 会话与线索端点 */
|
|||
|
|
export const CONVERSATION_ENDPOINTS = {
|
|||
|
|
list: (slug: string) => `/api/platform/tenants/${slug}/conversations`,
|
|||
|
|
detail: (slug: string, convId: string) =>
|
|||
|
|
`/api/platform/tenants/${slug}/conversations/${convId}`,
|
|||
|
|
remove: (slug: string, convId: string) =>
|
|||
|
|
`/api/platform/tenants/${slug}/conversations/${convId}`,
|
|||
|
|
pushLogs: (slug: string) => `/api/platform/tenants/${slug}/push-logs`
|
|||
|
|
} as const
|