soka-rails 0.0.1 → 0.0.3

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: a6730ee1778d50df9b15f89e90cae6ee7ad6e5ccad4957859ab99b328cd4d37f
4
- data.tar.gz: 51d7ca5f8469231d197f74317661f02d4a9cdfa6a3ba4deb92d85928aab51bf3
3
+ metadata.gz: 8e5ecc6bd862b68971cd0b63fe3535e24b110844dbb93d69a6088af129b1806e
4
+ data.tar.gz: e7d13cca5d699e68f1224a6f3981b372abc1ac3072845aec7f10a47f31702517
5
5
  SHA512:
6
- metadata.gz: 2b5b44129a5845a5d9f4054f6b8128620767092b9db3862c715d12d9383d8d76dea3f0abe0cac00b67f91806a1247970dc9870828201795ce2d7396252435da3
7
- data.tar.gz: 48beed549db55eee4f4ca2d9a20dae03ec51b6de0103dc9c4a4519d5938f64be872c2ab41cee3b88766fe32cebfd32d44268f8fb9dc741c5ceee8fb0c4f47435
6
+ metadata.gz: 8fccb922b42ad0ecebb6aa56e85aa2adca7235b0bf8f8f706abbf426e777202674329662d6982ada09fa15ed5c4962ee354e33f0ffaed26c24063305b09f1109
7
+ data.tar.gz: 7a626cb54ba4272cb95cdaa895098fc99f3c14f3873a26f3ae5c8c41e705b9ffb56c22ac24f34874715b8f84920a023864ce54f8c02471e5dd0b8cdd892b7f80
data/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ 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.3] - 2025-08-04
9
+
10
+ ### Added
11
+ - Upgrade to Soka v0.0.3 with custom instructions and multilingual support
12
+
13
+ ## [0.0.2] - 2025-08-01
14
+
15
+ ### Fixed
16
+ - Comment out private keyword in agent template
17
+ - Resolve Rails autoloading issues for agents and tools
18
+
19
+ ### Changed
20
+ - Add link to full changelog in release notes
21
+
8
22
  ## [0.0.1] - 2025-08-01
9
23
 
10
24
  ### Added
data/DESIGN.md CHANGED
@@ -478,7 +478,6 @@ module Soka
478
478
  def mock_ai_response(response_attrs = {})
