import request from '/@/utils/request';

// 提示词管理接口类型
export interface PromptItem {
	id: number | string;
	tenantId?: number;
	creator?: string;
	createdAt?: string;
	updater?: string;
	updatedAt?: string;
	deletedAt?: string | null;
	nodeType: string;
	prompt: string;
	sourceType: number; // 0-自定义 1-公共
}

export interface PromptListResponse {
	list: PromptItem[];
	total: number;
}

export interface PromptListParams {
	pageNum?: number;
	pageSize?: number;
	keyword?: string;
	nodeType?: string;
}

export interface CreatePromptParams {
	nodeType: string;
	prompt: string;
	sourceType: number;
}

export interface UpdatePromptParams extends CreatePromptParams {
	id: number | string;
}

// 节点库项接口类型
export interface NodeLibraryNode {
	nodeId: string;
	nodeCode: string;
	modelType: number;
	nodeName: string;
	skillOption: boolean;
	promptOption: boolean;
}

export interface NodeLibraryGroup {
	group: string;
	label: string;
	items: NodeLibraryNode[];
}

export interface NodeLibraryResponse {
	groups: NodeLibraryGroup[];
}

/**
 * 获取节点类型列表（节点库）
 */
export function getNodeLibraryList() {
	return request<NodeLibraryResponse>({
		url: '/ai-agent/node/library/list',
		method: 'get',
	});
}

/**
 * 获取提示词列表（根据节点类型）
 */
export function getPromptList(params: PromptListParams) {
	return request<PromptListResponse>({
		url: '/ai-agent/node/prompt/list',
		method: 'get',
		params,
	});
}

/**
 * 获取当前用户提示词列表
 */
export function getMyPromptList(params: PromptListParams) {
	return request<PromptListResponse>({
		url: '/ai-agent/node/prompt/listMy',
		method: 'get',
		params,
	});
}

/**
 * 创建提示词
 */
export function createPrompt(data: CreatePromptParams) {
	return request({
		url: '/ai-agent/node/prompt/create',
		method: 'post',
		data,
	});
}

/**
 * 修改提示词
 */
export function updatePrompt(data: UpdatePromptParams) {
	return request({
		url: '/ai-agent/node/prompt/update',
		method: 'put',
		data,
	});
}

/**
 * 删除提示词
 */
export function deletePrompt(id: number | string) {
	return request({
		url: '/ai-agent/node/prompt/delete',
		method: 'delete',
		data: { id },
	});
}
