Class: TurboRAG::Client
- Inherits:
-
Object
- Object
- TurboRAG::Client
- Defined in:
- lib/turborag.rb
Instance Method Summary collapse
-
#health ⇒ Hash
Health check.
-
#index ⇒ Hash
Index configuration and stats.
-
#ingest(records:) ⇒ Hash
Add records with precomputed embeddings.
-
#ingest_text(text:, source_doc: nil) ⇒ Hash
Ingest raw text with auto-chunking (requires –model).
-
#initialize(base_url, timeout: 30) ⇒ Client
constructor
A new instance of Client.
-
#metrics ⇒ Hash
Latency and error metrics.
-
#query(vector:, top_k: 5) ⇒ Hash
Search by embedding vector.
-
#query_batch(queries:, top_k: 5) ⇒ Hash
Batch vector search.
-
#query_text(text:, top_k: 5) ⇒ Hash
Search by text (requires –model on the server).
Constructor Details
#initialize(base_url, timeout: 30) ⇒ Client
Returns a new instance of Client.
28 29 30 31 |
# File 'lib/turborag.rb', line 28 def initialize(base_url, timeout: 30) @base_uri = URI.parse(base_url.chomp("/")) @timeout = timeout end |
Instance Method Details
#health ⇒ Hash
Health check.
78 79 80 |
# File 'lib/turborag.rb', line 78 def health get("/health") end |
#index ⇒ Hash
Index configuration and stats.
84 85 86 |
# File 'lib/turborag.rb', line 84 def index get("/index") end |
#ingest(records:) ⇒ Hash
Add records with precomputed embeddings.
64 65 66 |
# File 'lib/turborag.rb', line 64 def ingest(records:) post("/ingest", { records: records }) end |
#ingest_text(text:, source_doc: nil) ⇒ Hash
Ingest raw text with auto-chunking (requires –model).
72 73 74 |
# File 'lib/turborag.rb', line 72 def ingest_text(text:, source_doc: nil) post("/ingest-text", { text: text, source_doc: source_doc }) end |
#metrics ⇒ Hash
Latency and error metrics.
90 91 92 |
# File 'lib/turborag.rb', line 90 def metrics get("/metrics") end |
#query(vector:, top_k: 5) ⇒ Hash
Search by embedding vector.
37 38 39 |
# File 'lib/turborag.rb', line 37 def query(vector:, top_k: 5) post("/query", { query_vector: vector, top_k: top_k }) end |
#query_batch(queries:, top_k: 5) ⇒ Hash
Batch vector search.
53 54 55 56 57 58 59 |
# File 'lib/turborag.rb', line 53 def query_batch(queries:, top_k: 5) payload = { queries: queries.map { |q| { query_vector: q[:vector] } }, top_k: top_k, } post("/query/batch", payload) end |
#query_text(text:, top_k: 5) ⇒ Hash
Search by text (requires –model on the server).
45 46 47 |
# File 'lib/turborag.rb', line 45 def query_text(text:, top_k: 5) post("/query", { query_text: text, top_k: top_k }) end |