479
479
  default_response = {
480
480
  final_answer: "Mocked answer",
481
- confidence_score: 0.95,
482
481
  status: :completed,
483
482
  iterations: 1,
484
483
  thought_process: []
@@ -616,7 +615,6 @@ class ConversationsController < ApplicationController
616
615
  def build_response(result)
617
616
  {
618
617
  answer: result.final_answer,
619
- confidence: result.confidence_score,
620
618
  status: result.status,
621
619
  metadata: {
622
620
  iterations: result.iterations,
@@ -652,7 +650,6 @@ class ProcessConversationJob < ApplicationJob
652
650
  user.conversations.create!(
653
651
  message: message,
654
652
  response: result.final_answer,
655
- confidence: result.confidence_score,
656
653
  metadata: {
657
654
  iterations: result.iterations,
658
655
  thought_process: result.thought_process
data/README.md CHANGED
@@ -26,6 +26,8 @@ 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 (Soka v0.0.3+)
30
+ - 🌐 **Multilingual Thinking**: Support for reasoning in different languages (Soka v0.0.3+)
29
31
 
30
32
  ## Installation
31
33
 
@@ -91,7 +93,7 @@ class ConversationsController < ApplicationController
91
93
 
92
94
  render json: {
93
95
  answer: result.final_answer,
94
- confidence: result.confidence_score
96
+ status: result.status
95
97
  }
96
98
  end
97
99
  end
@@ -243,6 +245,12 @@ class WeatherAgent < ApplicationAgent
243
245
  tool TemperatureTool
244
246
  tool HumidityTool
245
247
 
248
+ # Custom instructions
249
+ # instructions "You are a weather expert. Always provide temperature in both Celsius and Fahrenheit."
250
+
251
+ # Multilingual thinking
252
+ # think_in 'en' # Supported: 'en', 'zh-TW', 'ja-JP', etc.
253
+
246
254
  # Configuration
247
255
  # max_iterations 10
248
256
  # timeout 30
data/SPEC.md CHANGED
@@ -291,7 +291,6 @@ class ConversationsController < ApplicationController
291
291
 
292
292
  render json: {
293
293
  answer: result.final_answer,
294
- confidence: result.confidence_score,
295
294
  status: result.status
296
295
  }
297
296
  end
@@ -10,6 +10,12 @@ class <%= @agent_class_name %> < ApplicationAgent
10
10
  # tool YourTool
11
11
  <% end -%>
12
12
 
13
+ # Custom instructions (new in v0.0.3)
14
+ # instructions "You are a helpful assistant specialized in..."
15
+
16
+ # Multilingual thinking (new in v0.0.3)
17
+ # think_in 'en' # 'en', 'zh-TW', 'ja-JP', etc.
18
+
13
19
  # Configuration
14
20
  # max_iterations 10
15
21
  # timeout 30
@@ -19,7 +25,7 @@ class <%= @agent_class_name %> < ApplicationAgent
19
25
  # after_action :your_method
20
26
  # on_error :your_method
21
27
 
22
- private
28
+ # private
23
29
 
24
30
  # Implement your private methods here
25
31
  end
@@ -15,14 +15,14 @@ RSpec.describe <%= @tool_class_name %>Tool, type: :tool do
15
15
  }
16
16
  end
17
17
 
18
- it 'executes successfully with valid params' do
18
+ it 'calls successfully with valid params' do
19
19
  result = tool.call(**params)
20
20
 
21
21
  expect(result).to be_a(Hash)
22
22
  expect(result[:result]).to be_present
23
23
  end
24
24
  <% else -%>
25
- it 'executes successfully' do
25
+ it 'calls successfully' do
26
26
  result = tool.call
27
27
 
28
28
  expect(result).to be_a(Hash)
@@ -1,14 +1,65 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'soka'
4
+
3
5
  module Soka
4
6
  module Rails
5
7
  # Rails integration for Soka, configuring autoloading and initializers
8
+ #
9
+ # This Railtie ensures that Soka agents and tools can be autoloaded
10
+ # properly by Rails' Zeitwerk autoloader. It sets up app/soka as a
11
+ # root directory and collapses subdirectories to avoid namespace requirements.
12
+ #
13
+ # @example Directory structure
14
+ # app/soka/
15
+ # ├── agents/
16
+ # │ ├── application_agent.rb # Defines ApplicationAgent (not Agents::ApplicationAgent)
17
+ # │ └── search_agent.rb # Defines SearchAgent (not Agents::SearchAgent)
18
+ # └── tools/
19
+ # ├── application_tool.rb # Defines ApplicationTool (not Tools::ApplicationTool)
20
+ # └── search_tool.rb # Defines SearchTool (not Tools::SearchTool)
6
21
  class Railtie < ::Rails::Railtie
7
- # Configure autoloading - executed after Rails completes basic setup
8
- initializer 'soka.setup_autoloading', before: :set_autoload_paths do |app|
9
- # Add app/soka to autoload paths
10
- # eager_load: true will automatically include all subdirectories
11
- app.config.paths.add 'app/soka', eager_load: true
22
+ # Configuration for collapsed directories
23
+ # Users can modify this in an initializer if needed
24
+ config.soka_collapsed_dirs = %w[agents tools]
25
+
26
+ # Set up Zeitwerk autoloading for Soka directories
27
+ #
28
+ # This initializer runs after Rails sets up its autoloaders but before
29
+ # eager loading begins. It configures app/soka as a root directory
30
+ # and collapses specified subdirectories.
31
+ initializer 'soka.setup_autoloading',
32
+ after: :setup_once_autoloader,
33
+ before: :eager_load! do |app|
34
+ setup_soka_autoloading(app)
35
+ end
36
+
37
+ private
38
+
39
+ def setup_soka_autoloading(app)
40
+ soka_path = app.root.join('app/soka')
41
+ return unless soka_path.exist?
42
+
43
+ configure_autoloader(soka_path)
44
+ rescue StandardError => e
45
+ ::Rails.logger&.error "[Soka] Failed to configure autoloading: #{e.message}"
46
+ raise
47
+ end
48
+
49
+ def configure_autoloader(soka_path)
50
+ # Add app/soka as a root directory without namespace
51
+ # This allows classes in app/soka to be loaded at the top level
52
+ ::Rails.autoloaders.main.push_dir(soka_path.to_s)
53
+
54
+ # Collapse configured directories
55
+ # This removes the directory name from the expected constant path
56
+ # e.g., app/soka/agents/foo.rb defines Foo instead of Agents::Foo
57
+ config.soka_collapsed_dirs.each do |dir|
58
+ dir_path = soka_path.join(dir)
59
+ ::Rails.autoloaders.main.collapse(dir_path.to_s) if dir_path.exist?
60
+ end
61
+
62
+ ::Rails.logger&.debug "[Soka] Configured autoloading for #{soka_path}"
12
63
  end
13
64
  end
14
65
  end
@@ -19,7 +19,6 @@ module Soka
19
19
  def build_mock_response(attrs)
20
20
  default_response = {
21
21
  final_answer: 'Mocked answer',
22
- confidence_score: 0.95,
23
22
  status: :completed,
24
23
  iterations: 1,
25
24
  thought_process: []
@@ -95,7 +94,6 @@ module Soka
95
94
  default_attrs = {
96
95
  status: :completed,
97
96
  final_answer: 'Success',
98
- confidence_score: 0.95,
99
97
  iterations: 1
100
98
  }
101
99
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Soka
4
4
  module Rails
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soka-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiunjiun
@@ -35,14 +35,14 @@ dependencies:
35
35
  requirements:
36
36
  - - "~>"
37
37
  - !ruby/object:Gem::Version
38
- version: 0.0.1
38
+ version: 0.0.3
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
42
42
  requirements:
43
43
  - - "~>"
44
44
  - !ruby/object:Gem::Version
45
- version: 0.0.1
45
+ version: 0.0.3
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: zeitwerk
48
48
  requirement: !ruby/object:Gem::Requirement