inquirex-llm 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 +7 -0
- data/.relaxed_rubocop.yml +153 -0
- data/.secrets.baseline +127 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +221 -0
- data/Rakefile +36 -0
- data/docs/badges/coverage_badge.svg +21 -0
- data/exe/inquirex-llm +3 -0
- data/justfile +38 -0
- data/lefthook.yml +35 -0
- data/lib/inquirex/llm/adapter.rb +69 -0
- data/lib/inquirex/llm/dsl/flow_builder.rb +58 -0
- data/lib/inquirex/llm/dsl/llm_step_builder.rb +178 -0
- data/lib/inquirex/llm/errors.rb +19 -0
- data/lib/inquirex/llm/node.rb +136 -0
- data/lib/inquirex/llm/null_adapter.rb +49 -0
- data/lib/inquirex/llm/schema.rb +110 -0
- data/lib/inquirex/llm/version.rb +7 -0
- data/lib/inquirex/llm.rb +43 -0
- data/lib/inquirex-llm.rb +3 -0
- data/sig/inquirex/llm.rbs +6 -0
- metadata +84 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 10d488773dcdef0cbf1f5fe93cdb916b7bf2bdf585e45d283b98fcda77dcd68d
|
|
4
|
+
data.tar.gz: 8c8128942112c74522f8f8c4e3be86904eeb5be510400f9c104f908ec24c7d5e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a2ec2170b2fd8dd56bbfaa05ad3dd9507c6880ddce90993caa2af9519ccc002a869d87e0c784f855272480ffb1500f545152daeff0d5f29dcb9d9b68ffdb3849
|
|
7
|
+
data.tar.gz: 4f53ae8500c6cb8f11d89952f4b101a6fd919e3902e3d8bfed2b06fb0cb8b899b1fe93dfe309fddfb8e4c523b2b10d60d96551b9a2084efef09f118edaef197b
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Relaxed.Ruby.Style
|
|
2
|
+
## Version 2.5
|
|
3
|
+
|
|
4
|
+
Style/Alias:
|
|
5
|
+
Enabled: false
|
|
6
|
+
StyleGuide: https://relaxed.ruby.style/#stylealias
|
|
7
|
+
|
|
8
|
+
Style/AsciiComments:
|
|
9
|
+
Enabled: false
|
|
10
|
+
StyleGuide: https://relaxed.ruby.style/#styleasciicomments
|
|
11
|
+
|
|
12
|
+
Style/BeginBlock:
|
|
13
|
+
Enabled: false
|
|
14
|
+
StyleGuide: https://relaxed.ruby.style/#stylebeginblock
|
|
15
|
+
|
|
16
|
+
Style/BlockDelimiters:
|
|
17
|
+
Enabled: false
|
|
18
|
+
StyleGuide: https://relaxed.ruby.style/#styleblockdelimiters
|
|
19
|
+
|
|
20
|
+
Style/CommentAnnotation:
|
|
21
|
+
Enabled: false
|
|
22
|
+
StyleGuide: https://relaxed.ruby.style/#stylecommentannotation
|
|
23
|
+
|
|
24
|
+
Style/Documentation:
|
|
25
|
+
Enabled: false
|
|
26
|
+
StyleGuide: https://relaxed.ruby.style/#styledocumentation
|
|
27
|
+
|
|
28
|
+
Layout/DotPosition:
|
|
29
|
+
Enabled: false
|
|
30
|
+
StyleGuide: https://relaxed.ruby.style/#layoutdotposition
|
|
31
|
+
|
|
32
|
+
Style/DoubleNegation:
|
|
33
|
+
Enabled: false
|
|
34
|
+
StyleGuide: https://relaxed.ruby.style/#styledoublenegation
|
|
35
|
+
|
|
36
|
+
Style/EndBlock:
|
|
37
|
+
Enabled: false
|
|
38
|
+
StyleGuide: https://relaxed.ruby.style/#styleendblock
|
|
39
|
+
|
|
40
|
+
Style/FormatString:
|
|
41
|
+
Enabled: false
|
|
42
|
+
StyleGuide: https://relaxed.ruby.style/#styleformatstring
|
|
43
|
+
|
|
44
|
+
Style/IfUnlessModifier:
|
|
45
|
+
Enabled: false
|
|
46
|
+
StyleGuide: https://relaxed.ruby.style/#styleifunlessmodifier
|
|
47
|
+
|
|
48
|
+
Style/Lambda:
|
|
49
|
+
Enabled: false
|
|
50
|
+
StyleGuide: https://relaxed.ruby.style/#stylelambda
|
|
51
|
+
|
|
52
|
+
Style/ModuleFunction:
|
|
53
|
+
Enabled: false
|
|
54
|
+
StyleGuide: https://relaxed.ruby.style/#stylemodulefunction
|
|
55
|
+
|
|
56
|
+
Style/MultilineBlockChain:
|
|
57
|
+
Enabled: false
|
|
58
|
+
StyleGuide: https://relaxed.ruby.style/#stylemultilineblockchain
|
|
59
|
+
|
|
60
|
+
Style/NegatedIf:
|
|
61
|
+
Enabled: false
|
|
62
|
+
StyleGuide: https://relaxed.ruby.style/#stylenegatedif
|
|
63
|
+
|
|
64
|
+
Style/NegatedWhile:
|
|
65
|
+
Enabled: false
|
|
66
|
+
StyleGuide: https://relaxed.ruby.style/#stylenegatedwhile
|
|
67
|
+
|
|
68
|
+
Style/NumericPredicate:
|
|
69
|
+
Enabled: false
|
|
70
|
+
StyleGuide: https://relaxed.ruby.style/#stylenumericpredicate
|
|
71
|
+
|
|
72
|
+
Style/ParallelAssignment:
|
|
73
|
+
Enabled: false
|
|
74
|
+
StyleGuide: https://relaxed.ruby.style/#styleparallelassignment
|
|
75
|
+
|
|
76
|
+
Style/PercentLiteralDelimiters:
|
|
77
|
+
Enabled: false
|
|
78
|
+
StyleGuide: https://relaxed.ruby.style/#stylepercentliteraldelimiters
|
|
79
|
+
|
|
80
|
+
Style/PerlBackrefs:
|
|
81
|
+
Enabled: false
|
|
82
|
+
StyleGuide: https://relaxed.ruby.style/#styleperlbackrefs
|
|
83
|
+
|
|
84
|
+
Style/Semicolon:
|
|
85
|
+
Enabled: false
|
|
86
|
+
StyleGuide: https://relaxed.ruby.style/#stylesemicolon
|
|
87
|
+
|
|
88
|
+
Style/SignalException:
|
|
89
|
+
Enabled: false
|
|
90
|
+
StyleGuide: https://relaxed.ruby.style/#stylesignalexception
|
|
91
|
+
|
|
92
|
+
Style/SingleLineBlockParams:
|
|
93
|
+
Enabled: false
|
|
94
|
+
StyleGuide: https://relaxed.ruby.style/#stylesinglelineblockparams
|
|
95
|
+
|
|
96
|
+
Style/SingleLineMethods:
|
|
97
|
+
Enabled: false
|
|
98
|
+
StyleGuide: https://relaxed.ruby.style/#stylesinglelinemethods
|
|
99
|
+
|
|
100
|
+
Layout/SpaceBeforeBlockBraces:
|
|
101
|
+
Enabled: false
|
|
102
|
+
StyleGuide: https://relaxed.ruby.style/#layoutspacebeforeblockbraces
|
|
103
|
+
|
|
104
|
+
Layout/SpaceInsideParens:
|
|
105
|
+
Enabled: false
|
|
106
|
+
StyleGuide: https://relaxed.ruby.style/#layoutspaceinsideparens
|
|
107
|
+
|
|
108
|
+
Style/SpecialGlobalVars:
|
|
109
|
+
Enabled: false
|
|
110
|
+
StyleGuide: https://relaxed.ruby.style/#stylespecialglobalvars
|
|
111
|
+
|
|
112
|
+
Style/StringLiterals:
|
|
113
|
+
Enabled: false
|
|
114
|
+
StyleGuide: https://relaxed.ruby.style/#stylestringliterals
|
|
115
|
+
|
|
116
|
+
Style/TrailingCommaInArguments:
|
|
117
|
+
Enabled: false
|
|
118
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarguments
|
|
119
|
+
|
|
120
|
+
Style/TrailingCommaInArrayLiteral:
|
|
121
|
+
Enabled: false
|
|
122
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarrayliteral
|
|
123
|
+
|
|
124
|
+
Style/TrailingCommaInHashLiteral:
|
|
125
|
+
Enabled: false
|
|
126
|
+
StyleGuide: https://relaxed.ruby.style/#styletrailingcommainhashliteral
|
|
127
|
+
|
|
128
|
+
Style/SymbolArray:
|
|
129
|
+
Enabled: false
|
|
130
|
+
StyleGuide: http://relaxed.ruby.style/#stylesymbolarray
|
|
131
|
+
|
|
132
|
+
Style/WhileUntilModifier:
|
|
133
|
+
Enabled: false
|
|
134
|
+
StyleGuide: https://relaxed.ruby.style/#stylewhileuntilmodifier
|
|
135
|
+
|
|
136
|
+
Style/WordArray:
|
|
137
|
+
Enabled: false
|
|
138
|
+
StyleGuide: https://relaxed.ruby.style/#stylewordarray
|
|
139
|
+
|
|
140
|
+
Lint/AmbiguousRegexpLiteral:
|
|
141
|
+
Enabled: false
|
|
142
|
+
StyleGuide: https://relaxed.ruby.style/#lintambiguousregexpliteral
|
|
143
|
+
|
|
144
|
+
Lint/AssignmentInCondition:
|
|
145
|
+
Enabled: false
|
|
146
|
+
StyleGuide: https://relaxed.ruby.style/#lintassignmentincondition
|
|
147
|
+
|
|
148
|
+
Layout/LineLength:
|
|
149
|
+
Enabled: false
|
|
150
|
+
|
|
151
|
+
Metrics:
|
|
152
|
+
Enabled: false
|
|
153
|
+
|
data/.secrets.baseline
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.5.0",
|
|
3
|
+
"plugins_used": [
|
|
4
|
+
{
|
|
5
|
+
"name": "ArtifactoryDetector"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"name": "AWSKeyDetector"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "AzureStorageKeyDetector"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "Base64HighEntropyString",
|
|
15
|
+
"limit": 4.5
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "BasicAuthDetector"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "CloudantDetector"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "DiscordBotTokenDetector"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "GitHubTokenDetector"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "GitLabTokenDetector"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "HexHighEntropyString",
|
|
34
|
+
"limit": 3.0
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "IbmCloudIamDetector"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "IbmCosHmacDetector"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "IPPublicDetector"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "JwtTokenDetector"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "KeywordDetector",
|
|
50
|
+
"keyword_exclude": ""
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "MailchimpDetector"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "NpmDetector"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "OpenAIDetector"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "PrivateKeyDetector"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "PypiTokenDetector"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "SendGridDetector"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "SlackDetector"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "SoftlayerDetector"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "SquareOAuthDetector"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "StripeDetector"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "TelegramBotTokenDetector"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "TwilioKeyDetector"
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"filters_used": [
|
|
90
|
+
{
|
|
91
|
+
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
|
|
95
|
+
"min_level": 2
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"path": "detect_secrets.filters.heuristic.is_lock_file"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"path": "detect_secrets.filters.heuristic.is_sequential_string"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"path": "detect_secrets.filters.heuristic.is_swagger_file"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"path": "detect_secrets.filters.heuristic.is_templated_secret"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"results": {},
|
|
126
|
+
"generated_at": "2026-04-13T21:29:03Z"
|
|
127
|
+
}
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Konstantin Gredeskoul
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
[](https://github.com/inquirex/inquirex-llm/actions/workflows/main.yml) 
|
|
2
|
+
|
|
3
|
+
# inquirex-llm
|
|
4
|
+
|
|
5
|
+
LLM integration verbs for the [Inquirex](https://github.com/inquirex/inquirex) questionnaire engine.
|
|
6
|
+
|
|
7
|
+
Extends the core DSL with four server-side verbs -- `clarify`, `describe`, `summarize`, and `detour` -- that bridge free-text answers and structured data via LLM processing. Ships with a pluggable adapter interface and a `NullAdapter` for testing.
|
|
8
|
+
|
|
9
|
+
## Status
|
|
10
|
+
|
|
11
|
+
- Version: `0.1.0`
|
|
12
|
+
- Ruby: `>= 4.0.0`
|
|
13
|
+
- Test suite: `111 examples, 0 failures`
|
|
14
|
+
- Depends on: `inquirex` (core gem)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
gem "inquirex-llm"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
`require "inquirex-llm"` injects the LLM verbs into the core `Inquirex.define` DSL. No separate entry point needed.
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
require "inquirex"
|
|
28
|
+
require "inquirex-llm"
|
|
29
|
+
|
|
30
|
+
definition = Inquirex.define id: "tax-intake-2026", version: "1.0.0" do
|
|
31
|
+
start :description
|
|
32
|
+
|
|
33
|
+
ask :description do
|
|
34
|
+
type :text
|
|
35
|
+
question "Describe your business in a few sentences."
|
|
36
|
+
transition to: :extracted
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
clarify :extracted do
|
|
40
|
+
from :description
|
|
41
|
+
prompt "Extract structured business information from the description."
|
|
42
|
+
schema industry: :string,
|
|
43
|
+
entity_type: :string,
|
|
44
|
+
employee_count: :integer,
|
|
45
|
+
estimated_revenue: :currency
|
|
46
|
+
model :claude_sonnet
|
|
47
|
+
temperature 0.2
|
|
48
|
+
transition to: :summary
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
summarize :summary do
|
|
52
|
+
from_all
|
|
53
|
+
prompt "Summarize this client's tax situation and flag complexity concerns."
|
|
54
|
+
transition to: :done
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
say :done do
|
|
58
|
+
text "Thank you! We'll be in touch."
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
All core verbs (`ask`, `say`, `header`, `btw`, `warning`, `confirm`) and widget hints work alongside LLM verbs in the same `Inquirex.define` block.
|
|
64
|
+
|
|
65
|
+
## LLM Verbs
|
|
66
|
+
|
|
67
|
+
### `clarify`
|
|
68
|
+
|
|
69
|
+
Extract structured data from a free-text answer. Requires `from`, `prompt`, and `schema`.
|
|
70
|
+
|
|
71
|
+
```ruby
|
|
72
|
+
clarify :business_extracted do
|
|
73
|
+
from :business_description
|
|
74
|
+
prompt "Extract structured business information."
|
|
75
|
+
schema industry: :string, employee_count: :integer, revenue: :currency
|
|
76
|
+
model :claude_sonnet
|
|
77
|
+
temperature 0.2
|
|
78
|
+
max_tokens 1024
|
|
79
|
+
transition to: :next_step
|
|
80
|
+
end
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### `describe`
|
|
84
|
+
|
|
85
|
+
Generate natural-language text from structured data. Requires `from` and `prompt`. No schema needed.
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
describe :business_narrative do
|
|
89
|
+
from :business_extracted
|
|
90
|
+
prompt "Write a brief narrative of this business for the intake report."
|
|
91
|
+
transition to: :next_step
|
|
92
|
+
end
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### `summarize`
|
|
96
|
+
|
|
97
|
+
Produce a summary of all or selected answers. Use `from_all` to pass everything, or `from` to select specific steps.
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
summarize :intake_summary do
|
|
101
|
+
from_all
|
|
102
|
+
prompt "Summarize this client's tax situation."
|
|
103
|
+
transition to: :review
|
|
104
|
+
end
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `detour`
|
|
108
|
+
|
|
109
|
+
Dynamically generate follow-up questions based on an answer. The server adapter handles presenting the generated questions and collecting responses. Requires `from`, `prompt`, and `schema`.
|
|
110
|
+
|
|
111
|
+
```ruby
|
|
112
|
+
detour :followup do
|
|
113
|
+
from :description
|
|
114
|
+
prompt "Generate 2-3 follow-up questions to clarify the tax situation."
|
|
115
|
+
schema questions: :array, answers: :hash
|
|
116
|
+
transition to: :next_step
|
|
117
|
+
end
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## DSL Methods (inside LLM verb blocks)
|
|
121
|
+
|
|
122
|
+
| Method | Purpose | Required |
|
|
123
|
+
|--------|---------|----------|
|
|
124
|
+
| `prompt "..."` | LLM prompt template | Always |
|
|
125
|
+
| `schema key: :type, ...` | Expected output structure | `clarify`, `detour` |
|
|
126
|
+
| `from :step_id` | Source step(s) whose answers feed the LLM | `clarify`, `describe`, `detour` |
|
|
127
|
+
| `from_all` | Pass all collected answers to the LLM | Alternative to `from` |
|
|
128
|
+
| `model :claude_sonnet` | Optional model hint for the adapter | No |
|
|
129
|
+
| `temperature 0.3` | Optional sampling temperature | No |
|
|
130
|
+
| `max_tokens 1024` | Optional max output tokens | No |
|
|
131
|
+
| `fallback { \|answers\| ... }` | Server-side fallback (stripped from JSON) | No |
|
|
132
|
+
| `transition to: :step` | Conditional transition (same as core) | No |
|
|
133
|
+
| `skip_if rule` | Skip step when condition is true | No |
|
|
134
|
+
|
|
135
|
+
## Engine Integration
|
|
136
|
+
|
|
137
|
+
The engine treats LLM steps as collecting steps. The server adapter processes the LLM call and feeds the result back:
|
|
138
|
+
|
|
139
|
+
```ruby
|
|
140
|
+
engine = Inquirex::Engine.new(definition)
|
|
141
|
+
|
|
142
|
+
engine.answer("I run an LLC with 15 employees, ~$2M revenue.")
|
|
143
|
+
# engine.current_step_id => :extracted
|
|
144
|
+
|
|
145
|
+
# Server-side: adapter calls the LLM
|
|
146
|
+
adapter = MyLlmAdapter.new
|
|
147
|
+
result = adapter.call(engine.current_step, engine.answers)
|
|
148
|
+
# => { industry: "Technology", employee_count: 15, revenue: 2_000_000.0 }
|
|
149
|
+
|
|
150
|
+
engine.answer(result)
|
|
151
|
+
# engine.current_step_id => :summary
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
For testing, use `NullAdapter` which returns schema-conformant placeholder values without any API calls:
|
|
155
|
+
|
|
156
|
+
```ruby
|
|
157
|
+
adapter = Inquirex::LLM::NullAdapter.new
|
|
158
|
+
result = adapter.call(engine.current_step)
|
|
159
|
+
# => { industry: "", employee_count: 0, revenue: 0.0 }
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## JSON Serialization
|
|
163
|
+
|
|
164
|
+
LLM steps serialize with `"requires_server": true` so the JS widget knows to round-trip to the server. LLM metadata lives under an `"llm"` key:
|
|
165
|
+
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"verb": "clarify",
|
|
169
|
+
"requires_server": true,
|
|
170
|
+
"transitions": [{ "to": "summary", "requires_server": true }],
|
|
171
|
+
"llm": {
|
|
172
|
+
"prompt": "Extract structured business information.",
|
|
173
|
+
"schema": {
|
|
174
|
+
"industry": "string",
|
|
175
|
+
"employee_count": "integer",
|
|
176
|
+
"revenue": "currency"
|
|
177
|
+
},
|
|
178
|
+
"from_steps": ["business_description"],
|
|
179
|
+
"model": "claude_sonnet",
|
|
180
|
+
"temperature": 0.2,
|
|
181
|
+
"max_tokens": 1024
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Fallback procs are stripped from JSON (server-side only).
|
|
187
|
+
|
|
188
|
+
## Custom Adapter
|
|
189
|
+
|
|
190
|
+
Subclass `Inquirex::LLM::Adapter` and implement `#call(node, answers)`:
|
|
191
|
+
|
|
192
|
+
```ruby
|
|
193
|
+
class MyLlmAdapter < Inquirex::LLM::Adapter
|
|
194
|
+
def call(node, answers)
|
|
195
|
+
source = source_answers(node, answers)
|
|
196
|
+
response = my_llm_client.complete(
|
|
197
|
+
node.prompt,
|
|
198
|
+
context: source,
|
|
199
|
+
model: node.model,
|
|
200
|
+
temperature: node.temperature
|
|
201
|
+
)
|
|
202
|
+
result = parse_response(response)
|
|
203
|
+
validate_output!(node, result)
|
|
204
|
+
result
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The base class provides `#source_answers` (gathers relevant answers) and `#validate_output!` (checks schema conformance).
|
|
210
|
+
|
|
211
|
+
## Development
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
bundle install
|
|
215
|
+
bundle exec rspec
|
|
216
|
+
bundle exec rubocop
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## License
|
|
220
|
+
|
|
221
|
+
MIT. See [LICENSE.txt](LICENSE.txt).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rspec/core/rake_task"
|
|
5
|
+
require "timeout"
|
|
6
|
+
require "yard"
|
|
7
|
+
|
|
8
|
+
def shell(*args)
|
|
9
|
+
puts "running: #{args.join(" ")}"
|
|
10
|
+
system(args.join(" "))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
task :clean do
|
|
14
|
+
shell("rm -rf pkg/ tmp/ coverage/ doc/ ")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
task gem: [:build] do
|
|
18
|
+
shell("gem install pkg/*")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
task permissions: [:clean] do
|
|
22
|
+
shell("chmod -v o+r,g+r * */* */*/* */*/*/* */*/*/*/* */*/*/*/*/*")
|
|
23
|
+
shell("find . -type d -exec chmod o+x,g+x {} \\;")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
task build: :permissions
|
|
27
|
+
|
|
28
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
|
29
|
+
t.files = %w[lib/**/*.rb exe/*.rb - README.md LICENSE.txt CHANGELOG.md]
|
|
30
|
+
t.options.unshift("--title", '"FlowEngine — DSL + AST for buildiong complex flows in Ruby."')
|
|
31
|
+
t.after = -> { exec("open doc/index.html") } if RUBY_PLATFORM =~ /darwin/
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
35
|
+
|
|
36
|
+
task default: :spec
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20">
|
|
3
|
+
<linearGradient id="b" x2="0" y2="100%">
|
|
4
|
+
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
|
5
|
+
<stop offset="1" stop-opacity=".1"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
<mask id="a">
|
|
8
|
+
<rect width="99" height="20" rx="3" fill="#fff"/>
|
|
9
|
+
</mask>
|
|
10
|
+
<g mask="url(#a)">
|
|
11
|
+
<path fill="#555" d="M0 0h63v20H0z"/>
|
|
12
|
+
<path fill="#4c1" d="M63 0h36v20H63z"/>
|
|
13
|
+
<path fill="url(#b)" d="M0 0h99v20H0z"/>
|
|
14
|
+
</g>
|
|
15
|
+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
|
16
|
+
<text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
|
|
17
|
+
<text x="31.5" y="14">coverage</text>
|
|
18
|
+
<text x="80" y="15" fill="#010101" fill-opacity=".3">98%</text>
|
|
19
|
+
<text x="80" y="14">98%</text>
|
|
20
|
+
</g>
|
|
21
|
+
</svg>
|
data/exe/inquirex-llm
ADDED
data/justfile
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
set shell := ["bash", "-lc"]
|
|
2
|
+
|
|
3
|
+
rbenv := 'eval "$(rbenv init -)"'
|
|
4
|
+
|
|
5
|
+
[no-exit-message]
|
|
6
|
+
recipes:
|
|
7
|
+
@just --choose
|
|
8
|
+
|
|
9
|
+
# Sync all dependencies
|
|
10
|
+
install:
|
|
11
|
+
{{rbenv}} && bin/setup
|
|
12
|
+
|
|
13
|
+
# Lint and reformat files
|
|
14
|
+
lint-fix *args:
|
|
15
|
+
{{rbenv}} && bundle exec rubocop -a
|
|
16
|
+
|
|
17
|
+
alias format := lint-fix
|
|
18
|
+
|
|
19
|
+
# Lint and reformat files
|
|
20
|
+
lint:
|
|
21
|
+
{{rbenv}} && bundle exec rubocop
|
|
22
|
+
|
|
23
|
+
# Run all the tests
|
|
24
|
+
test *args:
|
|
25
|
+
{{rbenv}} && ENVIRONMENT=test bundle exec rspec {{args}}
|
|
26
|
+
|
|
27
|
+
# Run tests with coverage
|
|
28
|
+
test-coverage *args:
|
|
29
|
+
ENVIRONMENT=test COVERAGE=true bundle exec rspec
|
|
30
|
+
|
|
31
|
+
clean:
|
|
32
|
+
#!/usr/bin/env bash
|
|
33
|
+
find . -name .DS_Store -delete -print || true
|
|
34
|
+
rm -rf tmp/*
|
|
35
|
+
|
|
36
|
+
# Run all lefthook pre-commit hooks
|
|
37
|
+
ci:
|
|
38
|
+
{{rbenv}} && lefthook run pre-commit --all-files
|
data/lefthook.yml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
output:
|
|
2
|
+
- summary
|
|
3
|
+
- failure
|
|
4
|
+
|
|
5
|
+
pre-commit:
|
|
6
|
+
parallel: true
|
|
7
|
+
jobs:
|
|
8
|
+
- name: lint
|
|
9
|
+
run: bundle exec rubocop -c .rubocop.yml {staged_files}
|
|
10
|
+
glob: "*.{rb,Gemfile}"
|
|
11
|
+
stage_fixed: true
|
|
12
|
+
|
|
13
|
+
- name: check for conflict markers and whitespace issues
|
|
14
|
+
run: git --no-pager diff --check
|
|
15
|
+
|
|
16
|
+
# If tests take >1 second, move this (or just the long-running tests) to pre-push.
|
|
17
|
+
- name: run tests
|
|
18
|
+
run: just test
|
|
19
|
+
|
|
20
|
+
- name: fix rubocop formatting issues
|
|
21
|
+
run: bundle exec rubocop -a {staged_files}
|
|
22
|
+
glob: "*.{rb,Gemfile,gemspec}"
|
|
23
|
+
stage_fixed: true
|
|
24
|
+
|
|
25
|
+
- name: spell check
|
|
26
|
+
run: codespell {staged_files}
|
|
27
|
+
glob: "*.{rb,md,gemspec}"
|
|
28
|
+
|
|
29
|
+
- name: format markdown
|
|
30
|
+
run: mdformat {staged_files}
|
|
31
|
+
glob: "*.md"
|
|
32
|
+
stage_fixed: true
|
|
33
|
+
|
|
34
|
+
- name: scan for secrets
|
|
35
|
+
run: detect-secrets-hook --baseline .secrets.baseline
|