Files
dstalk/dstalk-core/include/dstalk/dstalk_api.h
未知时光 c9fb924a1c Initial dstalk project: core DLL + CLI + BearSSL TLS
- Core DLL: AI API client (DeepSeek/OpenAI compatible), HTTP(S) via Boost.Beast
- BearSSL vendored as TLS backend (MIT license, replacing OpenSSL)
- CLI frontend with ANSI colors, /help /model /file /save /load commands
- WinHTTP alternative HTTP client for Windows
- GPLv3 license with linking exception
- Build: CMake + Ninja + Clang, dependencies via Conan2

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 16:42:42 +08:00

53 lines
1.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef DSTALK_API_H
#define DSTALK_API_H
#ifdef __cplusplus
extern "C" {
#endif
/* ---- DLL 导出 / 导入宏 ---- */
#if defined(_WIN32)
#ifdef DSTALK_BUILD_DLL
#define DSTALK_API __declspec(dllexport)
#else
#define DSTALK_API __declspec(dllimport)
#endif
#else
#define DSTALK_API __attribute__((visibility("default")))
#endif
/* ---- 初始化和配置 ---- */
DSTALK_API int dstalk_init(const char* config_path);
DSTALK_API void dstalk_destroy(void);
/* 在 init 之后可修改 API 参数 (init 也会从配置文件读取) */
DSTALK_API void dstalk_set_api_key(const char* api_key);
DSTALK_API void dstalk_set_base_url(const char* base_url);
DSTALK_API void dstalk_set_model(const char* model);
/* ---- AI 对话 ---- */
/* 同步对话: 发送 input返回完整 AI 回复 (调用方通过 dstalk_free_string 释放) */
DSTALK_API int dstalk_chat(const char* input, char** output);
/* 流式对话: 每收到一个 token 调用回调,回调返回 0 可提前取消 */
typedef int (*dstalk_stream_cb)(const char* token, void* userdata);
DSTALK_API int dstalk_chat_stream(const char* input, dstalk_stream_cb cb, void* userdata);
/* 释放由 dstalk_chat / dstalk_file_read 分配的字符串 */
DSTALK_API void dstalk_free_string(char* str);
/* ---- 会话管理 ---- */
DSTALK_API void dstalk_session_clear(void); /* 清空对话历史 */
DSTALK_API int dstalk_session_save(const char* path); /* 保存会话到文件 */
DSTALK_API int dstalk_session_load(const char* path); /* 从文件恢复会话 */
/* ---- 文件操作 ---- */
DSTALK_API int dstalk_file_read(const char* path, char** content);
DSTALK_API int dstalk_file_write(const char* path, const char* content);
#ifdef __cplusplus
}
#endif
#endif /* DSTALK_API_H */