luo 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/luo.iml +1 -0
- data/lib/luo/init_project.rb +1 -1
- data/lib/luo/open_ai_agent_runner.rb +3 -3
- data/lib/luo/prompts.rb +6 -5
- data/lib/luo/templates/agent_input.md.erb +39 -0
- data/lib/luo/templates/agent_system.md.erb +4 -0
- data/lib/luo/templates/agent_tool_input.md.erb +10 -0
- data/lib/luo/templates/xinghuo_agent_input.md.erb +10 -0
- data/lib/luo/templates/xinghuo_response_error.md.erb +10 -0
- data/lib/luo/version.rb +1 -1
- data/lib/luo/xinghuo_agent_runner.rb +3 -3
- data/luo +13 -5
- metadata +13 -8
- /data/lib/luo/{templates/luo_agent_input.md.erb → projects/prompts/agent_input.md.erb} +0 -0
- /data/lib/luo/{templates/luo_agent_system.md.erb → projects/prompts/agent_system.md.erb} +0 -0
- /data/lib/luo/{templates/luo_agent_tool_input.md.erb → projects/prompts/agent_tool_input.md.erb} +0 -0
- /data/lib/luo/{templates/luo_xinghuo_agent_input.md.erb → projects/prompts/xinghuo_agent_input.md.erb} +0 -0
- /data/lib/luo/{templates/luo_xinghuo_response_error.md.erb → projects/prompts/xinghuo_response_error.md.erb} +0 -0
- /data/lib/luo/templates/{prompt.demo.erb → demo.md.erb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16877925d84cc45e2f2feebb170ef2009e8a1111335e0ca8dd913d578c5d0257
|
4
|
+
data.tar.gz: bb1a045bfd1d40ca767e2c04735dc241006f750bbf8713291d08ea58afcf8e35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bb212832775ae2c7919eafeb11a6ad476d1ee3380d98d553a0136bf7e6dcc5179ce0e37d6f9bd8ff969c4edc8b899b8d4871dc5d1fe6cc9fbb81a5c8b68f850
|
7
|
+
data.tar.gz: b8e6c6f1b701395e559ea56ede7c5b58dcc2fb690eda7b728a32135187a48e1cfa1f552ccc33ea17f95e1e98d9c93eeef4a3ca4d2ce1048a61045f7be0561238
|
data/.idea/luo.iml
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
9
|
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
10
|
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
+
<excludeFolder url="file://$MODULE_DIR$/bundle_gems/cache" />
|
11
12
|
</content>
|
12
13
|
<orderEntry type="jdk" jdkName="ruby-3.2.1-p31" jdkType="RUBY_SDK" />
|
13
14
|
<orderEntry type="sourceFolder" forTests="false" />
|
data/lib/luo/init_project.rb
CHANGED
@@ -24,7 +24,7 @@ module Luo
|
|
24
24
|
def create_templates
|
25
25
|
puts "create templates directory"
|
26
26
|
unless File.directory?('templates')
|
27
|
-
FileUtils.cp_r(File.join(__dir__, '
|
27
|
+
FileUtils.cp_r(File.join(__dir__, 'projects', 'prompts'), 'prompts')
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -13,8 +13,8 @@ module Luo
|
|
13
13
|
|
14
14
|
on_request do
|
15
15
|
context.messages = Messages.create(history: context.histories)
|
16
|
-
.system(prompt: Luo::Prompts.
|
17
|
-
.user(prompt: Luo::Prompts.
|
16
|
+
.system(prompt: Luo::Prompts.agent_system)
|
17
|
+
.user(prompt: Luo::Prompts.agent_input, context: {agents: self.class.agents, last_user_input: context.user_input})
|
18
18
|
context.response = @openai.chat(context.messages)
|
19
19
|
end
|
20
20
|
|
@@ -39,7 +39,7 @@ module Luo
|
|
39
39
|
after_run do
|
40
40
|
if context.retries < config.retires && context.final_result.nil?
|
41
41
|
context.messages = context.messages.assistant(
|
42
|
-
prompt: Luo::Prompts.
|
42
|
+
prompt: Luo::Prompts.agent_tool_input,
|
43
43
|
context: {
|
44
44
|
tools_response: context.agent_results
|
45
45
|
}
|
data/lib/luo/prompts.rb
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
|
3
3
|
module Luo
|
4
4
|
module Prompts
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
extend Dry::Configurable
|
6
|
+
|
7
|
+
setting :gem_templates_dir, default: "#{__dir__}/templates"
|
8
|
+
setting :prompts_dir, default: "#{Dir.pwd}/prompts"
|
8
9
|
|
9
10
|
extend self
|
10
11
|
|
11
12
|
def define_templates
|
12
|
-
define_templates_in_dir(
|
13
|
-
define_templates_in_dir(
|
13
|
+
define_templates_in_dir(config.gem_templates_dir)
|
14
|
+
define_templates_in_dir(config.prompts_dir)
|
14
15
|
end
|
15
16
|
|
16
17
|
def define_templates_in_dir(dir_path)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
TOOLS
|
2
|
+
------
|
3
|
+
Assistant can ask the user to use tools to look up information that may be helpful in answering the users original question. The tools the human can use are:
|
4
|
+
|
5
|
+
<% agents.values.each do |agent| -%>
|
6
|
+
> <%= agent.agent_name %>: <%= agent.agent_desc %>
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
RESPONSE FORMAT INSTRUCTIONS
|
10
|
+
----------------------------
|
11
|
+
|
12
|
+
When responding to me please, please output a response in one of two formats:
|
13
|
+
|
14
|
+
**Option 1:**
|
15
|
+
Use this if you want humans to use the tools.
|
16
|
+
Markdown code snippet formatted in the following schema:
|
17
|
+
|
18
|
+
```json
|
19
|
+
[{
|
20
|
+
"action": string \ The action to take. Must be one of <%= agents.values.map do |a| a.agent_name end.join(', ') %>
|
21
|
+
"action_input": string \ The input to the action
|
22
|
+
}]
|
23
|
+
```
|
24
|
+
|
25
|
+
**Option #2:**
|
26
|
+
Use this if you want to respond directly to the human. Markdown code snippet formatted in the following schema:
|
27
|
+
|
28
|
+
```json
|
29
|
+
{
|
30
|
+
"action": "Final Answer",
|
31
|
+
"action_input": string \ You should put what you want to return to use here <%= Luo::AgentRunnerBase.language_info %>
|
32
|
+
}
|
33
|
+
```
|
34
|
+
|
35
|
+
USER'S INPUT
|
36
|
+
--------------------
|
37
|
+
Here is the user's input (Remember to respond to a single or multiple actions with a json blob of markdown code snippets, and NOTHING else):
|
38
|
+
|
39
|
+
<%= last_user_input %>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
Assistant is a large language model trained by OpenAI.
|
2
|
+
Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
|
3
|
+
Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.
|
4
|
+
Overall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
TOOL RESPONSE:
|
2
|
+
---------------------
|
3
|
+
<% tools_response.each do |r| -%>
|
4
|
+
> <%= r[:agent_name] %>: <%= r[:agent_response] %>
|
5
|
+
<% end -%>
|
6
|
+
|
7
|
+
USER'S INPUT
|
8
|
+
--------------------
|
9
|
+
|
10
|
+
Okay, so what is the response to my last comment? If using information obtained from the tools you must mention it explicitly without mentioning the tool names - I have forgotten all TOOL RESPONSES! Remember to respond to a single or multiple actions with a json blob of markdown code snippets, and NOTHING else.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
根据问题选择合适的工具。
|
2
|
+
你可以使用以下工具:
|
3
|
+
<% agents.values.each do |agent| -%>
|
4
|
+
- <%= agent.agent_name %>:<%= agent.agent_desc %>
|
5
|
+
<% end -%>
|
6
|
+
问题是:<%= last_user_input %>
|
7
|
+
现在我应该选择什么工具呢?请用以下格式回答:
|
8
|
+
```
|
9
|
+
调用工具:你要选择的工具是什么?只能在<%= agents.values.map do |a| a.agent_name end.join(',') %>中选择一个
|
10
|
+
```
|
@@ -0,0 +1,10 @@
|
|
1
|
+
输出的格式错误,根据问题选择合适的工具。
|
2
|
+
你可以使用以下工具:
|
3
|
+
<% agents.values.each do |agent| -%>
|
4
|
+
- <%= agent.agent_name %>:<%= agent.agent_desc %>
|
5
|
+
<% end -%>
|
6
|
+
刚刚的问题:<%= last_user_input %>
|
7
|
+
现在我应该选择什么工具呢?请用以下格式回答:
|
8
|
+
```
|
9
|
+
调用工具:你要选择的工具是什么?只能在<%= agents.values.map do |a| a.agent_name end.join(',') %>中选择一个
|
10
|
+
```
|
data/lib/luo/version.rb
CHANGED
@@ -12,13 +12,13 @@ module Luo
|
|
12
12
|
|
13
13
|
on_request do
|
14
14
|
context.messages = Messages.create(history: context.histories)
|
15
|
-
.user(prompt: Luo::Prompts.
|
15
|
+
.user(prompt: Luo::Prompts.xinghuo_agent_input, context: {agents: self.class.agents, last_user_input: context.user_input})
|
16
16
|
response = @xinghuo.chat(context.messages)
|
17
17
|
if response.split("\n").select { |line| line.size >1 }.size > 1
|
18
18
|
message = Messages.create(history: context.histories)
|
19
|
-
.user(prompt: Luo::Prompts.
|
19
|
+
.user(prompt: Luo::Prompts.xinghuo_agent_input, context: {agents: self.class.agents, last_user_input: context.user_input})
|
20
20
|
.assistant(text: response)
|
21
|
-
.user(prompt: Luo::Prompts.
|
21
|
+
.user(prompt: Luo::Prompts.xinghuo_response_error, context: {agents: self.class.agents, last_user_input: context.user_input})
|
22
22
|
context.response = @xinghuo.chat(message)
|
23
23
|
else
|
24
24
|
context.response = response
|
data/luo
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
# 性能低
|
4
|
+
#if [ -z "$(ls -A $PWD/bundle_gems)" ]; then
|
5
|
+
# echo "copy bundle gems"
|
6
|
+
# docker run --rm -v "$PWD/bundle_gems:/usr/local/bundle_1" ghcr.io/mjason/luo:latest e "cp -r /usr/local/bundle/* /usr/local/bundle_1/"
|
7
|
+
#fi
|
8
|
+
#
|
9
|
+
#docker run --rm -it \
|
10
|
+
# -v "$PWD:/workdir" \
|
11
|
+
# -v "$PWD/bundle_gems:/usr/local/bundle/" \
|
12
|
+
# ghcr.io/mjason/luo:latest \
|
13
|
+
# "$@"
|
6
14
|
|
15
|
+
# 性能高
|
7
16
|
docker run --rm -it \
|
8
17
|
-v "$PWD:/workdir" \
|
9
|
-
-v "$PWD/bundle_gems:/usr/local/bundle/" \
|
10
18
|
ghcr.io/mjason/luo:latest \
|
11
|
-
"$@"
|
19
|
+
"$@"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MJ
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -206,19 +206,24 @@ files:
|
|
206
206
|
- lib/luo/projects/application.rb
|
207
207
|
- lib/luo/projects/env
|
208
208
|
- lib/luo/projects/init.rb
|
209
|
+
- lib/luo/projects/prompts/agent_input.md.erb
|
210
|
+
- lib/luo/projects/prompts/agent_system.md.erb
|
211
|
+
- lib/luo/projects/prompts/agent_tool_input.md.erb
|
212
|
+
- lib/luo/projects/prompts/xinghuo_agent_input.md.erb
|
213
|
+
- lib/luo/projects/prompts/xinghuo_response_error.md.erb
|
209
214
|
- lib/luo/projects/test.yml
|
210
215
|
- lib/luo/projects/time_agent.rb
|
211
216
|
- lib/luo/projects/weather_agent.rb
|
212
217
|
- lib/luo/prompt_template.rb
|
213
218
|
- lib/luo/prompts.rb
|
214
|
-
- lib/luo/templates/
|
215
|
-
- lib/luo/templates/
|
216
|
-
- lib/luo/templates/
|
219
|
+
- lib/luo/templates/agent_input.md.erb
|
220
|
+
- lib/luo/templates/agent_system.md.erb
|
221
|
+
- lib/luo/templates/agent_tool_input.md.erb
|
222
|
+
- lib/luo/templates/demo.md.erb
|
217
223
|
- lib/luo/templates/luo_commit.md.erb
|
218
|
-
- lib/luo/templates/luo_xinghuo_agent_input.md.erb
|
219
224
|
- lib/luo/templates/luo_xinghuo_agent_tool_input.md.erb
|
220
|
-
- lib/luo/templates/
|
221
|
-
- lib/luo/templates/
|
225
|
+
- lib/luo/templates/xinghuo_agent_input.md.erb
|
226
|
+
- lib/luo/templates/xinghuo_response_error.md.erb
|
222
227
|
- lib/luo/version.rb
|
223
228
|
- lib/luo/xinghuo.rb
|
224
229
|
- lib/luo/xinghuo_agent_runner.rb
|
File without changes
|
File without changes
|
/data/lib/luo/{templates/luo_agent_tool_input.md.erb → projects/prompts/agent_tool_input.md.erb}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|