luo 0.1.25 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +7 -4
  3. data/exe/luo +2 -3
  4. data/lib/luo/cli/init_app.rb +17 -0
  5. data/lib/luo/cli/init_base.rb +45 -0
  6. data/lib/luo/cli/init_notebook.rb +20 -0
  7. data/lib/luo/cli.rb +33 -49
  8. data/lib/luo/helpers.rb +54 -0
  9. data/lib/luo/{init_project.rb → init_project._rb} +1 -1
  10. data/lib/luo/marqo.rb +1 -1
  11. data/lib/luo/open_ai_agent_runner.rb +15 -4
  12. data/lib/luo/parser_markdown.rb +34 -0
  13. data/lib/luo/project_init.rb +9 -0
  14. data/lib/luo/prompt_template.rb +7 -3
  15. data/lib/luo/prompts.rb +30 -2
  16. data/lib/luo/version.rb +1 -1
  17. data/lib/luo/xinghuo.rb +9 -8
  18. data/lib/luo/xinghuo_agent_runner.rb +7 -3
  19. data/lib/luo.rb +24 -2
  20. data/luo.gemspec +4 -1
  21. data/sig/luo/prompt_template.rbs +1 -1
  22. data/templates/AppGemfile +3 -0
  23. data/templates/NoteBookGemfile +5 -0
  24. data/{lib/luo/projects → templates}/application.rb +5 -1
  25. data/templates/luo.ipynb +292 -0
  26. data/templates/prompts/luo_error.md.erb +8 -0
  27. metadata +70 -46
  28. data/.idea/.gitignore +0 -8
  29. data/.idea/dictionaries/mj.xml +0 -7
  30. data/.idea/inspectionProfiles/Project_Default.xml +0 -9
  31. data/.idea/luo.iml +0 -81
  32. data/.idea/misc.xml +0 -4
  33. data/.idea/modules.xml +0 -8
  34. data/.idea/vcs.xml +0 -6
  35. data/init.rb +0 -16
  36. data/lib/luo/projects/luo.ipynb +0 -167
  37. data/lib/luo/templates/agent_input.md.erb +0 -39
  38. data/lib/luo/templates/agent_system.md.erb +0 -4
  39. data/lib/luo/templates/agent_tool_input.md.erb +0 -10
  40. data/lib/luo/templates/demo.md.erb +0 -1
  41. data/lib/luo/templates/luo_xinghuo_agent_tool_input.md.erb +0 -16
  42. data/lib/luo/templates/xinghuo_agent_input.md.erb +0 -10
  43. data/lib/luo/templates/xinghuo_response_error.md.erb +0 -10
  44. data/luo.ipynb +0 -84
  45. data/templates/luo_agent_input.md.erb +0 -39
  46. data/templates/luo_agent_system.md.erb +0 -4
  47. data/templates/luo_agent_tool_input.md.erb +0 -10
  48. data/templates/luo_commit.md.erb +0 -2
  49. data/templates/luo_xinghuo_agent_input.md.erb +0 -10
  50. data/templates/luo_xinghuo_agent_tool_input.md.erb +0 -16
  51. data/templates/luo_xinghuo_response_error.md.erb +0 -10
  52. data/templates/prompt.demo.erb +0 -1
  53. /data/{lib/luo/projects → templates}/env +0 -0
  54. /data/{lib/luo/projects → templates}/init.rb +0 -0
  55. /data/{lib/luo/projects → templates}/prompts/agent_input.md.erb +0 -0
  56. /data/{lib/luo/projects → templates}/prompts/agent_system.md.erb +0 -0
  57. /data/{lib/luo/projects → templates}/prompts/agent_tool_input.md.erb +0 -0
  58. /data/{lib/luo/templates → templates/prompts}/luo_commit.md.erb +0 -0
  59. /data/{lib/luo/projects → templates}/prompts/xinghuo_agent_input.md.erb +0 -0
  60. /data/{lib/luo/projects → templates}/prompts/xinghuo_response_error.md.erb +0 -0
  61. /data/{lib/luo/projects → templates}/test.yml +0 -0
  62. /data/{lib/luo/projects → templates}/time_agent.rb +0 -0
  63. /data/{lib/luo/projects → templates}/weather_agent.rb +0 -0
