ruby_conversations 1.0.6 → 1.0.8

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -16
  3. data/app/models/concerns/ruby_conversations/conversation_chat.rb +49 -0
  4. data/app/models/concerns/ruby_conversations/conversation_messages.rb +18 -0
  5. data/app/models/concerns/ruby_conversations/llm_credentials.rb +40 -0
  6. data/app/models/concerns/ruby_conversations/message_api_attributes.rb +39 -0
  7. data/app/models/concerns/ruby_conversations/message_attributes.rb +44 -0
  8. data/app/models/concerns/ruby_conversations/message_processing.rb +48 -0
  9. data/app/models/concerns/ruby_conversations/message_validation.rb +48 -0
  10. data/app/models/concerns/ruby_conversations/storable.rb +13 -0
  11. data/app/models/ruby_conversations/conversation.rb +102 -0
  12. data/app/models/ruby_conversations/message.rb +108 -0
  13. data/app/models/ruby_conversations/message_builder.rb +45 -20
  14. data/app/models/ruby_conversations/message_input.rb +69 -0
  15. data/app/models/ruby_conversations/message_prompt.rb +110 -0
  16. data/app/models/ruby_conversations/prompt.rb +48 -39
  17. data/lib/ruby_conversations/aws_credential_provider.rb +99 -0
  18. data/lib/ruby_conversations/client.rb +90 -0
  19. data/lib/ruby_conversations/configuration.rb +3 -13
  20. data/lib/ruby_conversations/engine.rb +2 -0
  21. data/lib/ruby_conversations/errors.rb +9 -0
  22. data/lib/ruby_conversations/version.rb +1 -1
  23. data/lib/ruby_conversations.rb +16 -30
  24. metadata +55 -76
  25. data/Rakefile +0 -12
  26. data/app/models/concerns/ruby_conversations/messageable.rb +0 -13
  27. data/app/models/concerns/ruby_conversations/versionable.rb +0 -20
  28. data/app/models/ruby_conversations/ai_conversation.rb +0 -116
  29. data/app/models/ruby_conversations/ai_message.rb +0 -28
  30. data/app/models/ruby_conversations/ai_message_input.rb +0 -22
  31. data/app/models/ruby_conversations/ai_message_prompt.rb +0 -28
  32. data/app/models/ruby_conversations/prompt_version.rb +0 -16
  33. data/lib/generators/ruby_conversations/install/install_generator.rb +0 -60
  34. data/lib/generators/ruby_conversations/install/templates/README.md +0 -42
  35. data/lib/generators/ruby_conversations/install/templates/initializer.rb.erb +0 -18
  36. data/lib/generators/ruby_conversations/install/templates/migrations/create_ai_conversations.rb.erb +0 -13
  37. data/lib/generators/ruby_conversations/install/templates/migrations/create_ai_message_inputs.rb.erb +0 -13
  38. data/lib/generators/ruby_conversations/install/templates/migrations/create_ai_message_prompts.rb.erb +0 -18
  39. data/lib/generators/ruby_conversations/install/templates/migrations/create_ai_messages.rb.erb +0 -18
  40. data/lib/generators/ruby_conversations/install/templates/migrations/create_ai_tool_calls.rb.erb +0 -15
  41. data/lib/generators/ruby_conversations/install/templates/migrations/create_prompt_versions.rb.erb +0 -14
  42. data/lib/generators/ruby_conversations/install/templates/migrations/create_prompts.rb.erb +0 -16
  43. data/lib/ruby_conversations/jwt_client.rb +0 -23
  44. data/lib/ruby_conversations/storage/base.rb +0 -28
  45. data/lib/ruby_conversations/storage/local.rb +0 -30
  46. data/lib/ruby_conversations/storage/remote.rb +0 -93
metadata CHANGED
@@ -1,93 +1,93 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_conversations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Shippy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-03 00:00:00.000000000 Z
11
+ date: 2025-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: faraday
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '7.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '7.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: jwt
28
+ name: aws-sdk-core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.0'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rails
42
+ name: faraday
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '7.0'
47
+ version: '2.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '7.0'
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: ruby_llm
56
+ name: jwt
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.0'
61
+ version: '2.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.0'
68
+ version: '2.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: zeitwerk
70
+ name: ruby_llm
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.5'
75
+ version: '1.1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.5'
82
+ version: '1.1'
83
83
  - !ruby/object:Gem::Dependency
