Fix streaming and file IO edge cases

Repair streaming callback/error handling and make file/session handling safer so the core API behaves correctly under real usage.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 19:26:47 +08:00
parent c9fb924a1c
commit 16475ca3fe
7 changed files with 132 additions and 36 deletions

View File

@@ -29,7 +29,7 @@ DSTALK_API void dstalk_set_model(const char* model);
/* 同步对话: 发送 input返回完整 AI 回复 (调用方通过 dstalk_free_string 释放) */
DSTALK_API int dstalk_chat(const char* input, char** output);
/* 流式对话: 每收到一个 token 调用回调,回调返回 0 可提前取消 */
/* 流式对话: 每收到一个 token 调用回调,回调返回 0 继续,非 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);