Module: Prescient
- Defined in:
- lib/prescient.rb,
lib/prescient/client.rb,
lib/prescient/errors.rb,
lib/prescient/version.rb
Overview
Main Prescient module for AI provider abstraction
Prescient provides a unified interface for working with multiple AI providers including Ollama, OpenAI, Anthropic, and Hugging Face. It supports both embedding generation and text completion with configurable context handling.
Defined Under Namespace
Modules: Pgvector, Provider Classes: AuthenticationError, Base, CLI, Client, Configuration, ConnectionError, Error, InvalidResponseError, InvalidVectorError, ModelNotAvailableError, ProviderError, RateLimitError
Constant Summary collapse
- VERSION =
Current Prescient gem version.
'0.4.0'
Class Method Summary collapse
-
.client(provider_name = nil, enable_fallback: true, provider_options: {}) ⇒ Client
Convenience methods for quick access.
-
.configuration ⇒ Configuration
Get the current configuration instance.
-
.configure {|config| ... } ⇒ void
Configure Prescient with custom settings and providers.
-
.generate_embedding(text, provider: nil, enable_fallback: true, **options) ⇒ Array<Float>
Generate an embedding through a configured provider.
-
.generate_response(prompt, context_items = [], provider: nil, enable_fallback: true, **options) ⇒ Hash
Generate a response through a configured provider.
-
.health_check(provider: nil) ⇒ Hash
Return the health status of a configured provider.
-
.reset_configuration! ⇒ Configuration
Reset configuration to defaults.
Class Method Details
.client(provider_name = nil, enable_fallback: true, provider_options: {}) ⇒ Client
Convenience methods for quick access
224 225 226 |
# File 'lib/prescient/client.rb', line 224 def self.client(provider_name = nil, enable_fallback: true, provider_options: {}) Client.new(provider_name, enable_fallback: enable_fallback, provider_options: ) end |
.configuration ⇒ Configuration
Get the current configuration instance
53 54 55 |
# File 'lib/prescient.rb', line 53 def self.configuration @_configuration ||= Configuration.new end |
.configure {|config| ... } ⇒ void
This method returns an undefined value.
Configure Prescient with custom settings and providers
46 47 48 |
# File 'lib/prescient.rb', line 46 def self.configure yield(configuration) end |
.generate_embedding(text, provider: nil, enable_fallback: true, **options) ⇒ Array<Float>
Generate an embedding through a configured provider.
234 235 236 |
# File 'lib/prescient/client.rb', line 234 def self.(text, provider: nil, enable_fallback: true, **) client(provider, enable_fallback: enable_fallback).(text, **) end |
.generate_response(prompt, context_items = [], provider: nil, enable_fallback: true, **options) ⇒ Hash
Generate a response through a configured provider.
246 247 248 |
# File 'lib/prescient/client.rb', line 246 def self.generate_response(prompt, context_items = [], provider: nil, enable_fallback: true, **) client(provider, enable_fallback: enable_fallback).generate_response(prompt, context_items, **) end |
.health_check(provider: nil) ⇒ Hash
Return the health status of a configured provider.
254 255 256 |
# File 'lib/prescient/client.rb', line 254 def self.health_check(provider: nil) client(provider, enable_fallback: false).health_check end |
.reset_configuration! ⇒ Configuration
Reset configuration to defaults
60 61 62 |
# File 'lib/prescient.rb', line 60 def self.reset_configuration! @_configuration = Configuration.new end |