llama_bot_rails 0.1.4 → 0.1.5
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/README.md +2 -0
- data/app/views/llama_bot_rails/agent/chat.html.erb +10 -2
- data/lib/generators/llama_bot_rails/install/install_generator.rb +6 -0
- data/lib/generators/llama_bot_rails/install/templates/agent_prompt.txt +1 -0
- data/lib/llama_bot_rails/agent_state_builder.rb +1 -0
- data/lib/llama_bot_rails/engine.rb +1 -1
- data/lib/llama_bot_rails/version.rb +1 -1
- data/lib/llama_bot_rails.rb +17 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e2df41e770f0dbcc740af59357462c33b0bcb87d3dd0394e343729d4d1a4a45
|
4
|
+
data.tar.gz: b7032c39fe95fc8e5dc5ab892c8abd28366c77db7c4826a29f6096511124e9ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b4ad9c9ce5bbb3bbb3d645c3db6e87cff9fc398c0ce412c75d7687c79b7532c751518add6f583566ebb20423e465a1b6f81611448ddf08de4a97d2f5704fc79
|
7
|
+
data.tar.gz: 172d5d32f0b0742ca51f6c47468019c628d7043e20b212324fc4f8da987a3aabd0e06dd5375375bf645cb62377f7ca2b12b227f640ff54b494dc52c050a18484
|
data/README.md
CHANGED
@@ -509,9 +509,17 @@
|
|
509
509
|
}
|
510
510
|
}
|
511
511
|
</style>
|
512
|
-
|
512
|
+
|
513
|
+
<% if defined?(javascript_importmap_tags) %> <!-- Rails 7+ -->
|
514
|
+
<%= javascript_importmap_tags %>
|
515
|
+
<% else %> <!-- Rails 6 -->
|
516
|
+
<%= javascript_include_tag "application" %>
|
517
|
+
<% end %>
|
518
|
+
|
513
519
|
<%= javascript_include_tag "llama_bot_rails/application" %>
|
514
|
-
|
520
|
+
<% if defined?(action_cable_meta_tag) %>
|
521
|
+
<%= action_cable_meta_tag %>
|
522
|
+
<% end %>
|
515
523
|
<!-- Add Snarkdown CDN -->
|
516
524
|
<script src="https://unpkg.com/snarkdown/dist/snarkdown.umd.js"></script>
|
517
525
|
</head>
|
@@ -3,6 +3,11 @@ module LlamaBotRails
|
|
3
3
|
module Generators
|
4
4
|
class InstallGenerator < Rails::Generators::Base
|
5
5
|
source_root File.expand_path("templates", __dir__)
|
6
|
+
|
7
|
+
def create_config_file
|
8
|
+
empty_directory "config/llama_bot"
|
9
|
+
copy_file "agent_prompt.txt", "config/llama_bot/agent_prompt.txt"
|
10
|
+
end
|
6
11
|
|
7
12
|
def mount_engine
|
8
13
|
say <<~MSG, :yellow
|
@@ -32,6 +37,7 @@ module LlamaBotRails
|
|
32
37
|
create_file "config/initializers/llama_bot_rails.rb", <<~RUBY
|
33
38
|
Rails.application.configure do
|
34
39
|
config.llama_bot_rails.websocket_url = ENV.fetch("LLAMABOT_WEBSOCKET_URL", "ws://localhost:8000/ws")
|
40
|
+
config.llama_bot_rails.llamabot_api_url = ENV.fetch("LLAMABOT_API_URL", "http://localhost:8000")
|
35
41
|
config.llama_bot_rails.enable_console_tool = !Rails.env.production?
|
36
42
|
end
|
37
43
|
RUBY
|
@@ -0,0 +1 @@
|
|
1
|
+
You are LlamaBot, a helpful assistant inside a Ruby on Rails app.
|
@@ -10,6 +10,7 @@ module LlamaBotRails
|
|
10
10
|
user_message: @params[:message], # Rails param from JS/chat UI
|
11
11
|
thread_id: @context[:thread_id],
|
12
12
|
api_token: @context[:api_token],
|
13
|
+
agent_prompt: LlamaBotRails.agent_prompt_text,
|
13
14
|
agent_name: "llamabot" #Very important. This routes to the appropriate LangGraph agent as defined in langgraph.json
|
14
15
|
}
|
15
16
|
end
|
@@ -14,7 +14,7 @@ module LlamaBotRails
|
|
14
14
|
config.llama_bot_rails.websocket_url = 'ws://localhost:8000/ws' # <-- default
|
15
15
|
config.llama_bot_rails.llamabot_api_url = "http://localhost:8000"
|
16
16
|
config.llama_bot_rails.enable_console_tool = true
|
17
|
-
|
17
|
+
|
18
18
|
initializer "llama_bot_rails.assets.precompile" do |app|
|
19
19
|
app.config.assets.precompile += %w( llama_bot_rails/application.js )
|
20
20
|
end
|
data/lib/llama_bot_rails.rb
CHANGED
@@ -6,5 +6,22 @@ module LlamaBotRails
|
|
6
6
|
def config
|
7
7
|
Rails.application.config.llama_bot_rails
|
8
8
|
end
|
9
|
+
|
10
|
+
def agent_prompt_path
|
11
|
+
Rails.root.join("config", "llama_bot", "agent_prompt.txt")
|
12
|
+
end
|
13
|
+
|
14
|
+
def agent_prompt_text
|
15
|
+
if File.exist?(agent_prompt_path)
|
16
|
+
File.read(agent_prompt_path)
|
17
|
+
else
|
18
|
+
"You are LlamaBot, a helpful assistant." #Fallback default.
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_instruction_to_agent_prompt!(new_instruction)
|
23
|
+
FileUtils.mkdir_p(agent_prompt_path.dirname)
|
24
|
+
File.write(agent_prompt_path, "\n#{new_instruction}", mode: 'a')
|
25
|
+
end
|
9
26
|
end
|
10
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: llama_bot_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kody Kendall
|
@@ -15,7 +15,7 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '
|
18
|
+
version: '6.0'
|
19
19
|
- - "<"
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '9.0'
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '6.0'
|
29
29
|
- - "<"
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: '9.0'
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
requirements:
|
36
36
|
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: '
|
38
|
+
version: '6.0'
|
39
39
|
- - "<"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '9.0'
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '6.0'
|
49
49
|
- - "<"
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '9.0'
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- config/initializers/llama_bot_rails.rb
|
123
123
|
- config/routes.rb
|
124
124
|
- lib/generators/llama_bot_rails/install/install_generator.rb
|
125
|
+
- lib/generators/llama_bot_rails/install/templates/agent_prompt.txt
|
125
126
|
- lib/llama_bot_rails.rb
|
126
127
|
- lib/llama_bot_rails/agent_state_builder.rb
|
127
128
|
- lib/llama_bot_rails/engine.rb
|