AI Servis Sağlayıcısı Seçme
Uygulamanızın içerdiği AI servis sağlayıcı SDK'larını kaydedin, ardından sonraki AI işlemlerinde AIBudsAISDK tarafından kullanılacak sağlayıcıyı seçin.
Ön Koşullar
- Temel AIBuds SDK başlatılmıştır.
- Uygulama en az bir servis sağlayıcı SDK'sını kurmuş ve bağlamıştır.
- Seçilen sağlayıcı
AIBudsAISDK.initialize(_:)öğesine verilen dizide bulunur. - Sağlayıcı kimlik doğrulamasından veya aygıta bağlı AI işlemlerinden önce aygıt bilgileri yapılandırılmıştır.
AI desteğiyle uygulayın
Bu iş akışını AI ile uygulayın
Resmî “AIBuds AI Sağlayıcısı Seçme” becerisini kullanarak iş akışını uygulamanıza uyarlayın.
https://docs-aibuds.github.io/tr/skills/select-aibuds-ai-provider adresini okuyup yönergeleri izleyin. Bu beceriyle “AIBuds AI Sağlayıcısı Seçme” iş akışını iOS projesinde uygulayıp doğrulayın.API Reference
Framework
AIBudsAI.xcframework
Servis sağlayıcı uygulamaları, AIBudsStarBurst.xcframework ve AIBudsMagicHelper.xcframework dahil ayrı dağıtılır.
Import
- Swift
- Objective-C
import AIBudsAI
import AIBudsAIFoundation
import AIBudsStarBurst
import AIBudsMagicHelper#import <AIBudsAI/AIBudsAI-Swift.h>
#import <AIBudsMagicHelper/AIBudsMagicHelper-Swift.h>
#import <AIBudsStarBurst/AIBudsStarBurst-Swift.h>Declaration
Servis sağlayıcı yaşam döngüsünü AIBudsAISDK yönetir. Sağlayıcı uygulamaları AIConnectSDK protokolüne uyar.
- Swift
- Objective-C
/// 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/// 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: `YES` when initialization succeeds; otherwise `NO`.
+ (BOOL)initWithAISDKs:(NSArray<id <AIBudsAIConnectSDK>> * _Nonnull)aiSDKs;
/// The current AI service vendor.
@property(nonatomic, class, readonly) AIBudsAIServiceVendor aiServiceVendor;
/// 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.
+ (void)setAIServiceVendor:(enum AIBudsAIServiceVendor)aiServiceVendor;
/// 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
/// `AIBudsAIServiceVendorNone` or its provider SDK is not registered.
+ (NSArray<AIBudsAIServiceLanguage *> * _Nonnull)allSupportedLanguagesForVendor:(enum AIBudsAIServiceVendor)vendor;
/// Returns the authentication initiation mode for the specified vendor.
/// - Parameter vendor: The vendor whose authentication mode is requested.
/// - Returns: The provider authentication mode.
+ (enum AIBudsAIAuthenticationMode)authenticationModeForVendor:(enum AIBudsAIServiceVendor)vendor;
/// Indicates whether the device is authenticated for the specified vendor.
/// - Parameter vendor: The vendor whose authentication state is requested.
/// - Returns: `YES` when the provider reports an authenticated device.
+ (BOOL)isAuthenticatedForVendor:(enum AIBudsAIServiceVendor)vendor;AI Servis Sağlayıcıları
| Swift | Objective-C | Açıklama |
|---|---|---|
.none | AIBudsAIServiceVendorNone | Servis sağlayıcı seçilmemiştir. Varsayılan durumdur. |
.starBurst | AIBudsAIServiceVendorStarBurst | StarBurst AI (ByteDance hizmeti). |
.mltcloud | AIBudsAIServiceVendorMltcloud | MltCloud AI (Meilc hizmeti). |
Yetkili enum tanımı için AIServiceVendor başvurusuna bakın.
Kullanım Örnekleri
Servis Sağlayıcı SDK'larını Kaydetme
Servis sağlayıcı kaydı normalde uygulama başlatılırken bir kez yapılır.
- Swift
- Objective-C
import AIBudsAI
import AIBudsStarBurst
import AIBudsMagicHelper
let initialized = AIBudsAISDK.initialize([
StarBurstSDK.shared,
MagicHelperSDK.shared,
])
guard initialized else {
print("AIBudsAISDK initialization failed")
return
}#import <AIBudsAI/AIBudsAI-Swift.h>
#import <AIBudsMagicHelper/AIBudsMagicHelper-Swift.h>
#import <AIBudsStarBurst/AIBudsStarBurst-Swift.h>
BOOL initialized = [AIBudsAISDK initWithAISDKs:@[
[AIBudsStarBurstSDK shared],
[AIBudsMagicHelperSDK shared],
]];
if (!initialized) {
NSLog(@"AIBudsAISDK initialization failed");
return;
}Uygulamanız AIBudsAllInOneSDK kullanıyorsa başlatma işlemi paketle gelen AI sağlayıcılarını kurabilir. AIBudsAISDK'yi ikinci kez başlatmayın.
Servis Sağlayıcı Seçme
- Swift
- Objective-C
let vendor: AIServiceVendor = .starBurst
AIBudsAISDK.setAIServiceVendor(vendor)
print("Selected provider: \(AIBudsAISDK.aiServiceVendor)")
print("Supported languages: \(AIBudsAISDK.allSupportedLanguages(for: vendor))")AIBudsAIServiceVendor vendor = AIBudsAIServiceVendorStarBurst;
[AIBudsAISDK setAIServiceVendor:vendor];
NSLog(@"Selected provider: %ld", (long)AIBudsAISDK.aiServiceVendor);
NSLog(@"Supported languages: %@", [AIBudsAISDK allSupportedLanguagesForVendor:vendor]);Kimlik Doğrulama Gereksinimlerini Denetleme
Bağlı aygıtın AI bilgilerini yapılandırdıktan sonra modu uygulama tarafından başlatılan sağlayıcılarda kimlik doğrulayın.
- Swift
- Objective-C
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")
}
}AIBudsAIServiceVendor vendor = AIBudsAISDK.aiServiceVendor;
if ([AIBudsAISDK authenticationModeForVendor:vendor] == AIBudsAIAuthenticationModeAppInitiated &&
![AIBudsAISDK isAuthenticatedForVendor:vendor]) {
[AIBudsAISDK
authenticateDevice:deviceInfo
completion:^(BOOL success, NSError *error) {
if (!success) {
NSLog(@"%@", error.localizedDescription ?: @"Authentication failed");
return;
}
NSLog(@"AI provider authenticated");
}];
}Notlar
setAIServiceVendor(_:)servis sağlayıcı SDK'sını kaydetmez veya kurmaz..noneseçmek, AI hizmetine bağlı işlemleri kullanılabilir sağlayıcısız bırakır.initialize(_:)birden fazla çağrılırsafalsedöndürür ve mevcut başlatmayı korur.- Yinelenen uygulamalar aynı sağlayıcı enum değerini bildirirse ilk kaydedilen uygulama korunur.
- Desteklenen özellikler ve diller servis sağlayıcılara göre değişebilir.