ruby_conversations 1.0.12 → 1.0.14

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: 2b0a2a0d68b09e3f39f63329126c07e9f36ca92acddceb4ae63079fbed34c535
4
- data.tar.gz: d5448b0535c11dd19ec1fa6d594f963eb2b276fc8cea8b89ec0255932094297a
3
+ metadata.gz: 1d6209ce940d83da8e50a14df8ef7b7aa9134676742022cc7fcbe47eaaba94bc
4
+ data.tar.gz: 010bf794202f4030e657c4fed0d88e39a8dceac460e9e32ca331cb2d340a020a
5
5
  SHA512:
6
- metadata.gz: a2612396e683b5c24f2f6e44532579cfa098ac6914b5d6e3fd260bccca3800788eb1e17f9244bcfb510b913f07ee1196190d4546ecbdce7ce1d8da598b1c4c94
7
- data.tar.gz: a8af5b75a7601668d7ffd6d7fae99d2a462f867b8c6f1f02c876c44c9e94554a28abb953176aed4b6c105c2ad3ac247ca1be52f74b576098fc1b736c09a2ae83
6
+ metadata.gz: 3686165abf53df27c35c84b0e1444e6be18336fcb939aebb36245fa906f72a31eb18468d2d6782d39eafac19ba2f60e4f07ee48a492880a883ec16cf331c376b
7
+ data.tar.gz: dac103d0a4ef37ca87e874dd1a36924800aa8c0a96e0ba5798434e7e246a97daad7d79d475d9758798938e0b426d39f0b6bfc146989286a8783ba745708d4480
@@ -8,8 +8,14 @@ module RubyConversations
8
8
 
9
9
  def execute(system_message: nil)
10
10
  validate_conversation_state
11
- response = generate_chat_response(system_message)
12
- store_and_update_conversation(response)
11
+ chat_messages = generate_chat_response(system_message)
12
+
13
+ if tool.present?
14
+ tool_calls = chat_messages.filter { |message| message.tool_calls.present? }
15
+ raise "No tool call found for tool '#{tool}'. Please check the prompt." if tool_calls.empty?
16
+ end
17
+
18
+ store_and_update_conversation(chat_messages)
13
19
  end
14
20
 
15
21
  def llm
@@ -31,14 +37,15 @@ module RubyConversations
31
37
  def generate_chat_response(system_message)
32
38
  chat = setup_llm_chat(system_message: system_message)
33
39
  chat.ask(messages.last.request)
40
+ chat.messages
34
41
  end
35
42
 
36
- def store_and_update_conversation(response)
37
- update_last_message_response(messages.last, response)
43
+ def store_and_update_conversation(chat_messages)
44
+ update_last_message_response(messages.last, chat_messages)
38
45
  RubyConversations.client.store_conversation_or_message(self, messages.last)
39
46
 
40
47
  {
41
- response: response,
48
+ response: chat_messages,
42
49
  conversation: self
43
50
  }
44
51
  end
@@ -48,8 +55,8 @@ module RubyConversations
48
55
  build_chat(system_message)
49
56
  end
50
57
 
51
- def update_last_message_response(message, response)
52
- message.response = response.to_h.to_json
58
+ def update_last_message_response(message, chat_messages)
59
+ message.response = chat_messages.map(&:to_h).to_json
53
60
  end
54
61
 
55
62
  def build_chat(system_message)
@@ -12,7 +12,7 @@ module RubyConversations
12
12
 
13
13
  def configure_llm_credentials
14
14
  RubyLLM.configure do |config|
15
- credentials = ENV['AWS_ACCESS_KEY_ID'].present? ? env_credentials : provider_credentials
15
+ credentials = provider_credentials
16
16
  config.bedrock_region = ENV.fetch('AWS_REGION', 'us-west-2')
17
17
  config.bedrock_api_key = credentials[:api_key]
18
18
  config.bedrock_secret_key = credentials[:secret_key]
@@ -54,7 +54,7 @@ module RubyConversations
54
54
  end
55
55
 
56
56
  def use_mock_credentials?
57
- ENV['RAILS_ENV'] != 'production'
57
+ ENV['RAILS_ENV'] == 'test'
58
58
  end
59
59
 
60
60
  def set_mock_credentials
@@ -3,7 +3,7 @@
3
3
  module RubyConversations
4
4
  MAJOR = 1
5
5
  MINOR = 0
6
- PATCH = 12
6
+ PATCH = 14
7
7
 
8
8
  VERSION = "#{RubyConversations::MAJOR}.#{RubyConversations::MINOR}.#{RubyConversations::PATCH}".freeze
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_conversations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.14
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-11 00:00:00.000000000 Z
11
+ date: 2025-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport