ruby_conversations 1.1.6 → 1.1.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.
- checksums.yaml +4 -4
- data/app/models/ruby_conversations/concerns/conversation_chat.rb +8 -1
- data/app/models/ruby_conversations/concerns/conversation_templates.rb +16 -0
- data/lib/ruby_conversations/client.rb +7 -0
- data/lib/ruby_conversations/errors.rb +11 -0
- data/lib/ruby_conversations/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d129588d8e1b65ea298915ffb01f98b8b1812e45648809da7c167e98bc437192
|
4
|
+
data.tar.gz: 0ae23b78f5c1f4fb861330f4c78cc2e2eabfbe3fc9a302225d345992379ada35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e838911c1eba0ac7bc2f5fe744830f38235708f0be905c491cf494011ba6f2aba74de9a778391c14303fdb5f03dbdce404489b703c9c8ab32ea2dbd6d25cd4e0
|
7
|
+
data.tar.gz: 3fdc3546c60c434bdc2aba30200c4c5d4c7ae7d28285dc98fe09150bfbd063fc5742d9f166f34a520e67a41bd03b6570e880a85301cba4a2cedee9187b142db4
|
@@ -21,7 +21,14 @@ module RubyConversations
|
|
21
21
|
return unless tools_configured?
|
22
22
|
return if tool_calls?(chat_messages)
|
23
23
|
|
24
|
-
|
24
|
+
last_message = chat_messages.last&.content
|
25
|
+
error_message = "No tool call found for tool(s): '#{tool_names}'. Please check the prompt."
|
26
|
+
|
27
|
+
raise RubyConversations::ToolCallValidationError.new(
|
28
|
+
error_message,
|
29
|
+
last_message: last_message,
|
30
|
+
tool_names: tool_names
|
31
|
+
)
|
25
32
|
end
|
26
33
|
|
27
34
|
def tools_configured?
|
@@ -20,6 +20,22 @@ module RubyConversations
|
|
20
20
|
extract_template_metadata(template_data)
|
21
21
|
end
|
22
22
|
|
23
|
+
# Fetch metadata for all available templates
|
24
|
+
# @return [Array<Hash>] Array of template metadata including fields and UI configuration
|
25
|
+
def all_templates
|
26
|
+
begin
|
27
|
+
templates_data = RubyConversations.client.fetch_all_conversation_templates
|
28
|
+
rescue RubyConversations::ClientError => e
|
29
|
+
raise RubyConversations::TemplateNotFoundError, 'Failed to fetch templates' if e.status_code == 404
|
30
|
+
|
31
|
+
raise e
|
32
|
+
end
|
33
|
+
|
34
|
+
return [] unless templates_data.is_a?(Array)
|
35
|
+
|
36
|
+
templates_data.map { |template_data| extract_template_metadata(template_data) }.compact
|
37
|
+
end
|
38
|
+
|
23
39
|
private
|
24
40
|
|
25
41
|
def extract_template_metadata(template_data)
|
@@ -68,6 +68,13 @@ module RubyConversations
|
|
68
68
|
handle_response(response)
|
69
69
|
end
|
70
70
|
|
71
|
+
# Fetch all available conversation templates
|
72
|
+
# @return [Array<Hash>] Array of template data including messages and prompts
|
73
|
+
def fetch_all_conversation_templates
|
74
|
+
response = client.get('api/ai_conversations')
|
75
|
+
handle_response(response)
|
76
|
+
end
|
77
|
+
|
71
78
|
# Fetch a prompt by name
|
72
79
|
# @param name [String] The name of the prompt to fetch
|
73
80
|
# @return [Hash] The prompt attributes
|
@@ -19,4 +19,15 @@ module RubyConversations
|
|
19
19
|
|
20
20
|
# Error raised when a template is not found
|
21
21
|
class TemplateNotFoundError < Error; end
|
22
|
+
|
23
|
+
# Error raised when tool calls are expected but not found in LLM response
|
24
|
+
class ToolCallValidationError < Error
|
25
|
+
attr_reader :last_message, :tool_names
|
26
|
+
|
27
|
+
def initialize(message, last_message: nil, tool_names: nil)
|
28
|
+
super(message)
|
29
|
+
@last_message = last_message
|
30
|
+
@tool_names = tool_names
|
31
|
+
end
|
32
|
+
end
|
22
33
|
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.1.
|
4
|
+
version: 1.1.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-05-
|
11
|
+
date: 2025-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|