ruby_conversations 1.0.0 → 1.0.1

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: 29d0a2bc2bf832a2bd4a452e1213d024604d73c3be3406851d2ac77dce20278d
4
- data.tar.gz: 973a5a996c8146aa0651dfeb42cb95d27c9a4623c53b1b4f662cefb48f90bc88
3
+ metadata.gz: 3994d5897446552014de346528c5d0c1806fba6c39995fec45d451103e07bece
4
+ data.tar.gz: c53dceb24ddfa2535d0a3ebe47380bb6e9f79f2ec890335dbc2ec5b13d20a95d
5
5
  SHA512:
6
- metadata.gz: bf8a698597f4a53c26a0850ee8afc0552d9280b5ea46ba05b890e5bebaa587e40d666e93349ec1667e1ac438c881b9a1afa79b7482cc970fedc49d7e89d49be5
7
- data.tar.gz: c9b77726ec303b37ad0af8f8e16ad3979802f8d995c254dcd2713a4a60563e0cbd7865b4bb433ade118ff2a597c8cc896940004b0abc874b802c63f666d037ba
6
+ metadata.gz: 86db4d62c0f983cf59ef3bc61e2e60d632ac45d86998e0dfb6263f390b3632d8477f556824dcfc572c8368ea33694a031cc23bdad00326ac876b67d78c1bee7b
7
+ data.tar.gz: 2b9a5f579db56d1d66c3cb147d47a282169680223e5e400d745a8543e9beaacef75e2c3ef339beec494741543781090b986d1435236d3c96a807c299013769a9
@@ -63,7 +63,6 @@ module RubyConversations
63
63
 
64
64
  def build_prompt_association(message, prompt, inputs)
65
65
  message_prompt = message.ai_message_prompts.build(
66
- prompt: prompt,
67
66
  prompt_version_id: prompt.latest_version_id,
68
67
  draft: prompt.message
69
68
  )
@@ -16,11 +16,9 @@ module RubyConversations
16
16
  belongs_to :organization, optional: true
17
17
 
18
18
  # Validations
19
- validates :message, presence: true
20
19
  validates :name, presence: true, uniqueness: true
21
20
  validates :temperature, numericality: { greater_than_or_equal_to: 0.0 }, allow_nil: true
22
21
  validates :role, presence: true, inclusion: { in: VALID_ROLES }
23
- validate :validate_placeholders_format
24
22
 
25
23
  # Scopes
26
24
  scope :active, -> { where(active: true) }
@@ -50,55 +48,14 @@ module RubyConversations
50
48
  end
51
49
 
52
50
  def interpolate(inputs = {})
53
- return message if placeholders.empty?
54
-
55
- validate_required_variables!(inputs)
56
-
57
51
  interpolated = message.dup
58
52
  format(interpolated, **inputs)
59
53
  end
60
54
 
61
- def placeholders
62
- return [] if message.nil?
63
-
64
- matches = message.scan(/%<([^>]+)>/)
65
- matches&.flatten&.uniq || []
66
- end
67
-
68
- def active?
69
- active
70
- end
71
-
72
- def deactivate!
73
- update!(active: false)
74
- end
75
-
76
- def activate!
77
- update!(active: true)
78
- end
79
-
80
55
  private
81
56
 
82
57
  def versioned_attributes
83
58
  %i[content role]
84
59
  end
85
-
86
- def validate_placeholders_format
87
- invalid_placeholders = placeholders.grep_v(/\A[a-z_][a-z0-9_]*\z/i)
88
-
89
- return unless invalid_placeholders.any?
90
-
91
- errors.add(:message, "contains invalid placeholders: #{invalid_placeholders.join(', ')}")
92
- end
93
-
94
- def validate_required_variables!(variables)
95
- missing = placeholders - variables.keys.map(&:to_s)
96
- raise ArgumentError, "Missing required variables: #{missing.join(', ')}" if missing.any?
97
-
98
- extra = variables.keys.map(&:to_s) - placeholders
99
- return unless extra.any?
100
-
101
- raise ArgumentError, "Unknown variables provided: #{extra.join(', ')}"
102
- end
103
60
  end
104
61
  end
@@ -3,7 +3,7 @@
3
3
  module RubyConversations
4
4
  MAJOR = 1
5
5
  MINOR = 0
6
- PATCH = 0 # this is automatically incremented by the build process
6
+ PATCH = 1
7
7
 
8
8
  VERSION = "#{RubyConversations::MAJOR}.#{RubyConversations::MINOR}.#{RubyConversations::PATCH}".freeze
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_conversations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Shippy