Files
keyboard/keyBoard/Class/AiTalk/VM/LLMStreamClient.h

49 lines
1.1 KiB
Objective-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.

//
// LLMStreamClient.h
// keyBoard
//
// Created by Mac on 2026/1/15.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// LLM 流式生成客户端代理
@protocol LLMStreamClientDelegate <NSObject>
@required
/// 收到新的 token
- (void)llmClientDidReceiveToken:(NSString *)token;
/// 生成完成
- (void)llmClientDidComplete;
/// 生成失败
- (void)llmClientDidFail:(NSError *)error;
@end
/// LLM 流式生成客户端
/// 支持 SSEServer-Sent Events或 WebSocket 接收 token 流
@interface LLMStreamClient : NSObject
@property(nonatomic, weak) id<LLMStreamClientDelegate> delegate;
/// LLM 服务器 URL
@property(nonatomic, copy) NSString *serverURL;
/// API Key如需要
@property(nonatomic, copy, nullable) NSString *apiKey;
/// 是否正在生成
@property(nonatomic, assign, readonly, getter=isGenerating) BOOL generating;
/// 发送用户文本请求 LLM 回复
/// @param text 用户输入的文本
/// @param conversationId 对话 ID
- (void)sendUserText:(NSString *)text conversationId:(NSString *)conversationId;
/// 取消当前请求
- (void)cancel;
@end
NS_ASSUME_NONNULL_END