/* * Copyright 2024 KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ #ifndef __KYLIN_AI_GEN_AI_TEXT_CHAT_H__ #define __KYLIN_AI_GEN_AI_TEXT_CHAT_H__ #include #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__