inquirex 0.3.0 → 0.3.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 +4 -4
- data/README.md +17 -0
- data/docs/badges/coverage_badge.svg +2 -2
- data/lib/inquirex/engine.rb +27 -0
- data/lib/inquirex/version.rb +1 -1
- metadata +3 -5
- data/exe/inquirex +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5457c529512019dbfcb838eb1a607d933d85cad7a2edc926bd0049eca271f2f0
|
|
4
|
+
data.tar.gz: f561ac674e088508c2bb33726016660dc5a29cbbeb085e17ec84de8833c45859
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be941ae3435a8e114dce7234477afb5d29e2624f7ddf8ed07fe8118d23b031390dd4c59610251f8419469765e4c6db5bc5413522b9f1befcc5e218e95b295513
|
|
7
|
+
data.tar.gz: 831876215c0ee5cd29d7bf72549d9a430633b3dafe6f154e813df2891381bc9d269ddddbcef117a6b86697c32ae4708fdf30faf0a2d8f18e259b3f933f76c1a2
|
data/README.md
CHANGED
|
@@ -381,6 +381,23 @@ Behavior:
|
|
|
381
381
|
- Use `finished?` to detect completion
|
|
382
382
|
- Use `total(:price)` / `totals` to read running totals
|
|
383
383
|
- Use `to_state` / `.from_state` for persistence/resume (totals included)
|
|
384
|
+
- Use `prefill!(hash)` to merge externally-supplied answers into the state,
|
|
385
|
+
e.g. fields extracted by an LLM from a free-text answer (see
|
|
386
|
+
[inquirex-llm](#extension-gems)). Existing answers are preserved; `nil`
|
|
387
|
+
and empty values are ignored so they don't spuriously satisfy
|
|
388
|
+
`not_empty` rules. The engine auto-advances past any newly-skippable step.
|
|
389
|
+
|
|
390
|
+
```ruby
|
|
391
|
+
engine = Inquirex::Engine.new(definition)
|
|
392
|
+
engine.answer("I'm MFJ with two kids in California.") # free-text :describe
|
|
393
|
+
|
|
394
|
+
# Step is now :extracted (a clarify node); adapter returns a Hash.
|
|
395
|
+
result = adapter.call(engine.current_step, engine.answers)
|
|
396
|
+
engine.answer(result) # store under the clarify step's id
|
|
397
|
+
engine.prefill!(result) # splat into top-level answers
|
|
398
|
+
# Downstream :filing_status, :dependents, :state are now auto-skipped by
|
|
399
|
+
# `skip_if not_empty(:filing_status)` etc.
|
|
400
|
+
```
|
|
384
401
|
|
|
385
402
|
### Validation Adapter
|
|
386
403
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
|
16
16
|
<text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
|
|
17
17
|
<text x="31.5" y="14">coverage</text>
|
|
18
|
-
<text x="80" y="15" fill="#010101" fill-opacity=".3">
|
|
19
|
-
<text x="80" y="14">
|
|
18
|
+
<text x="80" y="15" fill="#010101" fill-opacity=".3">95%</text>
|
|
19
|
+
<text x="80" y="14">95%</text>
|
|
20
20
|
</g>
|
|
21
21
|
</svg>
|
data/lib/inquirex/engine.rb
CHANGED
|
@@ -74,6 +74,33 @@ module Inquirex
|
|
|
74
74
|
advance_step
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
+
# Merges a hash of { step_id => value } into the top-level answers without
|
|
78
|
+
# clobbering answers the user has already provided. Used by LLM clarify
|
|
79
|
+
# steps to populate downstream answers from free-text extraction so that
|
|
80
|
+
# `skip_if not_empty(:id)` rules on later steps will fire.
|
|
81
|
+
#
|
|
82
|
+
# Nil/empty values in the hash are ignored so that "unknown" LLM outputs
|
|
83
|
+
# don't spuriously satisfy `not_empty` rules.
|
|
84
|
+
#
|
|
85
|
+
# If the engine's current step becomes skippable as a result of the prefill,
|
|
86
|
+
# it auto-advances past it.
|
|
87
|
+
#
|
|
88
|
+
# @param hash [Hash] answers keyed by step id
|
|
89
|
+
# @return [Hash] the updated answers
|
|
90
|
+
def prefill!(hash)
|
|
91
|
+
return @answers unless hash.is_a?(Hash)
|
|
92
|
+
|
|
93
|
+
hash.each do |key, value|
|
|
94
|
+
next if value.nil?
|
|
95
|
+
next if value.respond_to?(:empty?) && value.empty?
|
|
96
|
+
|
|
97
|
+
sym = key.to_sym
|
|
98
|
+
@answers[sym] = value unless @answers.key?(sym)
|
|
99
|
+
end
|
|
100
|
+
skip_if_needed unless finished?
|
|
101
|
+
@answers
|
|
102
|
+
end
|
|
103
|
+
|
|
77
104
|
# Serializable state snapshot for persistence or resumption.
|
|
78
105
|
#
|
|
79
106
|
# @return [Hash]
|
data/lib/inquirex/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inquirex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Konstantin Gredeskoul
|
|
8
|
-
bindir:
|
|
8
|
+
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
@@ -18,8 +18,7 @@ description: Inquirex lets you define multi-step questionnaires as directed grap
|
|
|
18
18
|
immutable definitions.
|
|
19
19
|
email:
|
|
20
20
|
- kigster@gmail.com
|
|
21
|
-
executables:
|
|
22
|
-
- inquirex
|
|
21
|
+
executables: []
|
|
23
22
|
extensions: []
|
|
24
23
|
extra_rdoc_files: []
|
|
25
24
|
files:
|
|
@@ -33,7 +32,6 @@ files:
|
|
|
33
32
|
- README.md
|
|
34
33
|
- Rakefile
|
|
35
34
|
- docs/badges/coverage_badge.svg
|
|
36
|
-
- exe/inquirex
|
|
37
35
|
- justfile
|
|
38
36
|
- lefthook.yml
|
|
39
37
|
- lib/inquirex.rb
|
data/exe/inquirex
DELETED