-
Notifications
You must be signed in to change notification settings - Fork 1
/
coord.go
47 lines (35 loc) · 1.1 KB
/
coord.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package coord
import (
"context"
"errors"
"github.com/lemon-mint/coord/pconf"
"github.com/lemon-mint/coord/provider"
)
var ErrNoSuchProvider = errors.New("coord: no such provider")
func NewLLMClient(ctx context.Context, provider string, configs ...pconf.Config) (provider.LLMClient, error) {
llmProvidersMu.RLock()
defer llmProvidersMu.RUnlock()
driver, ok := llmProviders[provider]
if !ok {
return nil, ErrNoSuchProvider
}
return driver.NewLLMClient(ctx, configs...)
}
func NewEmbeddingClient(ctx context.Context, provider string, configs ...pconf.Config) (provider.EmbeddingClient, error) {
embeddingProvidersMu.RLock()
defer embeddingProvidersMu.RUnlock()
driver, ok := embeddingProviders[provider]
if !ok {
return nil, ErrNoSuchProvider
}
return driver.NewEmbeddingClient(ctx, configs...)
}
func NewTTSClient(ctx context.Context, provider string, configs ...pconf.Config) (provider.TTSClient, error) {
ttsProvidersMu.RLock()
defer ttsProvidersMu.RUnlock()
driver, ok := ttsProviders[provider]
if !ok {
return nil, ErrNoSuchProvider
}
return driver.NewTTSClient(ctx, configs...)
}