llama_bot_rails 0.1.5 β 0.1.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22dd1ec3cd8056d6ad567a987afb3aee4590816f37477eeefa81e975d07b59a6
|
4
|
+
data.tar.gz: f38dfc3262e9794f7371e6d16c9be4f382f638eac84657850c725b0f85264731
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd7d9a5386b68dcee1d2dd672df9a8ea6fa6c5860d2f6a829d7de73d9c28cfec0810addd344c3f341351c743a350afd8018bf6aff4d687611807bb9da37a4cef
|
7
|
+
data.tar.gz: b3dbc4afc368553e968b587ccda61905912c9190ba6bf05d2f59003f556f45a4613595bb8e2938661b30e10de3a9c0ada1b1c1541777b7d577f5910e71121c07
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Chat with a powerful agent that has access to your models, your application cont
|
|
12
12
|
|
13
13
|
## π₯ **See it in action** (30-Second Demo)
|
14
14
|
|
15
|
-
π [
|
15
|
+
π 
|
16
16
|
βWelcome to the future of Rails + AI.β
|
17
17
|
|
18
18
|
### The agent can:
|
@@ -7,9 +7,25 @@ module LlamaBotRails
|
|
7
7
|
# POST /agent/command
|
8
8
|
def command
|
9
9
|
input = params[:command]
|
10
|
+
|
11
|
+
# Capture both stdout and return value
|
12
|
+
output = StringIO.new
|
13
|
+
result = nil
|
14
|
+
|
15
|
+
$stdout = output
|
10
16
|
result = safety_eval(input)
|
11
|
-
|
17
|
+
$stdout = STDOUT
|
18
|
+
|
19
|
+
# If result is a string and output has content, prefer output
|
20
|
+
final_result = if output.string.present?
|
21
|
+
output.string.strip
|
22
|
+
else
|
23
|
+
result
|
24
|
+
end
|
25
|
+
|
26
|
+
render json: { result: final_result }
|
12
27
|
rescue => e
|
28
|
+
$stdout = STDOUT # Reset stdout on error
|
13
29
|
render json: { error: e.class.name, message: e.message }, status: :unprocessable_entity
|
14
30
|
end
|
15
31
|
|
@@ -53,12 +69,11 @@ module LlamaBotRails
|
|
53
69
|
private
|
54
70
|
|
55
71
|
def safety_eval(input)
|
56
|
-
#
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
{ error: e.class.name, message: e.message }
|
72
|
+
# Change to Rails root directory for file operations
|
73
|
+
Dir.chdir(Rails.root) do
|
74
|
+
# Create a safer evaluation context
|
75
|
+
binding.eval(input)
|
76
|
+
end
|
62
77
|
end
|
63
78
|
|
64
79
|
def authenticate_agent!
|
@@ -1 +1,3 @@
|
|
1
|
-
You are LlamaBot, a helpful assistant inside a Ruby on Rails app.
|
1
|
+
You are LlamaBot, a helpful assistant inside a Ruby on Rails app, with access to the Rails Console.
|
2
|
+
|
3
|
+
To remember key information, you can use Rails Console to run `LlamaBotRails.add_instruction_to_agent_prompt!("<new instructions/memory>")`
|