84
- name: bootsnap
84
+ name: strongmind-auth
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.0'
90
- type: :development
90
+ type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
@@ -95,35 +95,35 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: database_cleaner-active_record
98
+ name: zeitwerk
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
103
+ version: '2.6'
104
+ type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '2.6'
111
111
  - !ruby/object:Gem::Dependency
112
- name: dotenv-rails
112
+ name: bootsnap
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '1.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '1.0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: factory_bot_rails
126
+ name: dotenv-rails
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -137,7 +137,7 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: parallel_tests
140
+ name: factory_bot
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: pg
154
+ name: pry-byebug
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: pry-byebug
168
+ name: rspec
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -234,21 +234,7 @@ dependencies:
234
234
  - - ">="
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
- - !ruby/object:Gem::Dependency
238
- name: sqlite3
239
- requirement: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - ">="
242
- - !ruby/object:Gem::Version
243
- version: '0'
244
- type: :development
245
- prerelease: false
246
- version_requirements: !ruby/object:Gem::Requirement
247
- requirements:
248
- - - ">="
249
- - !ruby/object:Gem::Version
250
- version: '0'
251
- description: 'A Rails engine for managing AI conversations with support for both '
237
+ description: A Ruby client library for managing AI conversations via a remote API.
252
238
  email:
253
239
  - paul.shippy@strongmind.com
254
240
  executables: []
@@ -256,33 +242,26 @@ extensions: []
256
242
  extra_rdoc_files: []
257
243
  files:
258
244
  - README.md
259
- - Rakefile
260
- - app/models/concerns/ruby_conversations/messageable.rb
261
- - app/models/concerns/ruby_conversations/versionable.rb
262
- - app/models/ruby_conversations/ai_conversation.rb
263
- - app/models/ruby_conversations/ai_message.rb
264
- - app/models/ruby_conversations/ai_message_input.rb
265
- - app/models/ruby_conversations/ai_message_prompt.rb
245
+ - app/models/concerns/ruby_conversations/conversation_chat.rb
246
+ - app/models/concerns/ruby_conversations/conversation_messages.rb
247
+ - app/models/concerns/ruby_conversations/llm_credentials.rb
248
+ - app/models/concerns/ruby_conversations/message_api_attributes.rb
249
+ - app/models/concerns/ruby_conversations/message_attributes.rb
250
+ - app/models/concerns/ruby_conversations/message_processing.rb
251
+ - app/models/concerns/ruby_conversations/message_validation.rb
252
+ - app/models/concerns/ruby_conversations/storable.rb
253
+ - app/models/ruby_conversations/conversation.rb
254
+ - app/models/ruby_conversations/message.rb
266
255
  - app/models/ruby_conversations/message_builder.rb
256
+ - app/models/ruby_conversations/message_input.rb
257
+ - app/models/ruby_conversations/message_prompt.rb
267
258
  - app/models/ruby_conversations/prompt.rb
268
- - app/models/ruby_conversations/prompt_version.rb
269
- - lib/generators/ruby_conversations/install/install_generator.rb
270
- - lib/generators/ruby_conversations/install/templates/README.md
271
- - lib/generators/ruby_conversations/install/templates/initializer.rb.erb
272
- - lib/generators/ruby_conversations/install/templates/migrations/create_ai_conversations.rb.erb
273
- - lib/generators/ruby_conversations/install/templates/migrations/create_ai_message_inputs.rb.erb
274
- - lib/generators/ruby_conversations/install/templates/migrations/create_ai_message_prompts.rb.erb
275
- - lib/generators/ruby_conversations/install/templates/migrations/create_ai_messages.rb.erb
276
- - lib/generators/ruby_conversations/install/templates/migrations/create_ai_tool_calls.rb.erb
277
- - lib/generators/ruby_conversations/install/templates/migrations/create_prompt_versions.rb.erb
278
- - lib/generators/ruby_conversations/install/templates/migrations/create_prompts.rb.erb
279
259
  - lib/ruby_conversations.rb
260
+ - lib/ruby_conversations/aws_credential_provider.rb
261
+ - lib/ruby_conversations/client.rb
280
262
  - lib/ruby_conversations/configuration.rb
281
263
  - lib/ruby_conversations/engine.rb
282
- - lib/ruby_conversations/jwt_client.rb
283
- - lib/ruby_conversations/storage/base.rb
284
- - lib/ruby_conversations/storage/local.rb
285
- - lib/ruby_conversations/storage/remote.rb
264
+ - lib/ruby_conversations/errors.rb
286
265
  - lib/ruby_conversations/version.rb
