#ifndef __KYLIN_AI_GEN_AI_TEXT_CHAT_H__
#define __KYLIN_AI_GEN_AI_TEXT_CHAT_H__

#include <common/macros.h>

#include "chatmessage.h"
#include "config.h"
#include "result.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
    TEXT_EXPANSION = 1,
    TEXT_POLISHING = 2,
    TRANSLATE_CHINESE_TO_ENGLISH = 3,
    TEXT_ERROR_CORRECTION = 8,
    SUMMARY = 9,
    EMAIL_REPLY = 10,
    WORK_SUMMARY = 11,
    TAG_EXTRACTION = 12,
} PromptId;

typedef struct _GenAiTextSession GenAiTextSession;

typedef void (*ChatResultCallback)(ChatResult *chat_result, void *user_data);

AISDK_EXTERN
GenAiTextSession *genai_text_create_session();

AISDK_EXTERN
void genai_text_destroy_session(GenAiTextSession **session);

AISDK_EXTERN
int genai_text_init_session(GenAiTextSession *session);

AISDK_EXTERN
void genai_text_result_set_callback(GenAiTextSession *session,
                                    ChatResultCallback callback,
                                    void *user_data);

AISDK_EXTERN
void genai_text_set_model_config(GenAiTextSession *session,
                                 ChatModelConfig *config);

// 根据提示进行文本生成补全
AISDK_EXTERN
void genai_text_generate_content_async(GenAiTextSession *session,
                                       const char *prompt);

// 进行对话，支持缓存上下文
AISDK_EXTERN
void genai_text_chat_async(GenAiTextSession *session, const char *question);

// 进行对话，需要传入历史消息
AISDK_EXTERN
void genai_text_chat_with_history_messages_async(GenAiTextSession *session,
                                                 ChatMessage *history_messages);

// 设置对话提示词
AISDK_EXTERN
void genai_text_set_chat_system_prompt(GenAiTextSession *session,
                                       const char *prompt);

// 设置对话的提示词，使用SDK内置的提示词
AISDK_EXTERN
void genai_text_set_chat_system_prompt_id(GenAiTextSession *session,
                                          PromptId prompt_id);

// 清除对话上下文
AISDK_EXTERN
void genai_text_clear_chat_history_messages(GenAiTextSession *session);

AISDK_EXTERN
void genai_text_stop_chat(GenAiTextSession *session);

#ifdef __cplusplus
}
#endif

#endif  // __KYLIN_AI_GEN_AI_TEXT_CHAT_H__