data/init.rb DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/setup"
4
- Bundler.require
5
-
6
- require 'luo'
7
- include Luo
8
-
9
- Loader.push_dir(File.join(__dir__, 'agents'))
10
- Loader.setup
11
-
12
- begin
13
- IRuby::Kernel.instance.switch_backend!(:pry)
14
- rescue => e
15
- #
16
- end
@@ -1,167 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "id": "ac60deeb-0d75-478e-823a-dfe39e73aa72",
6
- "metadata": {},
7
- "source": [
8
- "欢迎使用luo实验室"
9
- ]
10
- },
11
- {
12
- "cell_type": "code",
13
- "execution_count": 1,
14
- "id": "785fea13-bdfb-4bc6-80e7-1c53d8ca2f84",
15
- "metadata": {
16
- "tags": []
17
- },
18
- "outputs": [
19
- {
20
- "data": {
21
- "text/plain": [
22
- "true"
23
- ]
24
- },
25
- "execution_count": 1,
26
- "metadata": {},
27
- "output_type": "execute_result"
28
- }
29
- ],
30
- "source": [
31
- "# 初始化运行环境\n",
32
- "require_relative \"init\"\n",
33
- "require 'pry'\n",
34
- "IRuby::Kernel.instance.switch_backend!(:pry)"
35
- ]
36
- },
37
- {
38
- "cell_type": "code",
39
- "execution_count": 2,
40
- "id": "87d49a44-a485-4331-b982-6a9143490771",
41
- "metadata": {
42
- "tags": []
43
- },
44
- "outputs": [
45
- {
46
- "data": {
47
- "text/plain": [
48
- "Luo::XinghuoFinalAgent"
49
- ]
50
- },
51
- "execution_count": 2,
52
- "metadata": {},
53
- "output_type": "execute_result"
54
- }
55
- ],
56
- "source": [
57
- "class Runner < XinghuoAgentRunner\n",
58
- " register WeatherAgent\n",
59
- " register TimeAgent\n",
60
- " register XinghuoFinalAgent\n",
61
- "end"
62
- ]
63
- },
64
- {
65
- "cell_type": "code",
66
- "execution_count": 4,
67
- "id": "3b2b57cf-332e-4f4e-8b54-ee35950a0501",
68
- "metadata": {
69
- "tags": []
70
- },
71
- "outputs": [
72
- {
73
- "data": {
74
- "text/plain": [
75
- ":input"
76
- ]
77
- },
78
- "execution_count": 4,
79
- "metadata": {},
80
- "output_type": "execute_result"
81
- }
82
- ],
83
- "source": [
84
- "$runner = Runner.new\n",
85
- "\n",
86
- "def input(text)\n",
87
- " context = $runner.call(text)\n",
88
- " Helpers.print_md <<~MD\n",
89
- " ## Input:\n",
90
- " #{text}\n",
91
- "\n",
92
- " ## Response:\n",
93
- " #{context.response}\n",
94
- "\n",
95
- " ## Final Result:\n",
96
- " #{context.final_result}\n",
97
- "\n",
98
- " ## History:\n",
99
- " ```ruby\n",
100
- " #{context.histories.to_a}\n",
101
- " ```\n",
102
- " MD\n",
103
- " puts \"\\n\\n\\n\"\n",
104
- "end"
105
- ]
106
- },
107
- {
108
- "cell_type": "code",
109
- "execution_count": 5,
110
- "id": "3add85ed-2b49-4a5b-b625-eaf915825050",
111
- "metadata": {
112
- "tags": []
113
- },
114
- "outputs": [
115
- {
116
- "name": "stdout",
117
- "output_type": "stream",
118
- "text": [
119
- "** call aiui weather **\n",
120
- " Input:\n",
121
- " 明天的天气怎么样\n",
122
- "\n",
123
- " Response:\n",
124
- " 调用工具:天气查询。\n",
125
- "\n",
126
- " Final Result:\n",
127
- " 明天北京市全天多云,气温16℃ ~ 28℃,空气质量良,有南风微风,气候温暖。\n",
128
- "\n",
129
- " History:\n",
130
- " [{:role=>\"user\", :content=>\"明天的天气怎么样\"}, {:role=>\"assistant\", \n",
131
- " :content=>\"明天北京市全天多云,气温16℃ ~ \n",
132
- " 28℃,空气质量良,有南风微风,气候温暖。\"}]\n",
133
- "\n",
134
- "\n",
135
- "\n"
136
- ]
137
- }
138
- ],
139
- "source": [
140
- "input \"明天的天气怎么样\""
141
- ]
142
- },
143
- {
144
- "cell_type": "code",
145
- "execution_count": null,
146
- "id": "ca165db3-1711-41c3-85eb-3f7f02d04e0a",
147
- "metadata": {},
148
- "outputs": [],
149
- "source": []
150
- }
151
- ],
152
- "metadata": {
153
- "kernelspec": {
154
- "display_name": "Ruby 3.2.2",
155
- "language": "ruby",
156
- "name": "ruby"
157
- },
158
- "language_info": {
159
- "file_extension": ".rb",
160
- "mimetype": "application/x-ruby",
161
- "name": "ruby",
162
- "version": "3.2.2"
163
- }
164
- },
165
- "nbformat": 4,
166
- "nbformat_minor": 5
167
- }
@@ -1,39 +0,0 @@
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 %>
@@ -1,4 +0,0 @@
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.
@@ -1,10 +0,0 @@
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.
@@ -1 +0,0 @@
1
- <%= text %>
@@ -1,16 +0,0 @@
1
- 工具返回结果:
2
- <% @tools_response.each do |r| -%>
3
- > <%= r[:name] %>:<%= r[:response] %>
4
- <% end -%>
5
-
6
- 刚才的问题是:<%= @last_user_input %>
7
- 结合工具的输出和你的思考。
8
-
9
- 当你知道答案,用以下格式回答:
10
- 最终答案: 返回给用户的内容放在这里
11
-
12
- 当你需要使用工具,用以下格式回答:
13
- 工具调用: 如果工具 <%= @agents.values.map do |a| a.agent_name end.join(', ') %> 中有适合的那么输入合适的工具名,没有则输入无。
14
- 工具输入: 工具要求的输入, 如果不用输入或者工具要求不输入直接输入无。
15
-
16
- 你只能选择其中一种格式,那么你的答案是什么呢?
@@ -1,10 +0,0 @@
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
- ```
@@ -1,10 +0,0 @@
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/luo.ipynb DELETED
@@ -1,84 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "id": "ac60deeb-0d75-478e-823a-dfe39e73aa72",
6
- "metadata": {},
7
- "source": [
8
- "欢迎使用luo实验室"
9
- ]
10
- },
11
- {
12
- "cell_type": "code",
13
- "execution_count": 1,
14
- "id": "785fea13-bdfb-4bc6-80e7-1c53d8ca2f84",
15
- "metadata": {},
16
- "outputs": [
17
- {
18
- "data": {
19
- "text/plain": [
20
- "true"
21
- ]
22
- },
23
- "execution_count": 1,
24
- "metadata": {},
25
- "output_type": "execute_result"
26
- }
27
- ],
28
- "source": [
29
- "# 初始化运行环境\n",
30
- "require_relative \"init\""
31
- ]
32
- },
33
- {
34
- "cell_type": "code",
35
- "execution_count": 6,
36
- "id": "87d49a44-a485-4331-b982-6a9143490771",
37
- "metadata": {
38
- "tags": []
39
- },
40
- "outputs": [
41
- {
42
- "data": {
43
- "text/plain": [
44
- "Luo::XinghuoFinalAgent"
45
- ]
46
- },
47
- "execution_count": 6,
48
- "metadata": {},
49
- "output_type": "execute_result"
50
- }
51
- ],
52
- "source": [
53
- "class Runner < XinghuoAgentRunner\n",
54
- " register WeatherAgent\n",
55
- " register TimeAgent\n",
56
- " register XinghuoFinalAgent\n",
57
- "end"
58
- ]
59
- },
60
- {
61
- "cell_type": "code",
62
- "execution_count": null,
63
- "id": "3b2b57cf-332e-4f4e-8b54-ee35950a0501",
64
- "metadata": {},
65
- "outputs": [],
66
- "source": []
67
- }
68
- ],
69
- "metadata": {
70
- "kernelspec": {
71
- "display_name": "Ruby 3.2.1",
72
- "language": "ruby",
73
- "name": "ruby"
74
- },
75
- "language_info": {
76
- "file_extension": ".rb",
77
- "mimetype": "application/x-ruby",
78
- "name": "ruby",
79
- "version": "3.2.1"
80
- }
81
- },
82
- "nbformat": 4,
83
- "nbformat_minor": 5
84
- }
@@ -1,39 +0,0 @@
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 %>
@@ -1,4 +0,0 @@
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.
@@ -1,10 +0,0 @@
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.
@@ -1,2 +0,0 @@
1
- 你是一个git专家,我给你中文的commit,你提供合适的英文commit,然后我再提交到github上。
2
- 我的提交说明是:<%= commit %>
@@ -1,10 +0,0 @@
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
- ```
@@ -1,16 +0,0 @@
1
- 工具返回结果:
2
- <% @tools_response.each do |r| -%>
3
- > <%= r[:name] %>:<%= r[:response] %>
4
- <% end -%>
5
-
6
- 刚才的问题是:<%= @last_user_input %>
7
- 结合工具的输出和你的思考。
8
-
9
- 当你知道答案,用以下格式回答:
10
- 最终答案: 返回给用户的内容放在这里
11
-
12
- 当你需要使用工具,用以下格式回答:
13
- 工具调用: 如果工具 <%= @agents.values.map do |a| a.agent_name end.join(', ') %> 中有适合的那么输入合适的工具名,没有则输入无。
14
- 工具输入: 工具要求的输入, 如果不用输入或者工具要求不输入直接输入无。
15
-
16
- 你只能选择其中一种格式,那么你的答案是什么呢?
@@ -1,10 +0,0 @@
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
- ```
@@ -1 +0,0 @@
1
- <%= text %>
File without changes
File without changes
File without changes
File without changes
File without changes