49 lines
1.1 KiB
Objective-C
49 lines
1.1 KiB
Objective-C
//
|
||
// 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 流式生成客户端
|
||
/// 支持 SSE(Server-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
|