Class: EmbeddingUtil::Providers::SelfHosted
Instance Attribute Summary
#config
Instance Method Summary
collapse
#initialize, provider_name, #provider_name, supported?
Instance Method Details
#embed(texts, profile: config.resolved_profile) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/embedding_util/providers/self_hosted.rb', line 24
def embed(texts, profile: config.resolved_profile)
manager = ServerManager.new(config: config)
endpoint = manager.ensure_server(:embedding, profile: profile)
manager.track_activity(:embedding, profile: profile) do
endpoint_provider(embedding_endpoint: endpoint).embed(texts, profile: profile)
end
end
|
#rerank(query, documents, profile: config.resolved_profile) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/embedding_util/providers/self_hosted.rb', line 32
def rerank(query, documents, profile: config.resolved_profile)
manager = ServerManager.new(config: config)
endpoint = manager.ensure_server(:reranker, profile: profile)
rerank_with_activity(manager, endpoint, query, documents, profile)
rescue EndpointError => e
raise unless retryable_reranker_error?(e) && can_escalate_reranker_ubatch?
config.reranker_ubatch_size = config.reranker_max_ubatch_size
endpoint = manager.restart_server(:reranker, profile: profile)
rerank_with_activity(manager, endpoint, query, documents, profile)
end
|
#support ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/embedding_util/providers/self_hosted.rb', line 14
def support
{
provider: provider_name,
supported: supported?,
runtime: RuntimeCommand.resolve(config.runtime),
shutdown_idle: config.shutdown_idle,
state_dir: config.state_dir
}
end
|
#supported? ⇒ Boolean
10
11
12
|
# File 'lib/embedding_util/providers/self_hosted.rb', line 10
def supported?
ServerManager.supported?(config)
end
|