package cn.com.poc.agent_application.aggregate;

import cn.com.poc.agent_application.entity.AgentResultEntity;
import cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity;
import cn.com.poc.agent_application.entity.CreateAgentTitleAndDescEntity;
import cn.com.poc.agent_application.entity.KnowledgeSuperclassProblemConfig;
import cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeSearchTypeEnum;
import cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Message;
import cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool;
import cn.com.poc.thirdparty.resource.demand.ai.entity.function.FunctionCallResult;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

public interface AgentApplicationService {

    /**
     * 创建/更新应用
     *
     * @param entity 应用信息
     */
    BizAgentApplicationInfoEntity saveOrUpdate(BizAgentApplicationInfoEntity entity) throws Exception;


    /**
     * 更新并发布应用
     *
     * @param entity 应用信息
     */
    boolean updateAndPublish(BizAgentApplicationInfoEntity entity) throws Exception;

    /**
     * 删除Agent应用
     *
     * @param agentId 应用ID
     */
    boolean deletedAgentApplication(String agentId) throws Exception;

    /**
     * Agent应用对话
     *
     * @param agentId                 应用ID
     * @param identifier              对话唯一标识
     * @param largeModel              模型
     * @param agentSystem             应用角色指令
     * @param knowledgeIds            知识库ID
     * @param databaseIds             数据库ID
     * @param communicationTurn       对话轮数
     * @param topP                    模型参数topP
     * @param temperature             模型参数temperature
     * @param messages                对话消息
     * @param tools                   插件配置
     * @param functionCallResult      插件回调结果
     * @param stream                  是否流式传输
     * @param score                   知识库参数score
     * @param topK                    知识库参数topK
     * @param knowledgeSearchType     知识库参数知识搜索类型
     * @param superclassProblemConfig 知识库参数超级类问题配置
     */
    AgentResultEntity callAgentApplication(String agentId, String identifier, String largeModel, String agentSystem,
                                           Integer[] knowledgeIds, Integer[] databaseIds, Integer communicationTurn, Float topP, Float temperature,
                                           List<Message> messages, List<Tool> tools, FunctionCallResult functionCallResult,  boolean stream,
                                           Double score, Integer topK, KnowledgeSearchTypeEnum knowledgeSearchType, KnowledgeSuperclassProblemConfig superclassProblemConfig, HttpServletResponse httpServletResponse) throws Exception;


    /**
     * 应用下架
     *
     * @param agentId 应用ID
     * @return
     */
    boolean unPublish(String agentId) throws Exception;

    /**
     * 角色指令AI生成
     *
     * @param input                   用户输入内容
     * @param optimizationSuggestions 优化建议
     * @param httpServletResponse
     * @return
     */
    void createAgentSystem(String input, String optimizationSuggestions, HttpServletResponse httpServletResponse) throws Exception;

    /**
     * 开场白AI生成
     *
     * @param agentTitle  应用标题
     * @param agentDesc   应用描述
     * @param agentSystem 应用角色指令
     * @return
     */
    String createPreamble(String agentTitle, String agentDesc, String agentSystem);


    /**
     * 推荐问题AI生成
     *
     * @param agentTitle
     * @param agentDesc
     * @return
     * @throws Exception
     */
    List<String> createFeaturedQuestions(String agentTitle, String agentDesc);

    /**
     * AGENT 应用图标生成
     *
     * @param agentTitle 应用标题
     * @param agentDesc  应用描述
     * @return Agent 应用图标URL
     */
    String createAgentIcon(String agentTitle, String agentDesc) throws Exception;

    /**
     * Agent 应用标题，描述生成
     *
     * @param input 用户输入内容
     */
    CreateAgentTitleAndDescEntity createAgentTitleAndDesc(String input);

    /**
     * 收藏/取消收藏应用广场中的应用
     *
     * @param id      应用广场的应用id
     * @param agentId Agent应用id
     */
    void collectOrCancelAgentInMall(Integer id, String agentId) throws Exception;

    /**
     * 收藏/取消收藏个人空间中的应用
     *
     * @param agentId Agent应用id
     */
    void collectOrCancelAgentInPerson(String agentId) throws Exception;

    /**
     * 判断用户是否拥有该应用权限
     *
     * @param agentId  应用id
     * @param memberId 用户id
     */
    boolean hasPublishAgentPermission(String agentId, Long memberId);

    /**
     * 编辑器编辑功能
     *
     * @param agentGcConfigCode
     * @param articleContent
     * @param editorRequired
     * @param httpServletResponse
     * @return
     * @throws Exception
     */
    String editorFunction(String agentGcConfigCode, String articleContent, String editorRequired, HttpServletResponse httpServletResponse) throws Exception;


}
