| 1 | /* |
| 2 | * Copyright 2024 KylinSoft Co., Ltd. |
| 3 | * |
| 4 | * This program is free software: you can redistribute it and/or modify it under |
| 5 | * the terms of the GNU General Public License as published by the Free Software |
| 6 | * Foundation, either version 3 of the License, or (at your option) any later |
| 7 | * version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 12 | * details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #ifndef __KYLIN_AI_GEN_AI_TEXT_CHAT_H__ |
| 19 | #define __KYLIN_AI_GEN_AI_TEXT_CHAT_H__cxx . . $ `include/kylin-ai/genai/text/chat.h:19:9`! |
| 20 | |
| 21 | #include <common/macros.h> |
| 22 | |
| 23 | #include "chatmessage.h"cxx . . $ `<file>/include/kylin-ai/genai/text/chatmessage.h`/ |
| 24 | #include "config.h"cxx . . $ `<file>/include/kylin-ai/genai/text/config.h`/ |
| 25 | #include "result.h"cxx . . $ `<file>/include/kylin-ai/genai/text/result.h`/ |
| 26 | |
| 27 | #ifdef __cpluspluscxx . . $ `<built-in>:470:9`! |
| 28 | extern "C" { |
| 29 | #endif |
| 30 | |
| 31 | typedef enum { |
| 32 | TEXT_EXPANSION = 1, |
| 33 | TEXT_POLISHING = 2, |
| 34 | TRANSLATE_CHINESE_TO_ENGLISH = 3, |
| 35 | TEXT_ERROR_CORRECTION = 8, |
| 36 | SUMMARY = 9, |
| 37 | EMAIL_REPLY = 10, |
| 38 | WORK_SUMMARY = 11, |
| 39 | TAG_EXTRACTION = 12, |
| 40 | } PromptId; |
| 41 | |
| 42 | typedef struct _GenAiTextSessioncxx . . $ _GenAiTextSession# GenAiTextSession; |
| 43 | |
| 44 | typedef void (*ChatResultCallback)(ChatResult *chat_result, void *user_data); |
| 45 | |
| 46 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 47 | GenAiTextSession *genai_text_create_session(); |
| 48 | |
| 49 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 50 | void genai_text_destroy_session(GenAiTextSession **session); |
| 51 | |
| 52 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 53 | int genai_text_init_session(GenAiTextSession *session); |
| 54 | |
| 55 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 56 | void genai_text_result_set_callback(GenAiTextSession *session, |
| 57 | ChatResultCallback callback, |
| 58 | void *user_data); |
| 59 | |
| 60 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 61 | void genai_text_set_model_config(GenAiTextSession *session, |
| 62 | ChatModelConfig *config); |
| 63 | |
| 64 | // 根据提示进行文本生成补全 |
| 65 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 66 | void genai_text_generate_content_async(GenAiTextSession *session, |
| 67 | const char *prompt); |
| 68 | |
| 69 | // 进行对话,支持缓存上下文 |
| 70 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 71 | void genai_text_chat_async(GenAiTextSession *session, const char *question); |
| 72 | |
| 73 | // 进行对话,需要传入历史消息 |
| 74 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 75 | void genai_text_chat_with_history_messages_async(GenAiTextSession *session, |
| 76 | ChatMessage *history_messages); |
| 77 | |
| 78 | // 设置对话提示词 |
| 79 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 80 | void genai_text_set_chat_system_prompt(GenAiTextSession *session, |
| 81 | const char *prompt); |
| 82 | |
| 83 | // 设置对话的提示词,使用SDK内置的提示词 |
| 84 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 85 | void genai_text_set_chat_system_prompt_id(GenAiTextSession *session, |
| 86 | PromptId prompt_id); |
| 87 | |
| 88 | // 清除对话上下文 |
| 89 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 90 | void genai_text_clear_chat_history_messages(GenAiTextSession *session); |
| 91 | |
| 92 | AISDK_EXTERNcxx . . $ `<external>/16012735566347328758/macros.h:21:9`! |
| 93 | void genai_text_stop_chat(GenAiTextSession *session); |
| 94 | |
| 95 | #ifdef __cpluspluscxx . . $ `<built-in>:470:9`! |
| 96 | } |
| 97 | #endif |
| 98 | |
| 99 | #endif // __KYLIN_AI_GEN_AI_TEXT_CHAT_H__ |