AI सारांश
टेक्स्ट का संक्षिप्त सारांश बनाएँ और provider से क्रमिक परिणाम आते ही UI update करें।
आवश्यक शर्तें
AIBudsAISDKinitialize हो और registered provider चुना गया हो।- Provider
AISummaryServiceAPIsupport करता हो। - ज़रूरत पड़ने पर provider authentication और network access उपलब्ध हों।
- Input text खाली न हो।
AI की सहायता से लागू करें
AI से बनाएँ
इस वर्कफ़्लो को AI से लागू करें
आधिकारिक “AIBuds AI सारांश लागू करें” स्किल से वर्कफ़्लो को अपने ऐप के अनुसार लागू करें।
https://docs-aibuds.github.io/hi/skills/implement-aibuds-ai-summary को पढ़ें और निर्देशों का पालन करें। इस स्किल से “AIBuds AI सारांश लागू करें” को इस iOS प्रोजेक्ट में लागू करें और परिणाम सत्यापित करें।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 और cancelSummary देखें।
उपयोग के उदाहरण
- 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];
}
});
}];जिस request का परिणाम अब नहीं चाहिए, उसे पूरा होने से पहले cancel करें:
- Swift
- Objective-C
AIBudsAISDK.cancelSummary()[AIBudsAISDK cancelSummary];ध्यान देने योग्य बातें
- API केवल टेक्स्ट का सारांश बनाती है। यह file path नहीं लेती और
maxLengthparameter expose नहीं करती। - Provider बढ़ता हुआ सारांश क्रमशः लौटाता है, इसलिए हर नया transcript पहले दिखाए गए value को replace कर सकता है।
- पहले transcript मिल चुका हो, फिर भी non-
nilerror को failure मानें। cancelSummary()completion callback नहीं देता; cancel request भेजते समय application state update करें।