prescient 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +21 -268
- data/CHANGELOG.md +59 -0
- data/INTEGRATION_GUIDE.md +19 -1
- data/README.md +369 -21
- data/Steepfile +12 -12
- data/db/migrate/001_create_prescient_tables.rb +15 -16
- data/docker-compose.yml +22 -0
- data/examples/README.md +36 -1
- data/examples/custom_contexts.rb +4 -4
- data/examples/web_search.rb +34 -0
- data/exe/prescient +2 -2
- data/exe/prescient-mcp +7 -0
- data/lib/prescient/agent/audit_log.rb +37 -0
- data/lib/prescient/agent/cli_adapter.rb +29 -0
- data/lib/prescient/agent/configuration.rb +57 -0
- data/lib/prescient/agent/context.rb +56 -0
- data/lib/prescient/agent/error_serializer.rb +47 -0
- data/lib/prescient/agent/errors.rb +25 -0
- data/lib/prescient/agent/parser.rb +49 -0
- data/lib/prescient/agent/prompt_builder.rb +31 -0
- data/lib/prescient/agent/result.rb +36 -0
- data/lib/prescient/agent/runtime.rb +175 -0
- data/lib/prescient/agent/schema_validator.rb +215 -0
- data/lib/prescient/agent/tool_registry.rb +89 -0
- data/lib/prescient/agent.rb +22 -0
- data/lib/prescient/api.rb +346 -231
- data/lib/prescient/base.rb +370 -372
- data/lib/prescient/cli.rb +591 -402
- data/lib/prescient/client.rb +31 -4
- data/lib/prescient/configuration_loader.rb +511 -336
- data/lib/prescient/document_source.rb +114 -0
- data/lib/prescient/errors.rb +13 -3
- data/lib/prescient/mcp/authentication.rb +39 -0
- data/lib/prescient/mcp/configuration.rb +38 -0
- data/lib/prescient/mcp/rack.rb +243 -0
- data/lib/prescient/mcp/server.rb +202 -0
- data/lib/prescient/mcp/stdio.rb +42 -0
- data/lib/prescient/mcp.rb +8 -0
- data/lib/prescient/pgvector.rb +193 -189
- data/lib/prescient/provider/anthropic.rb +129 -125
- data/lib/prescient/provider/deepseek.rb +122 -118
- data/lib/prescient/provider/gemini.rb +153 -149
- data/lib/prescient/provider/huggingface.rb +191 -187
- data/lib/prescient/provider/mistral.rb +151 -147
- data/lib/prescient/provider/ollama.rb +168 -165
- data/lib/prescient/provider/openai.rb +174 -171
- data/lib/prescient/provider/xai.rb +122 -118
- data/lib/prescient/tool/search_api.rb +130 -0
- data/lib/prescient/tool/searxng.rb +128 -0
- data/lib/prescient/tool.rb +125 -0
- data/lib/prescient/version.rb +1 -1
- data/lib/prescient.rb +129 -55
- data/schema/prescient.configuration.schema.json +119 -0
- data/searxng/settings.yml +18 -0
- data/sig/prescient.rbs +228 -1
- metadata +33 -5
data/lib/prescient/client.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Main Prescient module for AI provider abstraction
|
|
3
4
|
module Prescient
|
|
4
5
|
# Client class for interacting with AI providers
|
|
5
6
|
#
|
|
@@ -104,10 +105,10 @@ module Prescient
|
|
|
104
105
|
# and recursively sanitized :options
|
|
105
106
|
def provider_info
|
|
106
107
|
{
|
|
107
|
-
name:
|
|
108
|
-
class:
|
|
108
|
+
name: @provider_name,
|
|
109
|
+
class: @provider.class.name.split("::").last,
|
|
109
110
|
available: available?,
|
|
110
|
-
options:
|
|
111
|
+
options: sanitize_options(@provider.options)
|
|
111
112
|
}
|
|
112
113
|
end
|
|
113
114
|
|
|
@@ -210,7 +211,7 @@ module Prescient
|
|
|
210
211
|
Prescient::ConnectionError,
|
|
211
212
|
Prescient::RateLimitError,
|
|
212
213
|
Prescient::ModelNotAvailableError,
|
|
213
|
-
Prescient::ProviderError
|
|
214
|
+
Prescient::ProviderError
|
|
214
215
|
].any? { |error_class| error.is_a?(error_class) }
|
|
215
216
|
end
|
|
216
217
|
end
|
|
@@ -247,6 +248,32 @@ module Prescient
|
|
|
247
248
|
client(provider, enable_fallback: enable_fallback).generate_response(prompt, context_items, **options)
|
|
248
249
|
end
|
|
249
250
|
|
|
251
|
+
# Search with an explicit external tool and optionally use the normalized
|
|
252
|
+
# results as context for a configured AI provider.
|
|
253
|
+
#
|
|
254
|
+
# @param query [String] Search query and generation prompt
|
|
255
|
+
# @param tool [Symbol, String] Configured external tool name
|
|
256
|
+
# @param provider [Symbol, nil] Provider to use for generation
|
|
257
|
+
# @param limit [Integer, nil] Maximum number of search results
|
|
258
|
+
# @param enable_fallback [Boolean] Whether provider fallback is enabled
|
|
259
|
+
# @param provider_options [Hash] Temporary provider configuration overrides
|
|
260
|
+
# @return [Hash] Normalized provider response
|
|
261
|
+
def self.search_and_generate(query, tool: :web_search, provider: nil, limit: nil,
|
|
262
|
+
enable_fallback: true, provider_options: {}, **options)
|
|
263
|
+
search_tool = self.tool(tool)
|
|
264
|
+
raise Prescient::ToolConfigurationError, "tool not configured: #{tool}" unless search_tool
|
|
265
|
+
|
|
266
|
+
search_result = search_tool.search(query, limit: limit)
|
|
267
|
+
context_items = search_result[:results]
|
|
268
|
+
raise Prescient::ToolInvalidResponseError, "tool results must be an array" unless context_items.is_a?(Array)
|
|
269
|
+
|
|
270
|
+
client(provider, enable_fallback:, provider_options:).generate_response(
|
|
271
|
+
query,
|
|
272
|
+
context_items,
|
|
273
|
+
**options
|
|
274
|
+
)
|
|
275
|
+
end
|
|
276
|
+
|
|
250
277
|
# Return the health status of a configured provider.
|
|
251
278
|
#
|
|
252
279
|
# @param provider [Symbol, nil] Provider to check
|