ask-rails 0.15.3 → 0.15.4

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -148
  3. data/lib/ask/rails/version.rb +1 -1
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e259cec23b1c2cc2ffcf28aa4e88631c6b8324f06faf54796bfe3dd25811c7b8
4
- data.tar.gz: 77f68fbcc68972b2f2e7ee25b4c191f3323ef7ac7fe67b87e28c34c133d76888
3
+ metadata.gz: dcbbe5b90ea4ca26543e8ff114cf09eece8d4bb86870a901e0c01410bb5cd8be
4
+ data.tar.gz: 1c0f1b2a39714a48432c2486d853803fa300eb1f170703508f09dd5db3f61b7b
5
5
  SHA512:
6
- metadata.gz: 57ac3ea96821f89d216ef96f6ef903c07c054f8fbced39df03753531a5034edfe5eee0edf4cd6895ca7f187509fec6a17805893ae5958b7262f7e5311c734c9d
7
- data.tar.gz: 91b579013d926feb5e5d4991ed65f50478e7d537f272c9113e2e504f3763c36b8f815e4d4974032ce5ea51213b81abf117c5633403b9be4bbe4d9e5d5934fb37
6
+ metadata.gz: 29a0091cf06a3960bdaf7251f1a2cd3ce38a4cd9f4004d322445e33da7b93373a5db8eb4c859b0e3d1dcaf49cb8933f8ea592be71fed0387cafeda825eb87979
7
+ data.tar.gz: b12f575ef3851ecd03dc223ca406edf2081dfc177df72af5cff712ceaeedf189b050bc7e67260afb1dfd5065ea9138a3f8338bb4e61e23915c607c2648ac1758
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # ask-rails
2
2
 
