soka-rails 0.0.3 → 0.0.5
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/.rubocop.yml +1 -1
- data/CHANGELOG.md +20 -0
- data/README.md +78 -3
- data/lib/generators/soka/agent/templates/agent.rb.tt +14 -2
- data/lib/soka/rails/version.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 727e9c42b3117990a0eb0237b5a12e9db9eafe6ad5cb3b2e6992a5de89920153
|
4
|
+
data.tar.gz: 48072884855827edbad3bba576d324d6d79dd888ba347d8b67af5977341acbdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32e97666a15b7e655a9a208c439b55c287a8701fac1a03282553aa0b14d4d81a28e7f564509069cce9d5142affeae1fa13dcf836699a80e4bd8bc455d1e220bb
|
7
|
+
data.tar.gz: 31d91665ae6af181d9db5a33cecb18de6561f31d259095a89d10ba01e23d0aa87346094d58d4b47fbebc6ec5539200e1e26e323fa92eb3835c552abd613a0070
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.0.5] - 2025-08-05
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- Support for Ruby 3.1, 3.2, and 3.3
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
- Updated CI/CD workflows to test all supported Ruby versions
|
15
|
+
- Adjusted RuboCop target version to minimum supported version (3.1)
|
16
|
+
- Updated gemspec minimum Ruby version requirement
|
17
|
+
- Upgraded soka dependency to 0.0.5
|
18
|
+
|
19
|
+
## [0.0.4] - 2025-08-04
|
20
|
+
|
21
|
+
### Added
|
22
|
+
- Support for dynamic instructions in Soka v0.0.4
|
23
|
+
- Ability to generate agent instructions dynamically via methods
|
24
|
+
- Context-aware behavior based on runtime conditions (environment, time, user, etc.)
|
25
|
+
- Updated README with dynamic instructions examples
|
26
|
+
- Enhanced agent generator template with dynamic instructions examples
|
27
|
+
|
8
28
|
## [0.0.3] - 2025-08-04
|
9
29
|
|
10
30
|
### Added
|
data/README.md
CHANGED
@@ -26,8 +26,9 @@ Soka Rails is a Rails integration package for the Soka AI Agent Framework, provi
|
|
26
26
|
- 🔄 **Rails Lifecycle Hooks**: Integrates with Rails logging and error tracking
|
27
27
|
- 💾 **Session Memory Support**: Store conversation history in Rails sessions
|
28
28
|
- 🔐 **Authentication Integration**: Works with Rails authentication systems
|
29
|
-
- 🗣️ **Custom Instructions**: Customize agent personality and behavior
|
30
|
-
-
|
29
|
+
- 🗣️ **Custom Instructions**: Customize agent personality and behavior
|
30
|
+
- 🎯 **Dynamic Instructions**: Generate instructions dynamically via methods
|
31
|
+
- 🌐 **Multilingual Thinking**: Support for reasoning in different languages
|
31
32
|
|
32
33
|
## Installation
|
33
34
|
|
@@ -132,6 +133,15 @@ class WeatherAgent < ApplicationAgent
|
|
132
133
|
tool WeatherApiTool
|
133
134
|
tool LocationTool
|
134
135
|
|
136
|
+
# Custom instructions
|
137
|
+
# instructions "You are a helpful weather assistant"
|
138
|
+
|
139
|
+
# Dynamic instructions via method
|
140
|
+
# instructions :generate_instructions
|
141
|
+
|
142
|
+
# Multilingual thinking
|
143
|
+
# think_in 'zh-TW' # Think in Traditional Chinese
|
144
|
+
|
135
145
|
# Rails integration hooks
|
136
146
|
before_action :log_request
|
137
147
|
on_error :notify_error_service
|
@@ -146,6 +156,15 @@ class WeatherAgent < ApplicationAgent
|
|
146
156
|
Rails.error.report(error, context: context)
|
147
157
|
:continue
|
148
158
|
end
|
159
|
+
|
160
|
+
# Example of dynamic instructions method
|
161
|
+
# def generate_instructions
|
162
|
+
# <<~PROMPT
|
163
|
+
# You are a weather assistant for #{Rails.env} environment.
|
164
|
+
# Current time: #{Time.zone.now}
|
165
|
+
# User location: #{request&.location&.city || 'Unknown'}
|
166
|
+
# PROMPT
|
167
|
+
# end
|
149
168
|
end
|
150
169
|
```
|
151
170
|
|
@@ -196,6 +215,59 @@ class ConversationsController < ApplicationController
|
|
196
215
|
end
|
197
216
|
```
|
198
217
|
|
218
|
+
### Custom Instructions and Dynamic Instructions
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
class CustomerSupportAgent < ApplicationAgent
|
222
|
+
# Static instructions
|
223
|
+
instructions <<~PROMPT
|
224
|
+
You are a friendly customer support agent.
|
225
|
+
Always be polite and helpful.
|
226
|
+
Use emojis when appropriate.
|
227
|
+
PROMPT
|
228
|
+
|
229
|
+
# OR Dynamic instructions via method
|
230
|
+
instructions :generate_context_aware_instructions
|
231
|
+
|
232
|
+
private
|
233
|
+
|
234
|
+
def generate_context_aware_instructions
|
235
|
+
business_hours = (9..17).include?(Time.zone.now.hour)
|
236
|
+
|
237
|
+
<<~PROMPT
|
238
|
+
You are a customer support agent for #{Rails.application.class.module_parent_name}.
|
239
|
+
Environment: #{Rails.env}
|
240
|
+
Current time: #{Time.zone.now.strftime('%Y-%m-%d %H:%M:%S %Z')}
|
241
|
+
Business hours: #{business_hours ? 'Yes' : 'No (after hours)'}
|
242
|
+
#{business_hours ? 'Provide immediate assistance.' : 'Inform about callback options.'}
|
243
|
+
PROMPT
|
244
|
+
end
|
245
|
+
end
|
246
|
+
```
|
247
|
+
|
248
|
+
### Multilingual Thinking
|
249
|
+
|
250
|
+
```ruby
|
251
|
+
class GlobalSupportAgent < ApplicationAgent
|
252
|
+
# Set default thinking language
|
253
|
+
think_in 'zh-TW' # Think in Traditional Chinese
|
254
|
+
|
255
|
+
# Or set dynamically at runtime
|
256
|
+
def initialize(options = {})
|
257
|
+
super
|
258
|
+
# Detect user's preferred language from session or request
|
259
|
+
self.think_in = detect_user_language
|
260
|
+
end
|
261
|
+
|
262
|
+
private
|
263
|
+
|
264
|
+
def detect_user_language
|
265
|
+
# Logic to detect language from session, user preferences, or request headers
|
266
|
+
session[:locale] || I18n.locale || 'en'
|
267
|
+
end
|
268
|
+
end
|
269
|
+
```
|
270
|
+
|
199
271
|
### Event Streaming
|
200
272
|
|
201
273
|
```ruby
|
@@ -248,6 +320,9 @@ class WeatherAgent < ApplicationAgent
|
|
248
320
|
# Custom instructions
|
249
321
|
# instructions "You are a weather expert. Always provide temperature in both Celsius and Fahrenheit."
|
250
322
|
|
323
|
+
# Dynamic instructions via method
|
324
|
+
# instructions :generate_instructions
|
325
|
+
|
251
326
|
# Multilingual thinking
|
252
327
|
# think_in 'en' # Supported: 'en', 'zh-TW', 'ja-JP', etc.
|
253
328
|
|
@@ -397,7 +472,7 @@ end
|
|
397
472
|
|
398
473
|
- Ruby: >= 3.4
|
399
474
|
- Rails: >= 7.0
|
400
|
-
- Soka: >=
|
475
|
+
- Soka: >= 0.0.4
|
401
476
|
|
402
477
|
## Contributing
|
403
478
|
|
@@ -10,10 +10,13 @@ class <%= @agent_class_name %> < ApplicationAgent
|
|
10
10
|
# tool YourTool
|
11
11
|
<% end -%>
|
12
12
|
|
13
|
-
# Custom instructions
|
13
|
+
# Custom instructions
|
14
14
|
# instructions "You are a helpful assistant specialized in..."
|
15
15
|
|
16
|
-
#
|
16
|
+
# Dynamic instructions via method
|
17
|
+
# instructions :generate_instructions # Reference a method for dynamic instructions
|
18
|
+
|
19
|
+
# Multilingual thinking
|
17
20
|
# think_in 'en' # 'en', 'zh-TW', 'ja-JP', etc.
|
18
21
|
|
19
22
|
# Configuration
|
@@ -28,4 +31,13 @@ class <%= @agent_class_name %> < ApplicationAgent
|
|
28
31
|
# private
|
29
32
|
|
30
33
|
# Implement your private methods here
|
34
|
+
|
35
|
+
# Example of dynamic instructions method
|
36
|
+
# def generate_instructions
|
37
|
+
# <<~PROMPT
|
38
|
+
# You are a #{Rails.env} environment assistant.
|
39
|
+
# Current Time: #{Time.zone.now.strftime('%Y-%m-%d %H:%M:%S')}
|
40
|
+
# User: #{current_user&.name || 'Guest'}
|
41
|
+
# PROMPT
|
42
|
+
# end
|
31
43
|
end
|
data/lib/soka/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soka-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiunjiun
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date:
|
11
|
+
date: 2025-08-05 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: rails
|
@@ -35,14 +36,14 @@ dependencies:
|
|
35
36
|
requirements:
|
36
37
|
- - "~>"
|
37
38
|
- !ruby/object:Gem::Version
|
38
|
-
version: 0.0.
|
39
|
+
version: 0.0.5
|
39
40
|
type: :runtime
|
40
41
|
prerelease: false
|
41
42
|
version_requirements: !ruby/object:Gem::Requirement
|
42
43
|
requirements:
|
43
44
|
- - "~>"
|
44
45
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.0.
|
46
|
+
version: 0.0.5
|
46
47
|
- !ruby/object:Gem::Dependency
|
47
48
|
name: zeitwerk
|
48
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +105,7 @@ metadata:
|
|
104
105
|
source_code_uri: https://github.com/jiunjiun/soka-rails
|
105
106
|
changelog_uri: https://github.com/jiunjiun/soka-rails/blob/main/CHANGELOG.md
|
106
107
|
rubygems_mfa_required: 'true'
|
108
|
+
post_install_message:
|
107
109
|
rdoc_options: []
|
108
110
|
require_paths:
|
109
111
|
- lib
|
@@ -111,14 +113,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
113
|
requirements:
|
112
114
|
- - ">="
|
113
115
|
- !ruby/object:Gem::Version
|
114
|
-
version: '3.
|
116
|
+
version: '3.1'
|
115
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
118
|
requirements:
|
117
119
|
- - ">="
|
118
120
|
- !ruby/object:Gem::Version
|
119
121
|
version: '0'
|
120
122
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.3.27
|
124
|
+
signing_key:
|
122
125
|
specification_version: 4
|
123
126
|
summary: Rails integration for Soka AI Agent Framework
|
124
127
|
test_files: []
|