foobara-llm-backed-command 0.0.7 → 0.0.9
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/CHANGELOG.md +8 -0
- data/src/llm_backed_execute_method.rb +43 -16
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd38cd90e786b6c0da9b5050bc524db798c11b5621201eff0510b5264d00c240
|
4
|
+
data.tar.gz: a1529aaac899adda0831d947e982affc9420bbdcfbce53d12677fd09a6fcab4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38df4ecf874a19a014329d5ecf3787f33fc0b70bc73c727de70220bda27312187bc43e1d1752177a58076c17fbb0f4003375f988f0b39a32117fd5bc91825344
|
7
|
+
data.tar.gz: 1c1ff92542023066c4ebabd4da9b417bfb715494f8ecf12a988072e84b41ddd9f300484eb9302ee47bf27237e320f4dc88a186ddf0a8fbb8e741d99aaaab08ae
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [0.0.9] - 2025-06-28
|
2
|
+
|
3
|
+
- Use temperature and replace Ask with GenerateNextMessage
|
4
|
+
|
5
|
+
## [0.0.8] - 2025-06-19
|
6
|
+
|
7
|
+
- Convert result type entities to their primary key types with a description
|
8
|
+
|
1
9
|
## [0.0.7] - 2025-05-30
|
2
10
|
|
3
11
|
- Add a could-not-parse-json command error instead of raising
|
@@ -10,7 +10,7 @@ module Foobara
|
|
10
10
|
include Concern
|
11
11
|
|
12
12
|
on_include do
|
13
|
-
depends_on Ai::AnswerBot::
|
13
|
+
depends_on Ai::AnswerBot::GenerateNextMessage
|
14
14
|
possible_error :could_not_parse_result_json,
|
15
15
|
message: "Could not parse answer",
|
16
16
|
context: {
|
@@ -21,14 +21,14 @@ module Foobara
|
|
21
21
|
|
22
22
|
def execute
|
23
23
|
determine_serializer
|
24
|
-
|
24
|
+
construct_messages
|
25
25
|
generate_answer
|
26
26
|
parse_answer
|
27
27
|
|
28
28
|
parsed_answer
|
29
29
|
end
|
30
30
|
|
31
|
-
attr_accessor :serializer, :
|
31
|
+
attr_accessor :serializer, :answer, :parsed_answer, :messages
|
32
32
|
|
33
33
|
def determine_serializer
|
34
34
|
depth = if respond_to?(:association_depth)
|
@@ -56,24 +56,48 @@ module Foobara
|
|
56
56
|
self.serializer = serializer.new
|
57
57
|
end
|
58
58
|
|
59
|
-
def construct_input_json
|
60
|
-
inputs_without_llm_integration_inputs = inputs.except(:llm_model, :association_depth)
|
61
|
-
input_json = serializer.serialize(inputs_without_llm_integration_inputs)
|
62
|
-
|
63
|
-
self.input_json = JSON.fast_generate(input_json)
|
64
|
-
end
|
65
|
-
|
66
59
|
def generate_answer
|
67
|
-
|
68
|
-
|
69
|
-
question: input_json
|
60
|
+
inputs = {
|
61
|
+
chat: Ai::AnswerBot::Types::Chat.new(messages:)
|
70
62
|
}
|
71
63
|
|
64
|
+
inputs[:temperature] = if respond_to?(:temperature)
|
65
|
+
temperature
|
66
|
+
end || 0
|
67
|
+
|
72
68
|
if respond_to?(:llm_model)
|
73
|
-
|
69
|
+
inputs[:model] = llm_model
|
70
|
+
end
|
71
|
+
|
72
|
+
message = run_subcommand!(Ai::AnswerBot::GenerateNextMessage, inputs)
|
73
|
+
|
74
|
+
self.answer = message.content
|
75
|
+
end
|
76
|
+
|
77
|
+
def construct_messages
|
78
|
+
self.messages = build_messages.map do |message|
|
79
|
+
content = message[:content]
|
80
|
+
|
81
|
+
if content.is_a?(String)
|
82
|
+
message
|
83
|
+
else
|
84
|
+
content = serializer.serialize(content)
|
85
|
+
message.merge(content: JSON.fast_generate(content))
|
86
|
+
end
|
74
87
|
end
|
88
|
+
end
|
75
89
|
|
76
|
-
|
90
|
+
def build_messages
|
91
|
+
[
|
92
|
+
{
|
93
|
+
role: :system,
|
94
|
+
content: llm_instructions
|
95
|
+
},
|
96
|
+
{
|
97
|
+
role: :user,
|
98
|
+
content: inputs.except(:llm_model, :association_depth)
|
99
|
+
}
|
100
|
+
]
|
77
101
|
end
|
78
102
|
|
79
103
|
def llm_instructions
|
@@ -161,7 +185,10 @@ module Foobara
|
|
161
185
|
end
|
162
186
|
|
163
187
|
def result_json_schema
|
164
|
-
@result_json_schema ||= JsonSchemaGenerator.to_json_schema(
|
188
|
+
@result_json_schema ||= JsonSchemaGenerator.to_json_schema(
|
189
|
+
result_type,
|
190
|
+
association_depth: JsonSchemaGenerator::AssociationDepth::PRIMARY_KEY_ONLY
|
191
|
+
)
|
165
192
|
end
|
166
193
|
|
167
194
|
def llm_instructions
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-llm-backed-command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 0.0.
|
18
|
+
version: 0.0.132
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: 0.0.
|
25
|
+
version: 0.0.132
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: foobara-ai
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,14 +43,14 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.0.
|
46
|
+
version: 0.0.6
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.0.
|
53
|
+
version: 0.0.6
|
54
54
|
email:
|
55
55
|
- azimux@gmail.com
|
56
56
|
executables: []
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
|
-
rubygems_version: 3.6.
|
89
|
+
rubygems_version: 3.6.9
|
90
90
|
specification_version: 4
|
91
91
|
summary: Provides an easy way to implement a command whose logic is managed by an
|
92
92
|
LLM
|