AI Özetleme
Metinden kısa bir özet oluşturun ve seçilen servis sağlayıcı parça parça sonuç döndürdükçe arayüzü güncelleyin.
Ön Koşullar
AIBudsAISDKbaşlatılmış ve kayıtlı bir servis sağlayıcı seçilmiştir.- Servis sağlayıcı
AISummaryServiceAPIdesteği sunar. - Gerektiğinde servis sağlayıcı kimlik doğrulaması ve ağ erişimi kullanılabilir.
- Giriş metni boş değildir.
AI desteğiyle uygulayın
AI ile geliştirin
Bu iş akışını AI ile uygulayın
Resmî “AIBuds AI Özetini Uygulama” becerisini kullanarak iş akışını uygulamanıza uyarlayın.
https://docs-aibuds.github.io/tr/skills/implement-aibuds-ai-summary adresini okuyup yönergeleri izleyin. Bu beceriyle “AIBuds AI Özetini Uygulama” iş akışını iOS projesinde uygulayıp doğrulayın.API Reference
Framework
AIBudsAI.xcframework
Import
- Swift
- Objective-C
import AIBudsAI#import <AIBudsAI/AIBudsAI-Swift.h>Declaration
- Swift
- Objective-C
/// Generates a concise summary for the provided text.
/// - Parameters:
/// - text: The text to summarize.
/// - streamResultHandler: Called repeatedly with the current summary.
/// - isFinal: `true` when the summary is complete; otherwise `false`.
/// - transcript: The current incremental summary text.
/// - error: The operation error, or `nil` when no error occurred.
public static func summary(withText text: String,
streamResultHandler: ((_ isFinal: Bool, _ transcript: String?, _ error: Error?) -> Void)? = nil)
/// Cancels the current summary operation before it completes.
public static func cancelSummary()/// Generates a concise summary for the provided text.
/// - Parameters:
/// - text: The text to summarize.
/// - streamResultHandler: Called repeatedly with the current summary.
/// - isFinal: `YES` when the summary is complete; otherwise `NO`.
/// - transcript: The current incremental summary text.
/// - error: The operation error, or `nil` when no error occurred.
+ (void)summaryWithText:(NSString * _Nonnull)text
streamResultHandler:(void (^ _Nullable)(BOOL, NSString * _Nullable, NSError * _Nullable))streamResultHandler;
/// Cancels the current summary operation before it completes.
+ (void)cancelSummary;summary ve cancelSummary başvurularına bakın.
Kullanım Örnekleri
- Swift
- Objective-C
let sourceText = """
The AIBuds SDK connects supported devices to an iOS application and exposes
device control, media, AI, voice assistant, and diagnostic capabilities.
"""
AIBudsAISDK.summary(withText: sourceText) { isFinal, transcript, error in
DispatchQueue.main.async {
if let error {
summaryLabel.text = "Summary failed: \(error.localizedDescription)"
return
}
if let transcript {
summaryLabel.text = transcript
}
if isFinal {
summaryActivityIndicator.stopAnimating()
}
}
}NSString *sourceText = @"The AIBuds SDK connects supported devices to an iOS application and "
"exposes device control, media, AI, voice assistant, and diagnostic "
"capabilities.";
[AIBudsAISDK summaryWithText:sourceText
streamResultHandler:^(BOOL isFinal, NSString *transcript, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error != nil) {
self.summaryLabel.text = [NSString
stringWithFormat:@"Summary failed: %@", error.localizedDescription];
return;
}
if (transcript != nil) {
self.summaryLabel.text = transcript;
}
if (isFinal) {
[self.summaryActivityIndicator stopAnimating];
}
});
}];Sonucu artık gerekmeyen devam eden isteği iptal edin:
- Swift
- Objective-C
AIBudsAISDK.cancelSummary()[AIBudsAISDK cancelSummary];Notlar
- API yalnızca metni özetler. Dosya yolu kabul etmez ve
maxLengthparametresi sunmaz. - Servis sağlayıcı giderek büyüyen bir özet döndürdüğü için her döküm daha önce gösterilen değerin yerini alabilir.
- Daha önce döküm alınmış olsa bile
nilolmayan hatayı başarısızlık sayın. cancelSummary()tamamlanma geri çağrısı sağlamaz; iptal istendiğinde uygulama durumunu güncelleyin.