Skip to content

Commit 27e772c

Browse files
committed
2 parents 89a74b1 + cc32df1 commit 27e772c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Sources/CoreMI/Intramodular/Service/_MIServiceTypeIdentifier.swift

+1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ extension _MIServiceTypeIdentifier {
3232
public static let _OpenAI = _MIServiceTypeIdentifier(rawValue: "vodih-vakam-hiduz-tosob")
3333
public static let _Perplexity = _MIServiceTypeIdentifier(rawValue: "dohug-muboz-bopuz-kasar")
3434
public static let _Replicate = _MIServiceTypeIdentifier(rawValue: "dovon-vatig-posov-luvis")
35+
public static let _ElevenLabs = _MIServiceTypeIdentifier(rawValue: "jatap-jogaz-ritiz-vibok")
3536
}

Sources/ElevenLabs/Intramodular/ElevenLabs.Client.swift

+22
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import NetworkKit
99

1010

1111
extension ElevenLabs {
12+
@RuntimeDiscoverable
1213
public final class Client: ObservableObject {
14+
public static var persistentTypeRepresentation: some IdentityRepresentation {
15+
_MIServiceTypeIdentifier._ElevenLabs
16+
}
1317

1418
public struct Configuration {
1519
public var apiKey: String?
@@ -32,6 +36,24 @@ extension ElevenLabs {
3236
}
3337
}
3438

39+
extension ElevenLabs.Client: _MIService {
40+
public convenience init(
41+
account: (any _MIServiceAccount)?
42+
) async throws {
43+
let account = try account.unwrap()
44+
45+
guard account.serviceIdentifier == _MIServiceTypeIdentifier._ElevenLabs else {
46+
throw _MIServiceError.serviceTypeIncompatible(account.serviceIdentifier)
47+
}
48+
49+
guard let credential = account.credential as? _MIServiceAPIKeyCredential else {
50+
throw _MIServiceError.invalidCredentials(account.credential)
51+
}
52+
53+
self.init(apiKey: credential.apiKey)
54+
}
55+
}
56+
3557
extension ElevenLabs.Client {
3658
public func availableVoices() async throws -> [ElevenLabs.Voice] {
3759
let request = HTTPRequest(url: URL(string: "\(apiSpecification)/v1/voices")!)

0 commit comments

Comments
 (0)