vector_amp 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b5cca5e94ec6fe5fa062e6e6034a5576db8264eefb4ebc306ed489ad8946ccd6
4
+ data.tar.gz: ba79880edd034128d92b4a57b3a7fe46be310e0b190d3cb93f8c7a6b00d80db4
5
+ SHA512:
6
+ metadata.gz: 8a1cf8517e4862b4a240b6dc6b4da146bb2fe1499d9b2b6a98fbdefe870be57ad24c78b5defffc4986ca3babea7d8533128450d1bfc54468305c23e54bcabcc5
7
+ data.tar.gz: aca7d1ef6aa30ff9477fdcd30d1deab9831111a8fd759f521e0cbd2334f724d2b870e57eee393a9d0d987f19ced7c6b9a776054c54a44bd6f5b4a6f6f20c3aa1
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and do
117
+ not modify the License. You may add Your own attribution notices
118
+ within Derivative Works that You distribute, alongside or as an
119
+ addendum to the NOTICE text from the Work, provided that such
120
+ additional attribution notices cannot be construed as modifying
121
+ the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 VectorAmp, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/NOTICE ADDED
@@ -0,0 +1,8 @@
1
+ VectorAmp SDK
2
+ Copyright 2026 VectorAmp, Inc.
3
+
4
+ This product includes software developed at VectorAmp, Inc.
5
+ (https://vectoramp.com/).
6
+
7
+ Licensed under the Apache License, Version 2.0. See the LICENSE file for
8
+ the full license text.
data/README.md ADDED
@@ -0,0 +1,377 @@
1
+ <div align="center">
2
+ <a href="https://vectoramp.com/">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: light)" srcset=".github/images/logo-full-light.svg">
5
+ <source media="(prefers-color-scheme: dark)" srcset=".github/images/logo-full-dark.svg">
6
+ <img alt="VectorAmp Logo" src=".github/images/logo-full-dark.svg" width="50%">
7
+ </picture>
8
+ </a>
9
+ </div>
10
+
11
+ # VectorAmp Ruby SDK
12
+
13
+ Official Ruby client for the VectorAmp API.
14
+
15
+ - Default API: `https://api.vectoramp.com`
16
+ - Auth: `X-Api-Key`
17
+ - Transport abstraction: REST today, designed so gRPC can be added later
18
+ - Licensed under Apache-2.0.
19
+
20
+ ## Installation
21
+
22
+ Add to your Gemfile:
23
+
24
+ ```ruby
25
+ gem "vector_amp"
26
+ ```
27
+
28
+ Or install from a local checkout while developing:
29
+
30
+ ```bash
31
+ bundle install
32
+ ```
33
+
34
+ ## Quick start
35
+
36
+ ```ruby
37
+ require "vector_amp"
38
+
39
+ # api_key defaults to ENV["VECTORAMP_API_KEY"]; base_url defaults to production.
40
+ client = VectorAmp::Client.new
41
+
42
+ # One-call create: only a name is required. The SDK defaults to the managed
43
+ # vectoramp/VectorAmp-Embedding-4B model, infers dim (2560), metric "cosine",
44
+ # and always uses the SABLE index (index type is never exposed).
45
+ dataset = client.datasets.create(name: "product-docs")
46
+
47
+ # Create/get/list return VectorAmp::Dataset resources. Prefer the object->method
48
+ # style: call helpers directly on the returned dataset.
49
+ dataset.add_texts(
50
+ ["VectorAmp is powered by SABLE."],
51
+ metadata: { source: "readme" }
52
+ )
53
+
54
+ # Add raw vectors. Ids may be strings or integers; integer ids stay numbers.
55
+ dataset.insert(vectors: [
56
+ { id: 1, values: [0.1, 0.2, 0.3], metadata: { title: "Intro" } },
57
+ { id: "doc-002", values: [0.4, 0.5, 0.6], metadata: { title: "Details" } }
58
+ ])
59
+
60
+ results = dataset.search("What powers VectorAmp?", top_k: 5, include_documents: true)
61
+ answer = dataset.ask("What powers VectorAmp?")
62
+ ```
63
+
64
+ ### Creating datasets
65
+
66
+ ```ruby
67
+ # Minimal: name only.
68
+ client.datasets.create(name: "docs")
69
+
70
+ # Enable hybrid (dense + sparse) search.
71
+ client.datasets.create(name: "docs", hybrid: true)
72
+
73
+ # Use an OpenAI embedding model (dim inferred from the model).
74
+ client.datasets.create(name: "docs", embedding: VectorAmp::Embedding.openai("large"))
75
+
76
+ # Custom/unknown model: pass dim explicitly.
77
+ client.datasets.create(name: "docs", embedding: { provider: "acme", model: "acme-embed" }, dim: 1024)
78
+ ```
79
+
80
+ ## Configuration
81
+
82
+ ```ruby
83
+ client = VectorAmp::Client.new(
84
+ api_key: "va_...",
85
+ base_url: "https://api.vectoramp.com",
86
+ timeout: 30
87
+ )
88
+ ```
89
+
90
+ `api_key` defaults to `ENV["VECTORAMP_API_KEY"]`.
91
+
92
+ ## Datasets
93
+
94
+ ```ruby
95
+ # Paginated envelope: { "datasets" => [VectorAmp::Dataset, ...], "total" => n, "limit" => 50, "offset" => 0 }
96
+ page = client.datasets.list(limit: 50, offset: 0)
97
+ dataset = page["datasets"].first
98
+
99
+ # Object->method style (preferred).
100
+ dataset = client.datasets.get("dataset-uuid")
101
+ dataset.stats
102
+ dataset.search(
103
+ "wireless headphones",
104
+ top_k: 10,
105
+ filters: { category: "electronics" },
106
+ advanced_filters: [
107
+ { field: "price", op: "lt", value: 100.0 }
108
+ ],
109
+ include_metadata: true,
110
+ include_documents: false,
111
+ rerank: true # expands to vectoramp / VectorAmp-Rerank-v1
112
+ )
113
+ dataset.insert(vectors: [{ id: "sku-1", values: [0.1, 0.2], metadata: { category: "electronics" } }])
114
+ dataset.add_texts(["Wireless headphones"], metadata: { category: "electronics" })
115
+ dataset.ask("Which headphones should I buy?")
116
+ dataset.ingest_source("source-uuid")
117
+ dataset.delete
118
+
119
+ # Hybrid search: pass a sparse query and/or alpha weighting on a hybrid dataset.
120
+ dataset.search("wireless headphones", hybrid: true, sparse_query: "headphones", alpha: 0.5)
121
+
122
+ # Client-namespaced methods are equivalent and also supported.
123
+ client.datasets.stats("dataset-uuid")
124
+ client.datasets.search("dataset-uuid", "wireless headphones", top_k: 10)
125
+ client.datasets.insert("dataset-uuid", vectors: [])
126
+ ```
127
+
128
+ `client.datasets.create` intentionally does not accept `index_type`; all datasets are created with SABLE.
129
+
130
+ ### Source documents
131
+
132
+ Dataset document listing is cursor-based: pass `next_cursor` into the next request and do not assume offsets or totals. Downloads return retained original bytes and follow API/storage redirects.
133
+
134
+ ```ruby
135
+ page = client.datasets.list_documents("dataset-uuid", limit: 50, cursor: nil, status: "ready")
136
+ page.fetch("documents").each do |doc|
137
+ next unless doc["download_available"]
138
+
139
+ bytes = client.datasets.download_document("dataset-uuid", doc.fetch("id"))
140
+ end
141
+
142
+ if page["next_cursor"]
143
+ next_page = client.datasets.list_documents("dataset-uuid", cursor: page["next_cursor"])
144
+ end
145
+
146
+ # Resource-style helpers are available too.
147
+ dataset = client.datasets.get("dataset-uuid")
148
+ docs = dataset.list_documents(limit: 25)
149
+ raw = dataset.download_document(docs.fetch("documents").first.fetch("id"))
150
+ ```
151
+
152
+ ## Ingestion
153
+
154
+ ```ruby
155
+ # Sources: paginated envelope { "sources" => [...], "total" => n, ... }
156
+ client.ingestion.list_sources(limit: 50, offset: 0)
157
+ client.ingestion.get_source("source-uuid")
158
+
159
+ # Typed builders cover the supported source_type values:
160
+ # "web", "s3", "gcs", "gdrive", "file_upload", "jira", and "confluence".
161
+ source = client.sources.create_web(
162
+ start_urls: ["https://docs.example.com"],
163
+ max_depth: 1,
164
+ include_assets: true,
165
+ max_assets_per_page: 5
166
+ )
167
+
168
+ s3_source = client.sources.create_s3(
169
+ bucket: "vectoramp-docs",
170
+ prefix: "public/"
171
+ )
172
+
173
+ gcs_source = client.sources.create_gcs(bucket: "vectoramp-docs-gcs", prefix: "public/")
174
+
175
+ jira_source = client.sources.create_jira(
176
+ cloud_id: "atlassian-cloud-id",
177
+ project_keys: ["ENG"],
178
+ include_comments: true # default
179
+ )
180
+
181
+ confluence_source = client.sources.create_confluence(
182
+ cloud_id: "atlassian-cloud-id",
183
+ spaces: ["ENG"],
184
+ username: "service-account@example.com",
185
+ api_token: ENV["CONFLUENCE_API_TOKEN"]
186
+ )
187
+
188
+ gdrive_source = client.sources.create_google_drive(
189
+ folder_ids: ["google-drive-folder-id"]
190
+ )
191
+
192
+ file_source = client.sources.create_file_upload
193
+
194
+ # You can still pass name: when you want control. If omitted, the SDK chooses
195
+ # a readable default from the URL, bucket, Google Drive id, or upload timestamp.
196
+
197
+ # GenericSource is an escape hatch for API-compatible source configs that are
198
+ # not modeled by a typed SDK helper yet.
199
+ generic_source = VectorAmp::GenericSource.new(
200
+ source_type: "custom",
201
+ name: "custom-source",
202
+ config: { endpoint: "https://example.com/feed" }
203
+ )
204
+ client.sources.create(generic_source)
205
+
206
+ # The lower-level existing API is still supported.
207
+ source = client.ingestion.create_source(
208
+ source_type: "web",
209
+ name: "docs-site",
210
+ config: { start_urls: ["https://docs.example.com"], max_depth: 1 }
211
+ )
212
+
213
+ job = client.ingestion.start_job(
214
+ source_id: source["id"],
215
+ dataset_id: "dataset-uuid"
216
+ )
217
+
218
+ # Dataset resources can ingest by source id or by a typed source object that has an id.
219
+ dataset.ingest_source(source["id"])
220
+ typed_source = VectorAmp::WebSource.new(id: source["id"], name: "docs-site", start_urls: ["https://docs.example.com"])
221
+ dataset.ingest_source(typed_source)
222
+
223
+ # Jobs: paginated envelope { "jobs" => [...], "total" => n, ... }
224
+ client.ingestion.list_jobs(dataset_id: "dataset-uuid", limit: 50, offset: 0)
225
+ client.ingestion.get_job(job["job_id"])
226
+ client.ingestion.job_files(job["job_id"])
227
+ client.ingestion.job_statistics(job["job_id"])
228
+ client.ingestion.cancel_job(job["job_id"])
229
+ ```
230
+
231
+ ### Upload files from the filesystem
232
+
233
+ `ingest_files` uses the REST upload flow: create a `file_upload` source, initialize upload, PUT bytes to presigned URLs, then complete the upload.
234
+
235
+ ```ruby
236
+ client.ingestion.ingest_files(
237
+ dataset_id: "dataset-uuid",
238
+ paths: ["docs/whitepaper.pdf", "docs/notes.md"],
239
+ metadata: { team: "product" }
240
+ )
241
+
242
+ # Or from a Dataset resource. No source name is required; the SDK creates a
243
+ # file_upload source with a generated name before uploading.
244
+ dataset.ingest_files(paths: ["docs/whitepaper.pdf"])
245
+ ```
246
+
247
+ ## Intelligence / RAG
248
+
249
+ Non-streaming:
250
+
251
+ ```ruby
252
+ answer = client.ask(
253
+ "What are the key features?",
254
+ dataset_id: "all",
255
+ top_k: 5
256
+ )
257
+ puts answer["answer"]
258
+ ```
259
+
260
+ Multi-turn conversations: the Intelligence API is stateless, so send prior turns
261
+ in `conversation_history`. You decide how many previous messages to include.
262
+
263
+ ```ruby
264
+ history = [
265
+ { role: "user", content: "What are the key features?" },
266
+ { role: "assistant", content: "Hybrid search, reranking, and managed ingestion." }
267
+ ]
268
+
269
+ follow_up = client.intelligence.query(
270
+ "Which of those help with relevance?",
271
+ dataset_id: "all",
272
+ conversation_history: history.last(10) # include as many prior turns as you want
273
+ )
274
+ puts follow_up["answer"]
275
+ ```
276
+
277
+ Streaming SSE:
278
+
279
+ ```ruby
280
+ client.ask_stream("Summarize the docs", dataset_id: "dataset-uuid") do |event|
281
+ print event["content"] if event["chunk_type"] == "text"
282
+ end
283
+
284
+ # Or as an Enumerator:
285
+ client.ask_stream("Summarize").each do |event|
286
+ puts event.inspect
287
+ end
288
+ ```
289
+
290
+ ### Sessions
291
+
292
+ Persist multi-turn conversations server-side instead of resending history.
293
+
294
+ ```ruby
295
+ session = client.intelligence.create_session(title: "Onboarding", dataset_id: "dataset-uuid")
296
+
297
+ client.intelligence.append_message(session.fetch("id"), role: "user", content: "What is SABLE?")
298
+ client.intelligence.append_message(session.fetch("id"), role: "assistant", content: "A managed index type.")
299
+
300
+ messages = client.intelligence.list_messages(session.fetch("id"))
301
+ sessions = client.intelligence.list_sessions(limit: 20)
302
+ client.intelligence.get_session(session.fetch("id"))
303
+ client.intelligence.delete_session(session.fetch("id"))
304
+ ```
305
+
306
+ ## Error handling
307
+
308
+ Non-2xx responses raise `VectorAmp::APIError` with `status`, `body`, and `headers`.
309
+
310
+ ```ruby
311
+ begin
312
+ client.datasets.get("missing")
313
+ rescue VectorAmp::APIError => e
314
+ warn "VectorAmp API error #{e.status}: #{e.message}"
315
+ end
316
+ ```
317
+
318
+ ## Development
319
+
320
+ ```bash
321
+ bundle install
322
+ bundle exec rake test
323
+ ```
324
+
325
+ Tests mock HTTP with WebMock and enforce SimpleCov coverage.
326
+
327
+ ## Method reference
328
+
329
+ Both access styles work everywhere: `client.datasets.<m>(id, ...)` and the
330
+ equivalent `datasetObj.<m>(...)` on a returned `VectorAmp::Dataset`.
331
+
332
+ ### Datasets — `client.datasets`
333
+
334
+ | Method | Required | Optional (defaults) |
335
+ |---|---|---|
336
+ | `create(name:)` | `name` | `dim` (inferred), `embedding` (vectoramp/VectorAmp-Embedding-4B), `metric` ("cosine"), `hybrid`, `filters`, `metadata_schema`, `tuning`, `metadata` |
337
+ | `list` | — | `limit` (50), `offset` (0) |
338
+ | `get(id)` | `id` | — |
339
+ | `delete(id)` | `id` | — |
340
+ | `stats(id)` | `id` | — |
341
+ | `search(id, query = nil)` | `id` | `query`/`query_text`/`search_text`, `top_k` (10), `filters`, `advanced_filters`, `hybrid`, `sparse_query`, `alpha`, `rerank`, `include_documents`, `include_metadata`, `include_embeddings`, `embedding_model`, `embedding_provider`, `nprobe_override`, `rerank_depth_override` |
342
+ | `insert(id, vectors:)` | `id`, `vectors` | — (integer ids preserved as numbers) |
343
+ | `embed(id)` | `id` | `text`, `texts` (one required) |
344
+ | `add_texts(id, texts = nil)` | `id`, `texts` | `ids` (auto-generated), `metadata` |
345
+ | `list_documents(id)` | `id` | `limit` (50), `cursor`, `status` |
346
+ | `download_document(id, document_id)` | `id`, `document_id` | — |
347
+
348
+ Dataset-object helpers: `search`, `insert`, `add_texts`, `embed`, `delete`, `stats`,
349
+ `list_documents`, `download_document`, `ask`, `ingest_source`, `ingest_files`.
350
+
351
+ ### Intelligence — `client.intelligence` (and `client.ask` / `client.ask_stream`)
352
+
353
+ | Method | Required | Optional (defaults) |
354
+ |---|---|---|
355
+ | `query(query)` / `ask` / `ask_stream` | `query` | `dataset_id` ("all" when unscoped), `top_k` (5 server-side), `conversation_history`, `include_sources`, `stream` |
356
+ | `create_session` | — | `title`, `dataset_id`, `workspace_id`, `metadata` |
357
+ | `list_sessions` | — | `limit` (50) |
358
+ | `get_session(session_id)` | `session_id` | — |
359
+ | `delete_session(session_id)` | `session_id` | — |
360
+ | `append_message(session_id, role:, content:)` | `session_id`, `role`, `content` | `metadata` |
361
+ | `list_messages(session_id)` | `session_id` | `limit` (100) |
362
+
363
+ ### Sources — `client.sources` (alias of `client.ingestion`)
364
+
365
+ `create(source)`, `create_web(start_urls:)`, `create_s3(bucket:)`, `create_gcs(bucket:)`,
366
+ `create_google_drive(folder_ids:|file_ids:)`, `create_jira(cloud_id:)`,
367
+ `create_confluence(cloud_id:|base_url:)`, `create_file_upload`, `list_sources`, `get_source(id)`.
368
+ Jobs: `start_job(source_id:, dataset_id:)`, `list_jobs`, `get_job(id)`, `retry_job(id)`,
369
+ `ingest_files(dataset_id:, paths:)`.
370
+
371
+ ### Schedules — `client.schedules`
372
+
373
+ `list`, `get(id)`, `create(source_id:, dataset_id:, cron:)`, `update(id)`, `delete(id)`, `trigger(id)`.
374
+
375
+ ## License
376
+
377
+ Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "connections"
4
+ require_relative "datasets"
5
+ require_relative "error"
6
+ require_relative "ingestion"
7
+ require_relative "intelligence"
8
+ require_relative "schedules"
9
+ require_relative "source"
10
+ require_relative "transport/http"
11
+
12
+ module VectorAmp
13
+ # Top-level API client for VectorAmp datasets, ingestion sources/jobs, and intelligence.
14
+ class Client
15
+ DEFAULT_BASE_URL = "https://api.vectoramp.com"
16
+
17
+ # @return [String] API base URL used by this client.
18
+ # @return [DatasetsResource] dataset API resource.
19
+ # @return [IngestionResource] ingestion/source API resource.
20
+ # @return [IntelligenceResource] intelligence API resource.
21
+ # @return [ConnectionsResource] managed provider connections API resource.
22
+ attr_reader :base_url, :datasets, :ingestion, :intelligence, :schedules, :sources, :connections
23
+
24
+ # Create a VectorAmp API client.
25
+ # @param api_key [String] API key; defaults to ENV["VECTORAMP_API_KEY"].
26
+ # @param base_url [String] API base URL; defaults to the production API.
27
+ # @param transport [#request, nil] optional custom transport for tests or advanced use.
28
+ # @param timeout [Numeric] HTTP timeout in seconds for the default transport.
29
+ # @return [Client]
30
+ # @raise [ConfigurationError] when api_key is missing.
31
+ def initialize(api_key: ENV["VECTORAMP_API_KEY"], base_url: DEFAULT_BASE_URL, transport: nil, timeout: Transport::HTTP::DEFAULT_TIMEOUT)
32
+ raise ConfigurationError, "api_key is required" if api_key.nil? || api_key.empty?
33
+
34
+ @base_url = base_url
35
+ @transport = transport || Transport::HTTP.new(base_url: base_url, api_key: api_key, timeout: timeout)
36
+ @ingestion = IngestionResource.new(@transport)
37
+ @sources = @ingestion
38
+ @schedules = SchedulesResource.new(@transport)
39
+ @intelligence = IntelligenceResource.new(@transport)
40
+ @connections = ConnectionsResource.new(@transport)
41
+ @datasets = DatasetsResource.new(@transport, client: self)
42
+ end
43
+
44
+ # Ask an intelligence question and return a complete response.
45
+ # @param query [String] natural-language question.
46
+ # @param options [Hash] forwarded to {IntelligenceResource#query}; `stream` is forced to false.
47
+ # @return [Hash] intelligence response.
48
+ def ask(query, **options)
49
+ @intelligence.query(query, **options.merge(stream: false))
50
+ end
51
+
52
+ # Ask an intelligence question as a stream.
53
+ # @param query [String] natural-language question.
54
+ # @param options [Hash] forwarded to {IntelligenceResource#query}; `stream` is forced to true.
55
+ # @yieldparam chunk [Object] streamed response chunk from the transport.
56
+ # @return [Enumerator, Object] enumerator without a block, otherwise the transport result.
57
+ def ask_stream(query, **options, &block)
58
+ @intelligence.query(query, **options.merge(stream: true), &block)
59
+ end
60
+ end
61
+ end