prompt_manager 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: add8f0261dd0fd2e91e8195330d923e8806c2e3a7243cfb51ce70a589fc76ef2
|
4
|
+
data.tar.gz: 73b69061afdd242679c231949fba6a3b075f486feb20113cb838d0345dd2ffcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a65630d9623b49c34265b137f03cfb032ec645f736e9ca9327e2aaf045cdd0e2818e28e1b000bc80b32016f32a59192861db6cc7596c8ea6834b2c386ce1aac2
|
7
|
+
data.tar.gz: ec16e90d781c354875932d454d04783bcd46b10f7a815ffe94204fd17475bc2930cb6627e55072ec9b937512031033bdf01eda83d62ed126d2833801fd156e0c
|
@@ -81,8 +81,9 @@ class PromptManager::Prompt
|
|
81
81
|
# Return tje prompt text suitable for passing to a
|
82
82
|
# gen-AI process.
|
83
83
|
def to_s
|
84
|
-
|
84
|
+
build
|
85
85
|
end
|
86
|
+
alias_method :prompt, :to_s
|
86
87
|
|
87
88
|
|
88
89
|
# Save the prompt to the Storage system
|
@@ -108,20 +109,27 @@ class PromptManager::Prompt
|
|
108
109
|
def build
|
109
110
|
@prompt = text.gsub(PARAMETER_REGEX) do |match|
|
110
111
|
param_name = match
|
111
|
-
parameters[param_name].last || match
|
112
|
+
Array(parameters[param_name]).last || match
|
112
113
|
end
|
113
114
|
|
114
115
|
remove_comments
|
115
116
|
end
|
116
117
|
|
118
|
+
|
119
|
+
def keywords
|
120
|
+
update_keywords
|
121
|
+
end
|
122
|
+
|
117
123
|
######################################
|
118
124
|
private
|
119
125
|
|
120
126
|
def update_keywords
|
121
127
|
@keywords = @text.scan(PARAMETER_REGEX).flatten.uniq
|
122
|
-
keywords.each do |kw|
|
128
|
+
@keywords.each do |kw|
|
123
129
|
@parameters[kw] = [] unless @parameters.has_key?(kw)
|
124
130
|
end
|
131
|
+
|
132
|
+
@keywords
|
125
133
|
end
|
126
134
|
|
127
135
|
|
@@ -258,6 +258,7 @@ class PromptManager::Storage::FileSystemAdapter
|
|
258
258
|
def write_with_error_handling(file_path, content)
|
259
259
|
begin
|
260
260
|
file_path.write content
|
261
|
+
true
|
261
262
|
rescue IOError => e
|
262
263
|
raise "Failed to write to file: #{e.message}"
|
263
264
|
end
|
@@ -268,6 +269,7 @@ class PromptManager::Storage::FileSystemAdapter
|
|
268
269
|
def delete_with_error_handling(file_path)
|
269
270
|
begin
|
270
271
|
file_path.delete
|
272
|
+
true
|
271
273
|
rescue IOError => e
|
272
274
|
raise "Failed to delete file: #{e.message}"
|
273
275
|
end
|