मुख्य कंटेंट तक स्किप करें

AI सारांश

टेक्स्ट का संक्षिप्त सारांश बनाएँ और provider से क्रमिक परिणाम आते ही UI update करें।

आवश्यक शर्तें

  • AIBudsAISDK initialize हो और registered provider चुना गया हो।
  • Provider AISummaryServiceAPI support करता हो।
  • ज़रूरत पड़ने पर 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
import AIBudsAI

Declaration

Swift
/// 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()

summary और cancelSummary देखें।

उपयोग के उदाहरण

Swift
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()
        }
    }
}

जिस request का परिणाम अब नहीं चाहिए, उसे पूरा होने से पहले cancel करें:

Swift
AIBudsAISDK.cancelSummary()

ध्यान देने योग्य बातें

  • API केवल टेक्स्ट का सारांश बनाती है। यह file path नहीं लेती और maxLength parameter expose नहीं करती।
  • Provider बढ़ता हुआ सारांश क्रमशः लौटाता है, इसलिए हर नया transcript पहले दिखाए गए value को replace कर सकता है।
  • पहले transcript मिल चुका हो, फिर भी non-nil error को failure मानें।
  • cancelSummary() completion callback नहीं देता; cancel request भेजते समय application state update करें।