3
- Rails integration for the [ask-rb](https://github.com/ask-rb) ecosystem. Provides generators, file conventions, and a railtie for building agents and workflows in your Rails app.
3
+ [![Gem Version](https://badge.fury.io/rb/ask-rails.svg)](https://badge.fury.io/rb/ask-rails)
4
+
5
+ Rails integration for the [ask-rb](https://github.com/ask-rb) ecosystem. Provides generators, file conventions, and a railtie for building user-facing AI features (agents, workflows, actions) inside a Rails app. Requires Rails 7.1+.
4
6
 
5
7
  ## Installation
6
8
 
@@ -8,7 +10,7 @@ Add to your Gemfile:
8
10
 
9
11
  ```ruby
10
12
  gem "ask-rails"
11
- gem "ask-graph" # optional add only if you use workflows
13
+ gem "ask-graph" # optional, add only if you use workflows
12
14
  ```
13
15
 
14
16
  Run the installer:
@@ -22,193 +24,75 @@ This creates:
22
24
 
23
25
  | File | Purpose |
24
26
  |---|---|
25
- | `config/initializers/ask.rb` | Agent + workflow configuration (graph block only generated when ask-graph is installed) |
27
+ | `config/initializers/ask.rb` | Agent, workflow, and action configuration |
26
28
  | `app/agents/application_agent.rb` | Base class for your agents |
27
29
  | `app/actions/application_action.rb` | Base class for your actions |
28
30
  | `app/workflows/application_workflow.rb` | Base class for your workflows (only with ask-graph) |
29
- | `db/migrate/*_create_ask_state.rb` | Shared key-value state table — workflow checkpoints and agent session indexes |
31
+ | `db/migrate/*_create_ask_state.rb` | Shared key-value state table |
30
32
  | `db/migrate/*_create_ask_audit_logs.rb` | Agent session audit log |
31
33
 
32
- The `ask_state` table is backed by `Ask::Rails::State` an ActiveRecord adapter that works with any database (PostgreSQL, MySQL, SQLite). Workflow checkpoints and agent session persistence share the same table, keyed by convention.
34
+ No controllers, views, or routes are generated. The admin chat UI ships in [ask-rails-harness](https://github.com/ask-rb/ask-rails-harness).
33
35
 
34
36
  ## Generators
35
37
 
36
- ### `ask:agent NAME`
37
-
38
- Scaffolds a new agent:
39
-
40
- ```bash
41
- rails generate ask:agent support_bot
42
- ```
38
+ - `rails generate ask:agent NAME`: creates `app/agents/<name>/` with `agent.rb`, `instructions.md`, and `tools/`.
39
+ - `rails generate ask:action NAME [NAMESPACE]`: creates an action under `app/actions/` (e.g. `ask:action chats create` → `app/actions/chats/create.rb`).
40
+ - `rails generate ask:workflow NAME`: creates `app/workflows/<name>/workflow.rb` and `steps/` (requires ask-graph).
41
+ - `rails generate ask:install --skip-graph`: skips workflow scaffolding when you don't use ask-graph.
43
42
 
44
- Creates the agent directory convention used by ask-agent discovery:
45
-
46
- ```
47
- app/agents/support_bot/
48
- ├── agent.rb # module SupportBot; class Agent < ApplicationAgent
49
- ├── instructions.md # auto-loaded as the system prompt
50
- └── tools/ # per-agent tools (referenced with `tools :tool_name`)
51
- ```
43
+ ## Quick Start
52
44
 
53
45
  ```ruby
54
46
  # app/agents/support_bot/agent.rb
55
47
  module SupportBot
56
48
  class Agent < ApplicationAgent
57
49
  model "gpt-4o"
58
- # tools :search_knowledge_base
59
- end
60
- end
61
- ```
62
-
63
- Run it with `Ask::Agent.new("support_bot")`. The directory name is the
64
- agent name — keep the file named `agent.rb`.
65
-
66
- ### `ask:workflow NAME`
67
-
68
- Scaffolds a new workflow (requires ask-graph):
69
-
70
- ```bash
71
- rails generate ask:workflow notify_customer
72
- ```
73
-
74
- Creates `app/workflows/notify_customer/workflow.rb` and `app/workflows/notify_customer/steps/`:
75
-
76
- ```ruby
77
- module NotifyCustomer
78
- class Workflow < ApplicationWorkflow
79
- # step SomeStep
80
- end
81
- end
82
- ```
83
-
84
- ### `ask:action NAME [NAMESPACE]`
85
-
86
- Scaffolds a new action — a user-facing operation callable from any channel (web, Slack, voice) by name:
87
-
88
- ```bash
89
- rails generate ask:action create_workspace # app/actions/create_workspace.rb
90
- rails generate ask:action chats create # app/actions/chats/create.rb
91
- ```
92
-
93
- Creates `app/actions/chats/create.rb`:
94
-
95
- ```ruby
96
- module Chats
97
- class Create < ApplicationAction
98
- def call
99
- Ask::Actions::Result.ok(message: "Chat created", data: { id: record.id })
100
- end
101
- end
102
- end
103
- ```
104
-
105
- ### Skipping workflow scaffolding
106
-
107
- If you don't use ask-graph, install with:
108
-
109
- ```bash
110
- rails generate ask:install --skip-graph
111
- ```
112
-
113
- The initializer still works — the graph block is omitted when ask-graph isn't installed.
114
-
115
- ## Usage
116
-
117
- ### Agents
118
-
119
- ```ruby
120
- # app/agents/support_bot.rb
121
- module Agents
122
- class SupportBot < ApplicationAgent
123
- model "gpt-4o"
124
- system_prompt "You help users with support questions."
125
-
126
- tool :bash
127
- tool :read
128
50
  end
129
51
  end
130
52
  ```
131
53
 
132
54
  ```ruby
133
55
  agent = Ask::Agent.new("support_bot")
134
- response = agent.run("Find all open issues in the codebase")
56
+ response = agent.run("How do I reset my password?")
135
57
  puts response
136
58
  ```
137
59
 
138
- ### Workflows
60
+ The directory name is the agent name. `instructions.md` next to `agent.rb` is auto-loaded as the system prompt.
139
61
 
140
- ```ruby
141
- # app/workflows/order_fulfillment/workflow.rb
142
- module OrderFulfillment
143
- class Workflow < ApplicationWorkflow
144
- step ValidatePayment
145
- step NotifyCustomer
146
- step ShipOrder
147
- end
148
- end
149
- ```
62
+ ## Essential API
150
63
 
151
- ```ruby
152
- # app/workflows/order_fulfillment/steps/validate_payment.rb
153
- module OrderFulfillment
154
- class ValidatePayment
155
- def call(context)
156
- context.payment = PaymentService.charge(context.input[:order])
157
- end
158
- end
159
- end
160
- ```
64
+ ### Ask::Actions: dispatch operations by name from any channel
161
65
 
162
66
  ```ruby
163
- result = OrderFulfillment::Workflow.call(order: order)
164
- result.payment
165
- ```
166
-
167
- Checkpoints are saved to the shared `ask_state` table, so workflows resume after crashes.
168
-
169
- ### Actions
170
-
171
- Actions are the operations your users trigger — booking an appointment, creating a chat, upgrading a plan. They live in `app/actions/` and are dispatched **by name**, so any channel (web controller, Slack handler, voice agent) calls the same operation:
172
-
173
- ```ruby
174
- # app/actions/chats/create.rb
175
- module Chats
176
- class Create < ApplicationAction
177
- def call
178
- chat = context.channel.start_new_chat!
179
- Ask::Actions::Result.ok(message: "Chat created", data: { chat: chat })
180
- end
181
- end
182
- end
183
- ```
184
-
185
- ```ruby
186
- # From any channel:
187
67
  context = Ask::Actions::Context.new(user: current_user, session: session)
188
68
  result = Ask::Actions.dispatch(action: "chats.create", context: context, params: { name: "general" })
189
- result.ok? # => true
190
- result.message # => "Chat created"
191
- result.data # => { chat: ... }
69
+ result.ok? # => true
70
+ result.message # => "Chat created"
192
71
  ```
193
72
 
194
- By convention, `"chats.create"` resolves to `Chats::Create` — no registration needed (Zeitwerk autoloads `app/actions/`). Register explicitly to override the convention or to list actions in `Ask::Actions.available`:
73
+ `"chats.create"` resolves to `Chats::Create` (Zeitwerk autoloads `app/actions/`). Register explicitly to override the convention or list actions:
195
74
 
196
75
  ```ruby
197
- # config/initializers/ask.rb
198
76
  Ask::Actions.register "chats.create", Chats::Create
77
+ Ask::Actions.available # => ["chats.create"]
199
78
  ```
200
79
 
201
- Unknown action names raise `Ask::Actions::Backend::UnknownAction` with a helpful message.
80
+ Actions return an `Ask::Actions::Result` (`Result.ok` / `Result.error`). Unknown action names raise `Ask::Actions::Backend::UnknownAction`.
81
+
82
+ ### Ask::Rails::State: ActiveRecord-backed state
202
83
 
203
- ## Configuration
84
+ `Ask::Rails::State` backs the `ask_state` table and works with any database (PostgreSQL, MySQL, SQLite). ask-graph stores workflow checkpoints there; ask-agent session persistence uses the same table, keyed by convention.
204
85
 
205
- API keys are resolved automatically by `Ask::Auth`:
86
+ ## Full documentation
206
87
 
207
- - **Environment variables:** `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, etc.
208
- - **Rails credentials:** `rails credentials:edit` → add `ask.openai`, `ask.anthropic`
209
- - **File:** `~/.ask/credentials.yml`
88
+ The full ask-rb documentation lives at https://ask-rb.github.io/ask-docs. [Rails app integration](https://ask-rb.github.io/ask-docs/getting-started/rails-app) covers ask-rails in depth. API reference: https://ask-rb.github.io/ask-docs/reference/api.
210
89
 
211
- No manual credential setup is required.
90
+ ## Development
91
+
92
+ ```bash
93
+ bundle install
94
+ bundle exec rake test
95
+ ```
212
96
 
213
97
  ## License
214
98
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module Rails
5
- VERSION = "0.15.3"
5
+ VERSION = "0.15.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.3
4
+ version: 0.15.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '0.1'
32
+ version: 0.40.1
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '0.1'
39
+ version: 0.40.1
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: minitest
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubygems_version: 4.0.3
151
+ rubygems_version: 4.0.18
152
152
  specification_version: 4
153
153
  summary: Rails integration for the ask-rb ecosystem
154
154
  test_files: []