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

AI सेवा प्रदाता चुनें

App में शामिल AI provider SDKs register करें, फिर आगे के AI operations के लिए AIBudsAISDK द्वारा उपयोग किया जाने वाला provider चुनें।

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

  • Base AIBuds SDK initialize हो।
  • App में कम से कम एक provider SDK install और link हो।
  • चुना गया provider AIBudsAISDK.initialize(_:) को दिए array में शामिल हो।
  • Provider authentication या device-dependent AI operations से पहले device information configure हो।

AI की सहायता से लागू करें

AI से बनाएँ

इस वर्कफ़्लो को AI से लागू करें

आधिकारिक “AIBuds AI प्रदाता चुनें” स्किल से वर्कफ़्लो को अपने ऐप के अनुसार लागू करें।

https://docs-aibuds.github.io/hi/skills/select-aibuds-ai-provider को पढ़ें और निर्देशों का पालन करें। इस स्किल से “AIBuds AI प्रदाता चुनें” को इस iOS प्रोजेक्ट में लागू करें और परिणाम सत्यापित करें।
आधिकारिक स्किल देखें

API Reference

Framework

AIBudsAI.xcframework

Provider implementations अलग वितरित होते हैं, जिनमें AIBudsStarBurst.xcframework और AIBudsMagicHelper.xcframework शामिल हैं।

Import

Swift
import AIBudsAI
import AIBudsAIFoundation
import AIBudsStarBurst
import AIBudsMagicHelper

Declaration

Provider lifecycle AIBudsAISDK संभालता है। Provider implementations AIConnectSDK को conform करते हैं।

Swift
/// Initializes the SDK with the specified provider implementations.
/// - Parameter aiSDKs: The providers to register. Their order determines
///   recognition priority; a later provider using an already-registered
///   Bluetooth data protocol type is ignored.
/// - Returns: `true` when initialization succeeds; otherwise `false`.
public static func initialize( _ aiSDKs: [AIConnectSDK] ) -> Bool

/// The current AI service vendor.
static var aiServiceVendor: AIServiceVendor { get }

/// Sets the AI service vendor for the SDK.
/// - Parameter aiServiceVendor: The vendor used by subsequent AI services.
/// - Important: Call this method before using AI service-dependent functionality.
public static func setAIServiceVendor(_ aiServiceVendor: AIServiceVendor) -> Void

/// Returns all languages supported by the specified vendor.
/// - Parameter vendor: The vendor whose languages are requested.
/// - Returns: Supported languages, or an empty array when the vendor is `.none`
///   or its provider SDK is not registered.
public static func allSupportedLanguages(for vendor: AIServiceVendor) -> [AIServiceLanguage]

/// Returns the authentication initiation mode for the specified vendor.
/// - Parameter vendor: The vendor whose authentication mode is requested.
/// - Returns: The provider authentication mode.
public static func authenticationMode(for vendor: AIServiceVendor) -> AIAuthenticationMode

/// Indicates whether the device is authenticated for the specified vendor.
/// - Parameter vendor: The vendor whose authentication state is requested.
/// - Returns: `true` when the provider reports an authenticated device.
public static func isAuthenticated(for vendor: AIServiceVendor) -> Bool

AI सेवा प्रदाता

SwiftObjective-Cविवरण
.noneAIBudsAIServiceVendorNoneकोई provider नहीं चुना गया। यह default state है।
.starBurstAIBudsAIServiceVendorStarBurstStarBurst AI (ByteDance)।
.mltcloudAIBudsAIServiceVendorMltcloudMltCloud AI (Meilc)।

Authoritative enumeration के लिए AIServiceVendor देखें।

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

Provider SDKs register करें

Provider registration आमतौर पर app startup पर एक बार होता है।

Swift
import AIBudsAI
import AIBudsStarBurst
import AIBudsMagicHelper

let initialized = AIBudsAISDK.initialize([
    StarBurstSDK.shared,
    MagicHelperSDK.shared,
])

guard initialized else {
    print("AIBudsAISDK initialization failed")
    return
}

App AIBudsAllInOneSDK उपयोग करता हो तो उसका initialization bundled AI providers install कर सकता है। AIBudsAISDK को दूसरी बार initialize न करें।

Provider चुनें

Swift
let vendor: AIServiceVendor = .starBurst
AIBudsAISDK.setAIServiceVendor(vendor)

print("Selected provider: \(AIBudsAISDK.aiServiceVendor)")
print("Supported languages: \(AIBudsAISDK.allSupportedLanguages(for: vendor))")

Authentication आवश्यकताएँ जाँचें

जुड़े डिवाइस की AI information configure करने के बाद उन providers को authenticate करें जिनका mode app-initiated है।

Swift
let vendor = AIBudsAISDK.aiServiceVendor

if AIBudsAISDK.authenticationMode(for: vendor) == .appInitiated,
    !AIBudsAISDK.isAuthenticated(for: vendor)
{
    AIBudsAISDK.authenticateDevice(deviceInfo) { success, error in
        guard success else {
            print(error?.localizedDescription ?? "Authentication failed")
            return
        }
        print("AI provider authenticated")
    }
}

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

  • setAIServiceVendor(_:) provider SDK को register या install नहीं करता।
  • .none चुनने पर AI service पर निर्भर operations के लिए usable provider नहीं रहता।
  • initialize(_:) को एक से अधिक बार call करने पर false लौटता है और मौजूदा initialization बना रहता है।
  • Duplicate implementations समान provider enum value दें तो पहले registered implementation को रखा जाता है।
  • Supported features और languages providers के बीच अलग हो सकती हैं।