import "../base.api"

type (
    // The data of chat records information | ChatRecords信息
    ChatRecordsInfo {
        BaseIDInfo

        // 内容 
        Content  *string `json:"content,optional"`

        // 内容类型:1-提问 2-回答 
        ContentType  *uint8 `json:"contentType,optional"`

        // 角色类型:1-用户 2-智能体
        RoleType  *string `json:"roleType,optional"`

        // 会话ID 
        SessionId  *uint64 `json:"sessionId,optional"`

        // 用户ID 
        UserId  *uint64 `json:"userId,optional"`

        // 聊天ID 
        BotId  *uint64 `json:"botId,optional"`

        // 类型:1-微信 2-小程序card 3-智能体 
        BotType  *uint8 `json:"botType,optional,options=1|2|3"`

		Finish bool `json:"finish,optional"`
    }

    // The response data of chat records list | ChatRecords列表数据
    ChatRecordsListResp {
        BaseDataInfo

        // ChatRecords list data | ChatRecords列表数据
        Data ChatRecordsListInfo `json:"data"`
    }

    // ChatRecords list data | ChatRecords列表数据
    ChatRecordsListInfo {
        BaseListInfo

        // The API list data | ChatRecords列表数据
        Data  []ChatRecordsInfo  `json:"data"`
    }

    // Get chat records list request params | ChatRecords列表请求参数
    ChatRecordsListReq {
        PageInfo

        SessionId  *uint64 `json:"sessionId"`
		BotId *uint64 `json:"botId,optional"`
		BotType *uint8  `json:"botType,optional"`
    }

    // ChatRecords information response | ChatRecords信息返回体
    ChatRecordsInfoResp {
        BaseDataInfo

        // ChatRecords information | ChatRecords数据
        Data ChatRecordsInfo `json:"data"`
    }

	ChatRecommendReq {
		SessionId  *uint64 `json:"sessionId"`
	}

	ChatRecommendResp {
		BaseDataInfo

		// The API list data | ChatRecords列表数据
		Data  ChatRecommend  `json:"data"`
	}

	ChatRecommend {
		Data []string `json:"data"`
		SessionId uint64 `json:"sessionId"`
	}

	ChatAskReq {
		CardId *uint64 `json:"cardId"`
		Question *string `json:"question"`
		SessionId *int `json:"sessionId"`
	}

	ChatAskResp {
		BaseDataInfo
		Data *string `json:"data"`
	}

	GptChatReq{
		ConversationId *string `json:"conversationId,optional"`
		Content *string `json:"content"`
		AgentId *uint64 `json:"agentId"`
	}
	GptMessageReq {
		ConversationId *string `json:"conversationId,optional"`
		FirstId *string `json:"firstId,optional"`
		Limit *int `json:"limit"`
		AgentId *uint64 `json:"agentId"`
	}
	GptMessageResp {
		BaseDataInfo
		Data GptMessageList `json:"data"`
	}
	GptMessageList {
		HasMore bool `json:"hasMore"`
		Data []Message  `json:"data"`
	}
	Message {
		Id *string `json:"id"`
		ConversationId *string `json:"conversationId,optional"`
		Query *string `json:"query"`
		Answer *string `json:"answer"`
		Inputs interface{} `json:"inputs"`
		CreatedAt *int `json:"createdAt"`
	}
	GptsSessionReq {
		Limit *int `json:"limit"`
		LastId *string `json:"lastId,optional"`
		AgentId *uint64 `json:"agentId"`
	}
	GptsSessionResp {
		BaseDataInfo
		Data GptsSessionList `json:"data"`
	}
	GptsSessionList {
		HasMore bool `json:"hasMore"`
		Data []Session `json:"data"`
	}
	Session {
		Id *string `json:"id"`
		Name *string `json:"name"`
		CreatedAt *int `json:"createdAt"`
		Inputs interface{} `json:"inputs"`
	}

	GptsDeleteSessionReq {
		AgentId *uint64 `json:"agentId"`
		ConversationId *string `json:"conversationId"`
	}
	GptsRenameSessionReq {
		AgentId *uint64 `json:"agentId"`
		ConversationId *string `json:"conversationId"`
		Name *string `json:"name"`
	}
)

@server(
	group: chatrecords
)

service Wechat {
	// Create chat records information | 创建ChatRecords
	@handler gptsSubmitApiChat
	post /gpts/chat/submit (GptChatReq)

	// Get chat message list | 获取聊天历史
	@handler gptsGetApiMessage
	post /gpts/chat/message (GptMessageReq) returns (GptMessageResp)

	// Get chat session list | 获取会话列表
	@handler gptsGetApiSession
	post /gpts/chat/session (GptsSessionReq) returns (GptsSessionResp)

	// Create chat records information | 创建ChatRecords
	@handler gptsDeleteApiSession
	post /gpts/chat/session/delete (GptsDeleteSessionReq) returns (BaseMsgResp)

	// Create chat records information | 创建ChatRecords
	@handler gptsRenameApiSession
	post /gpts/chat/session/rename (GptsRenameSessionReq) returns (BaseMsgResp)
}

@server(
	jwt: Auth
	group: chatrecords
	middleware: Miniprogram
)

service Wechat {
	// Create chat records information | 创建ChatRecords
	@handler submitApiChat
	post /api/chat/create (ChatRecordsInfo)

	// Create chat records information | 创建ChatRecords
	@handler answerApiChat
	post /api/chat/answer (ChatAskReq) returns (ChatAskResp)

	// Get chat records list | 获取ChatRecords列表
	@handler getApiChatList
	post /api/chat/list (ChatRecordsListReq) returns (ChatRecordsListResp)

	// Get chat records list | 获取ChatRecords列表
	@handler getApiRecommendChat
	post /api/chat/recommmend (ChatRecommendReq) returns (ChatRecommendResp)
}

@server(
    jwt: Auth
    group: chatrecords
    middleware: Authority
)

service Wechat {
    // Create chat records information | 创建ChatRecords
    @handler createChatRecords
    post /chat_records/create (ChatRecordsInfo) returns (BaseMsgResp)

    // Update chat records information | 更新ChatRecords
    @handler updateChatRecords
    post /chat_records/update (ChatRecordsInfo) returns (BaseMsgResp)

    // Delete chat records information | 删除ChatRecords信息
    @handler deleteChatRecords
    post /chat_records/delete (IDsReq) returns (BaseMsgResp)

    // Get chat records list | 获取ChatRecords列表
    @handler getChatRecordsList
    post /chat_records/list (ChatRecordsListReq) returns (ChatRecordsListResp)

    // Get chat records by ID | 通过ID获取ChatRecords
    @handler getChatRecordsById
    post /chat_records (IDReq) returns (ChatRecordsInfoResp)
}