vector_amp 0.5.0 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47c268daf0e7c0577fdff02c84f948bb2e394d607683464b6248d5039af98d39
4
- data.tar.gz: c7a616a0458451afc28163c91c7c221f5b7cb5892203766cf59daa33c961d8d8
3
+ metadata.gz: 70c698bb53d97209e9eeac1751e5e1630f3f71b4bd5f06a1ba65e807ddc573ac
4
+ data.tar.gz: e651d9b66da88dff32f1bf913db8fa86fac51bde05497cacf65372086e6ca4fd
5
5
  SHA512:
6
- metadata.gz: ecff0393b786f01d56c48376a2c5bc27cf718ddba580c3e4bf951e9e8adb35acea6e76309f1be2342dbee71e881cd2bfbbd70f663ae5cb95ae08d5cd0977e419
7
- data.tar.gz: b89d436c1d51a0b6feca1819bb1996a335da6ab03b6417c866a4e7811e45067b22304a077f70edf1cf646f26c255a1ca0b3a831a98aa98781c626795c3e1f391
6
+ metadata.gz: 2b1c6a7837315f1c0b9d76c41dd354d17109a0175a695f79026db437424d090c41b535937d07658923049e4715900fda0080796f76ea4624049a215f0ad5fcfe
7
+ data.tar.gz: e49eae451bcd0e9070fb42dbd4fc05bc6bec9b56d347474a1b4dde07d2960ee176bdb696a1bcdebeeb3e6c58e9cb3a1759f30ba9ed7999ea496e29f91ff29395
data/README.md CHANGED
@@ -306,10 +306,12 @@ Non-streaming:
306
306
  ```ruby
307
307
  answer = client.ask(
308
308
  "What are the key features?",
309
- dataset_id: "all",
310
- top_k: 5
309
+ top_k: 5 # omit dataset_ids to search every dataset you can see
311
310
  )
312
311
  puts answer["answer"]
312
+
313
+ # Scope one question to any number of datasets:
314
+ answer = client.ask("Which contracts renew in Q4?", dataset_ids: %w[ds_contracts ds_invoices])
313
315
  ```
314
316
 
315
317
  Multi-turn conversations: the Intelligence API is stateless, so send prior turns
