Module: Parse::Retrieval::Profiles
- Defined in:
- lib/parse/retrieval/profiles.rb
Overview
Server-configured retrieval profiles for the semantic_search agent
tool.
A profile composes the library's existing retrieval paths (vector,
hybrid, reranking) with explicit budgets, so an application can offer
an agent a few named strategies (for example fast, balanced,
precise) without letting the model pick providers, endpoints, or
credentials. The agent only ever names a profile; everything else is
fixed on the server at registration time.
Registration validates the whole configuration, so a misconfigured
profile (unknown option, unregistered reranker, non-positive budget)
fails at boot rather than mid-request. Without a profile: argument
semantic_search behaves exactly as before.
Defined Under Namespace
Classes: Profile
Constant Summary collapse
- ALLOWED_OPTIONS =
%i[ k max_k hybrid reranker rerank_candidates rerank_top_n rerank_max_document_chars rerank_timeout on_rerank_failure max_total_tokens ].freeze
- DEFAULTS =
Defaults applied to an option the profile does not set.
{ k: 10, max_k: 20, hybrid: nil, rerank_candidates: 30, rerank_top_n: nil, rerank_max_document_chars: 4_000, rerank_timeout: 10, on_rerank_failure: :fallback, max_total_tokens: nil, }.freeze
- MAX_RERANK_CANDIDATES =
Hard ceilings no profile may exceed, so a misconfigured profile still cannot fan out unbounded provider work.
100- MAX_K =
semantic_search returns at most this many documents, so a larger max_k could never take effect; it is refused rather than clamped.
20- MAX_RERANK_DOCUMENT_CHARS =
32_000- FAILURE_MODES =
%i[fallback raise].freeze
- RERANK_OPTIONS =
Options that only have an effect when the profile names a reranker.
%i[rerank_candidates rerank_top_n rerank_max_document_chars rerank_timeout on_rerank_failure].freeze
- HYBRID_KEYS =
%i[lexical vector fusion].freeze
- NAME_RE =
/\A[a-z][a-z0-9_]{0,39}\z/.freeze
Class Method Summary collapse
-
.fetch!(name) ⇒ Profile
The registered profile.
-
.names ⇒ Array<String>
Registered profile names, sorted.
-
.register(name, **options) ⇒ Profile
Register (or replace) a profile.
- .reset! ⇒ Object
- .unregister(name) ⇒ Object
Class Method Details
.fetch!(name) ⇒ Profile
Returns the registered profile.
113 114 115 116 117 118 119 120 |
# File 'lib/parse/retrieval/profiles.rb', line 113 def fetch!(name) key = name.to_s profile = @mutex.synchronize { @registry[key] } return profile if profile raise Parse::Agent::ValidationError, "Unknown retrieval profile #{key.inspect}. Available: #{names.inspect}." end |
.names ⇒ Array<String>
Returns registered profile names, sorted.
123 124 125 |
# File 'lib/parse/retrieval/profiles.rb', line 123 def names @mutex.synchronize { @registry.keys.sort } end |
.register(name, **options) ⇒ Profile
Register (or replace) a profile.
104 105 106 107 108 |
# File 'lib/parse/retrieval/profiles.rb', line 104 def register(name, **) profile = build(name, ) @mutex.synchronize { @registry[profile.name] = profile } profile end |
.reset! ⇒ Object
131 132 133 |
# File 'lib/parse/retrieval/profiles.rb', line 131 def reset! @mutex.synchronize { @registry.clear } end |
.unregister(name) ⇒ Object
127 128 129 |
# File 'lib/parse/retrieval/profiles.rb', line 127 def unregister(name) @mutex.synchronize { @registry.delete(name.to_s) } end |