处理流逝返回
处理粘贴
This commit is contained in:
@@ -290,9 +290,10 @@
|
||||
}
|
||||
NSInteger resolvedCharacterId = (characterId > 0) ? characterId : 75;
|
||||
NSString *message = seedTitle.length > 0 ? seedTitle : @"aliqua non cupidatat";
|
||||
// message = [NSString stringWithFormat:@"%@%d",message,arc4random() % 10000];
|
||||
NSDictionary *payload = @{
|
||||
@"characterId": @(resolvedCharacterId),
|
||||
@"message": @"dolore ea cillum"
|
||||
@"message": message
|
||||
};
|
||||
NSLog(@"[KBFunction] request payload: %@", payload);
|
||||
NSError *bodyError = nil;
|
||||
@@ -399,13 +400,15 @@
|
||||
- (NSString *)kb_normalizedLLMChunkString:(id)dataValue {
|
||||
if (![dataValue isKindOfClass:[NSString class]]) { return @""; }
|
||||
NSString *text = (NSString *)dataValue;
|
||||
|
||||
// 1. 处理上一个包遗留的 <SPLIT> 前缀(比如 "<SP" + "LIT>")
|
||||
if (self.eventSourceSplitPrefix.length > 0) {
|
||||
text = [self.eventSourceSplitPrefix stringByAppendingString:text ?: @""];
|
||||
self.eventSourceSplitPrefix = nil;
|
||||
}
|
||||
text = [text stringByReplacingOccurrencesOfString:@"\r\n\t" withString:@"\t"];
|
||||
text = [text stringByReplacingOccurrencesOfString:@"\n\t" withString:@"\t"];
|
||||
text = [text stringByReplacingOccurrencesOfString:@"\r\t" withString:@"\t"];
|
||||
if (text.length == 0) { return @""; }
|
||||
|
||||
// 2. 去掉开头多余换行(避免一开始就空一大块)
|
||||
while (text.length > 0) {
|
||||
unichar c0 = [text characterAtIndex:0];
|
||||
if (c0 == '\n' || c0 == '\r') {
|
||||
@@ -414,17 +417,24 @@
|
||||
}
|
||||
break;
|
||||
}
|
||||
text = [text stringByReplacingOccurrencesOfString:@"/t" withString:@"\t"];
|
||||
text = [text stringByReplacingOccurrencesOfString:@"<SPLIT>" withString:@"\t"];
|
||||
if (text.length == 0) { return @""; }
|
||||
|
||||
// 3. 处理结尾可能是不完整的 "<SPLIT" 之类,先截掉,放到下一个包里拼
|
||||
NSString *suffix = [self kb_pendingSplitSuffixForString:text];
|
||||
if (suffix.length > 0) {
|
||||
self.eventSourceSplitPrefix = suffix;
|
||||
text = [text substringToIndex:text.length - suffix.length];
|
||||
}
|
||||
text = [text stringByReplacingOccurrencesOfString:@"\t " withString:@"\t"];
|
||||
if (text.length == 0) { return @""; }
|
||||
|
||||
// 4. 处理完整的 <SPLIT>,变成段落分隔符 \t
|
||||
text = [text stringByReplacingOccurrencesOfString:@"<SPLIT>" withString:@"\t"];
|
||||
|
||||
// 不再做其它替换,不合并 /t、不改行,只把真正内容原样丢给 UI
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
- (NSString *)kb_formattedSearchResultString:(id)dataValue {
|
||||
// data 不是数组就直接返回空串
|
||||
if (![dataValue isKindOfClass:[NSArray class]]) { return @""; }
|
||||
@@ -570,12 +580,18 @@
|
||||
// });
|
||||
// return;
|
||||
}
|
||||
|
||||
BOOL hasPasteText = ![self.pasteView.pasBtn.currentTitle isEqualToString:KBLocalized(@" Paste Ta's Words")];
|
||||
// BOOL hasPasteText = (self.pasteView.pasBtn.imageView.image == nil);
|
||||
if (!hasPasteText) {
|
||||
[KBHUD showInfo:KBLocalized(@"Please copy the text first")];
|
||||
return;
|
||||
}
|
||||
NSString *copyTitle = self.pasteView.pasBtn.currentTitle;
|
||||
// 3) 已登录:开始业务逻辑(展示加载并拉取流式内容)
|
||||
[self.tagListView setLoading:YES atIndex:index];
|
||||
self.loadingTagIndex = @(index);
|
||||
self.loadingTagTitle = title ?: @"";
|
||||
[self kb_startNetworkStreamingWithSeed:self.loadingTagTitle];
|
||||
[self kb_startNetworkStreamingWithSeed:copyTitle];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -652,11 +668,11 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C
|
||||
}
|
||||
|
||||
// 1)把内容真正「粘贴」到当前输入框
|
||||
UIInputViewController *ivc = KBFindInputViewController(self);
|
||||
if (ivc) {
|
||||
id<UITextDocumentProxy> proxy = ivc.textDocumentProxy;
|
||||
[proxy insertText:text];
|
||||
}
|
||||
// UIInputViewController *ivc = KBFindInputViewController(self);
|
||||
// if (ivc) {
|
||||
// id<UITextDocumentProxy> proxy = ivc.textDocumentProxy;
|
||||
// [proxy insertText:text];
|
||||
// }
|
||||
|
||||
// 2)顺便把最新的剪贴板内容展示在左侧粘贴区按钮上,便于用户确认
|
||||
[self kb_updatePasteButtonWithDisplayText:text];
|
||||
|
||||
Reference in New Issue
Block a user