287
266
  homepage: https://github.com/StrongMind/ruby-conversations
288
267
  licenses:
@@ -310,5 +289,5 @@ requirements: []
310
289
  rubygems_version: 3.4.10
311
290
  signing_key:
312
291
  specification_version: 4
313
- summary: Rails engine for managing AI conversations with local or remote storage
292
+ summary: Client library for interacting with the AI Conversation Service
314
293
  test_files: []
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- require 'rubocop/rake_task'
9
-
10
- RuboCop::RakeTask.new
11
-
12
- task default: %i[spec rubocop]
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyConversations
4
- # Provides message-related functionalities for conversations.
5
- module Messageable
6
- extend ActiveSupport::Concern
7
-
8
- included do
9
- has_many :ai_conversations, as: :conversationable, dependent: :destroy
10
- has_many :ai_messages, through: :ai_conversations
11
- end
12
- end
13
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyConversations
4
- # Provides versioning functionalities for models.
5
- module Versionable
6
- extend ActiveSupport::Concern
7
-
8
- included do
9
- has_many :versions, class_name: 'PromptVersion', dependent: :destroy
10
- has_one :latest_version, -> { order(version: :desc) }, class_name: 'PromptVersion'
11
-
12
- delegate :content, :metadata, to: :latest_version, allow_nil: true
13
- end
14
-
15
- def create_version!(content:, metadata: {})
16
- next_version = versions.maximum(:version).to_i + 1
17
- versions.create!(content: content, metadata: metadata, version: next_version)
18
- end
19
- end
20
- end
@@ -1,116 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyConversations
4
- # An AI conversation is a conversation between an AI and a user.
5
- class AiConversation < ActiveRecord::Base
6
- # Associations
7
- belongs_to :conversationable, polymorphic: true, optional: true, touch: true
8
- has_many :ai_messages, class_name: RubyConversations.configuration.message_class, dependent: :destroy
9
-
10
- # Validations
11
- validates :ai_messages, presence: { message: 'At least one message is required' }, on: :update
12
- validate :validate_messages
13
-
14
- # Scopes
15
- scope :recent, -> { order(updated_at: :desc) }
16
- scope :with_messages, -> { includes(:ai_messages) }
17
-
18
- # Attributes
19
- attr_accessor :model_identifier, :provider, :tool
20
-
21
- def initialize(attributes = nil)
22
- attributes ||= {}
23
- super
24
- @model_identifier ||= attributes[:model_identifier] || RubyConversations.configuration.default_llm_model
25
- @provider ||= attributes[:provider] || RubyConversations.configuration.default_llm_provider
26
- end
27
-
28
- # Instance Methods
29
- def ask_multiple(prompt_inputs, description: nil)
30
- MessageBuilder.new(self).build_from_multiple_prompts(prompt_inputs, description: description)
31
- self
32
- end
33
-
34
- def ask(name, description: nil, inputs: {})
35
- MessageBuilder.new(self).build_from_single_prompt(name, description: description, inputs: inputs)
36
- self
37
- end
38
-
39
- def execute(system_message: nil)
40
- save!
41
- message = ai_messages.last
42
- raise ArgumentError, 'Conversation must have at least one message to execute' unless message
43
-
44
- chat = setup_llm_chat(system_message: system_message)
45
- response = chat.ask(message.request)
46
- update_last_message_response(message, response)
47
- response
48
- end
49
-
50
- def latest_message
51
- ai_messages.order(created_at: :desc).first
52
- end
53
-
54
- def message_count
55
- ai_messages.count
56
- end
57
-
58
- def llm
59
- case model_identifier
60
- when 'claude-3-7-sonnet'
61
- 'us.anthropic.claude-3-7-sonnet-20250219-v1:0'
62
- else
63
- model_identifier
64
- end
65
- end
66
-
67
- private
68
-
69
- def validate_messages
70
- ai_messages.each do |message|
71
- validate_message_level(message)
72
- message.ai_message_prompts.each do |prompt|
73
- validate_prompt_level(prompt)
74
- prompt.ai_message_inputs.each do |input|
75
- validate_input_level(input)
76
- end
77
- end
78
- end
79
- end
80
-
81
- def validate_message_level(message)
82
- return if message.valid?
83
-
84
- message.errors.full_messages.each do |msg|
85
- errors.add(:base, "Message error: #{msg}")
86
- end
87
- end
88
-
89
- def validate_prompt_level(prompt)
90
- return if prompt.valid?
91
-
92
- prompt.errors.full_messages.each do |msg|
93
- errors.add(:base, "Message prompt error: #{msg}")
94
- end
95
- end
96
-
97
- def validate_input_level(input)
98
- return if input.valid?
99
-
100
- input.errors.full_messages.each do |msg|
101
- errors.add(:base, "Message prompt input error: #{msg}")
102
- end
103
- end
104
-
105
- def setup_llm_chat(system_message: nil)
106
- chat = RubyLLM.chat(model: model_identifier, provider: provider).with_temperature(0.0)
107
- chat.with_tool(tool) if tool.present?
108
- chat.add_message(role: :system, content: system_message) if system_message.present?
109
- chat
110
- end
111
-
112
- def update_last_message_response(message, response)
113
- message.update!(response: response.to_h.to_json)
114
- end
115
- end
116
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyConversations
4
- # An AI message is a message in an AI conversation.
5
- class AiMessage < ActiveRecord::Base
6
- # Associations
7
- belongs_to :ai_conversation, class_name: RubyConversations.configuration.conversation_class
8
- has_many :ai_message_prompts, class_name: RubyConversations.configuration.message_prompt_class, dependent: :destroy
9
- has_many :prompts, through: :ai_message_prompts, class_name: RubyConversations.configuration.prompt_class
10
-
11
- # Validations
12
- validates :llm, presence: true
13
- validates :request, presence: true
14
-
15
- # Scopes
16
- scope :ordered, -> { order(created_at: :desc) }
17
- scope :with_tool, ->(tool) { where(tool: tool) }
18
- scope :with_prompts, -> { includes(:ai_message_prompts) }
19
-
20
- def prompt_inputs
21
- ai_message_prompts.includes(:ai_message_inputs).flat_map(&:ai_message_inputs)
22
- end
23
-
24
- def tool?
25
- tool.present?
26
- end
27
- end
28
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyConversations
4
- # Represents an input provided for a specific prompt placeholder within an AI message.
5
- class AiMessageInput < ActiveRecord::Base
6
- # Associations
7
- belongs_to :ai_message_prompt
8
-
9
- # Validations
10
- validates :placeholder_name, presence: true
11
- validate :value_not_nil
12
-
13
- # Scopes
14
- scope :ordered, -> { order(:placeholder_name) }
15
-
16
- private
17
-
18
- def value_not_nil
19
- errors.add(:value, "can't be blank") if value.nil?
20
- end
21
- end
22
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyConversations
4
- # Represents the association between an AI message and a specific version of a Prompt.
5
- class AiMessagePrompt < ActiveRecord::Base
6
- # Associations
7
- belongs_to :ai_message
8
- belongs_to :prompt, optional: true
9
- belongs_to :prompt_version, optional: true
10
- has_many :ai_message_inputs, class_name: RubyConversations.configuration.message_input_class, dependent: :destroy
11
-
12
- # Validations
13
- validate :prompt_or_inline_data_present
14
-
15
- # Scopes
16
- scope :with_inputs, -> { includes(:ai_message_inputs) }
17
- scope :for_prompt, ->(prompt) { where(prompt: prompt) }
18
-
19
- private
20
-
21
- def prompt_or_inline_data_present
22
- return if prompt_id.present? || prompt_version_id.present?
23
- return if name.present? && role.present? && draft.present?
24
-
25
- errors.add(:base, 'Must have either a prompt/version reference or inline prompt data (name, role, draft)')
26
- end
27
- end
28
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyConversations
4
- # Represents a specific version of a Prompt template.
5
- class PromptVersion < ActiveRecord::Base
6
- # Associations
7
- belongs_to :prompt
8
-
9
- # Validations
10
- validates :message, presence: true
11
- validates :temperature, numericality: { greater_than_or_equal_to: 0.0 }, allow_nil: true
12
-
13
- # Scopes
14
- scope :ordered, -> { order(created_at: :desc) }
15
- end
16
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails/generators'
4
- require 'rails/generators/migration'
5
-
6
- module RubyConversations
7
- module Generators
8
- # Generates the necessary files for installing the ruby_conversations engine.
9
- class InstallGenerator < Rails::Generators::Base
10
- include Rails::Generators::Migration
11
-
12
- source_root File.expand_path('templates', __dir__)
13
-
14
- def self.next_migration_number(path)
15
- next_migration_number = current_migration_number(path) + 1
16
- ActiveRecord::Migration.next_migration_number(next_migration_number)
17
- end
18
-
19
- def copy_migrations
20
- migration_template_details.each do |file, description|
21
- migration_template(
22
- "migrations/#{file}",
23
- "db/migrate/#{file.sub('.erb', '')}",
24
- migration_version: migration_version,
25
- migration_description: description
26
- )
27
- end
28
- end
29
-
30
- def create_initializer
31
- template 'initializer.rb.erb', 'config/initializers/ruby_conversations.rb'
32
- end
33
-
34
- def mount_engine
35
- route "mount RubyConversations::Engine => '/ai', as: 'ruby_conversations'"
36
- end
37
-
38
- def display_post_install_message
39
- readme 'README.md'
40
- end
41
-
42
- private
43
-
44
- def migration_version
45
- "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
46
- end
47
-
48
- def migration_template_details
49
- {
50
- 'create_prompts.rb.erb' => 'Create prompts table',
51
- 'create_prompt_versions.rb.erb' => 'Create prompt versions table',
52
- 'create_ai_conversations.rb.erb' => 'Create conversations table',
53
- 'create_ai_messages.rb.erb' => 'Create messages table',
54
- 'create_ai_message_prompts.rb.erb' => 'Create message prompts table',
55
- 'create_ai_message_inputs.rb.erb' => 'Create message inputs table'
56
- }
57
- end
58
- end
59
- end
60
- end
@@ -1,42 +0,0 @@
1
- # RubyConversations Installation
2
-
3
- The gem has been installed! Here are the next steps:
4
-
5
- 1. Run the migrations:
6
- ```bash
7
- bin/rails db:migrate
8
- ```
9
-
10
- 2. Configure the gem in `config/initializers/ruby_conversations.rb`
11
- - Set your storage mode (:local or :remote)
12
- - If using remote mode, set your API URL and JWT secret
13
- - Customize model names if needed
14
-
15
- 3. For remote mode, ensure your API endpoint is accessible and JWT authentication is configured.
16
-
17
- 4. Start using conversations in your models:
18
- ```ruby
19
- class MyModel < ApplicationRecord
20
- has_one :conversation, as: :conversationable, class_name: 'AiConversation'
21
- end
22
-
23
- # Create a conversation
24
- conversation = my_model.create_conversation!
25
-
26
- # Ask a question using a prompt
27
- conversation.ask("explain_code", inputs: { code: "def hello; end" })
28
- ```
29
-
30
- 5. The engine is mounted at `/ai`. You can change this in `config/routes.rb` if needed.
31
-
32
- ## What's Next?
33
-
34
- - Check out the documentation at https://github.com/yourusername/ruby_conversations
35
- - Review the example app at https://github.com/yourusername/ruby_conversations_example
36
- - Join our Discord community at https://discord.gg/ruby_conversations
37
-
38
- ## Need Help?
39
-
40
- - Open an issue on GitHub
41
- - Check our FAQ at https://github.com/yourusername/ruby_conversations/wiki/FAQ
42
- - Email support at support@example.com
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RubyConversations.configure do |config|
4
- # Storage mode: :local or :remote
5
- config.storage_mode = :local
6
-
7
- # Remote API settings (only needed for remote mode)
8
- # config.api_url = ENV['RUBY_CONVERSATIONS_API_URL']
9
- # config.jwt_secret = ENV['RUBY_CONVERSATIONS_JWT_SECRET']
10
-
11
- # Default LLM settings
12
- config.default_llm_model = 'gpt-4'
13
-
14
- # Customize model behaviors
15
- config.conversation_class = 'AiConversation'
16
- config.message_class = 'AiMessage'
17
- config.prompt_class = 'Prompt'
18
- end
@@ -1,13 +0,0 @@
1
- class CreateAiConversations < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :ai_conversations do |t|
4
- t.string :conversationable_type
5
- t.bigint :conversationable_id
6
-
7
- t.timestamps
8
- end
9
-
10
- add_index :ai_conversations, [:conversationable_type, :conversationable_id],
11
- name: 'index_ai_conversations_on_conversationable'
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- class CreateAiMessageInputs < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :ai_message_inputs do |t|
4
- t.string :placeholder_name
5
- t.text :value
6
- t.bigint :ai_message_prompt_id, null: false
7
-
8
- t.timestamps
9
- end
10
-
11
- add_index :ai_message_inputs, :ai_message_prompt_id
12
- end
13
- end