@@ -323,7 +325,6 @@ history = [
323
325
 
324
326
  follow_up = client.intelligence.query(
325
327
  "Which of those help with relevance?",
326
- dataset_id: "all",
327
328
  conversation_history: history.last(10) # include as many prior turns as you want
328
329
  )
329
330
  puts follow_up["answer"]
@@ -332,7 +333,7 @@ puts follow_up["answer"]
332
333
  Streaming SSE:
333
334
 
334
335
  ```ruby
335
- client.ask_stream("Summarize the docs", dataset_id: "dataset-uuid") do |event|
336
+ client.ask_stream("Summarize the docs", dataset_ids: ["dataset-uuid"]) do |event|
336
337
  print event["content"] if event["chunk_type"] == "text"
337
338
  end
338
339
 
@@ -409,7 +410,7 @@ Dataset-object helpers: `search`, `insert`, `add_texts`, `embed`, `delete`, `sta
409
410
 
410
411
  | Method | Required | Optional (defaults) |
411
412
  |---|---|---|
412
- | `query(query)` / `ask` / `ask_stream` | `query` | `dataset_id` ("all" when unscoped), `top_k` (5 server-side), `conversation_history`, `include_sources`, `stream` |
413
+ | `query(query)` / `ask` / `ask_stream` | `query` | `dataset_ids` (array; omit to search every visible dataset), `top_k` (5 server-side), `conversation_history`, `include_sources`, `stream` |
413
414
  | `create_session` | — | `title`, `dataset_id`, `workspace_id`, `metadata` |
414
415
  | `list_sessions` | — | `limit` (50) |
415
416
  | `get_session(session_id)` | `session_id` | — |
@@ -129,11 +129,11 @@ module VectorAmp
129
129
 
130
130
  # Ask an intelligence question constrained to this dataset.
131
131
  # @param query [String] natural-language question.
132
- # @param options [Hash] forwarded to {Client#ask}; `dataset_id` is set to this dataset id.
132
+ # @param options [Hash] forwarded to {Client#ask}; `dataset_ids` is set to this dataset id.
133
133
  # @return [Hash] intelligence response.
134
134
  def ask(query, **options)
135
135
  require_client!("ask")
136
- client.ask(query, **options.merge(dataset_id: id))
136
+ client.ask(query, **options.merge(dataset_ids: [id]))
137
137
  end
138
138
 
139
139
  # Upload local files by auto-creating a `file_upload` source, initializing presigned uploads, and completing the upload job.
@@ -11,20 +11,24 @@ module VectorAmp
11
11
  @transport = transport
12
12
  end
13
13
 
14
- # Ask an intelligence query, optionally scoped to a dataset and streamed.
14
+ # Ask an intelligence query, optionally scoped to datasets and streamed.
15
15
  # @param query [String] natural-language question.
16
- # @param dataset_id [String, nil] optional dataset id scope.
16
+ # @param dataset_ids [Array<String>, String, nil] datasets to scope the question to; omit to
17
+ # search every dataset the API key can see.
17
18
  # @param top_k [Integer, nil] optional retrieval result count.
18
19
  # @param conversation_history [Array<Hash>, nil] optional prior conversation messages.
19
20
  # @param include_sources [Boolean, nil] include source chunks/citations when supported.
20
21
  # @param stream [Boolean] stream chunks when true; defaults to false.
21
22
  # @yieldparam chunk [Object] streamed response chunk when stream is true.
22
23
  # @return [Hash, Enumerator, Object] response hash, enumerator without a stream block, or transport stream result.
23
- def query(query, dataset_id: nil, top_k: nil, conversation_history: nil, include_sources: nil, stream: false, **unknown, &block)
24
+ def query(query, dataset_ids: nil, top_k: nil, conversation_history: nil, include_sources: nil, stream: false, **unknown, &block)
24
25
  Utils.ensure_no_unknown!(unknown, "query")
26
+ scope = self.class.normalize_dataset_ids(dataset_ids)
25
27
  body = Utils.compact_hash(
26
28
  query: query,
27
- dataset_id: dataset_id,
29
+ # An absent dataset_ids is how the API says "every dataset you can see";
30
+ # an empty array would be a narrower, different request.
31
+ dataset_ids: scope.empty? ? nil : scope,
28
32
  top_k: top_k,
29
33
  conversation_history: conversation_history,
30
34
  include_sources: include_sources,
@@ -32,7 +36,7 @@ module VectorAmp
32
36
  )
33
37
 
34
38
  if stream
35
- return enum_for(:query, query, dataset_id: dataset_id, top_k: top_k,
39
+ return enum_for(:query, query, dataset_ids: dataset_ids, top_k: top_k,
36
40
  conversation_history: conversation_history, include_sources: include_sources,
37
41
  stream: true) unless block
38
42
 
@@ -42,6 +46,18 @@ module VectorAmp
42
46
  end
43
47
  end
44
48
 
49
+ # Normalize a dataset scope for the wire.
50
+ #
51
+ # `POST /intelligence/query` scopes with `dataset_ids` and reads an absent field as "every
52
+ # dataset the caller can see". The singular `dataset_id` is retired and now draws a 400, and
53
+ # the `"all"` sentinel it carried says nothing an omitted field does not, so both are dropped
54
+ # here rather than transmitted.
55
+ # @param dataset_ids [Array<String>, String, nil] requested scope.
56
+ # @return [Array<String>] normalized dataset ids.
57
+ def self.normalize_dataset_ids(dataset_ids)
58
+ Array(dataset_ids).map { |id| id.to_s.strip }.reject { |id| id.empty? || id == "all" }
59
+ end
60
+
45
61
  # Create an intelligence conversation session.
46
62
  # @param title [String, nil] optional session title.
47
63
  # @param dataset_id [String, nil] optional dataset scope.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VectorAmp
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vector_amp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - VectorAmp