luo 0.1.17 → 0.1.20

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: 2721c5f83c0322dbd49ed200ee05740604e9398483d64eb4f8845f4bed0e58ce
4
- data.tar.gz: 91f9f1c00f36ac96b51aabbe78a308bdc6da83b9580dda0dae1686ccc69b03e0
3
+ metadata.gz: 8704c313023d8ec033957282a0585bdbeeb51d9f76a7fe5415b48dbfff412c75
4
+ data.tar.gz: 847d8309389a0f8de711bb674014b45942c64a3719a027009a309a7ca741ef63
5
5
  SHA512:
6
- metadata.gz: 26b489a296e9b51a5f21af4a2358f6e3d2fb1a4fc9a9b5a9ead115da9db0dc88e2c6badc7770266b778cf21e9ac9631ed26bd82bbeee629e49248da1cefb3de2
7
- data.tar.gz: 2b7c099a3321deb860e40c146dda2a6c5c2ef718e4c843448f01b18bb009de9c7f582175cd42c1cc43991ea1f81fd721ce1bb0d4433529c32ae6b03021b1a039
6
+ metadata.gz: 240f45ee887a39ed426da4288ac259b4666a714dfa9c725417ba2b7ffe877f8bce2f58205c93847d64babcec8f59f8c2ea571a14c2a6736bc7731b9620bec788
7
+ data.tar.gz: d6fd03c0f45a0e406ff4861d4aef98d669fede266960620da40886f3c25fd95ba1d97cf80b9a00a95018e1e9cffec2cd9b50f8b0296c8858fe5d5be945cfcf58
data/Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
- FROM ruby:3.2.2-alpine
1
+ FROM ruby:3.2.2
2
2
 
3
3
  # Install docker/buildx-bin
4
- COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
4
+ #COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
5
5
 
6
6
  # Set the working directory to /luo
7
7
  WORKDIR /luo
@@ -12,12 +12,25 @@ COPY Gemfile Gemfile.lock luo.gemspec ./
12
12
  # Required in luo.gemspec
13
13
  COPY lib/luo/version.rb /luo/lib/luo/version.rb
14
14
 
15
- # Install system dependencies
16
- RUN apk add --no-cache --update build-base git docker openrc openssh-client-default \
17
- && rc-update add docker boot \
18
- && gem install bundler --version=2.4.3 \
15
+ RUN apt-get update && apt-get install -y --no-install-recommends \
16
+ build-essential gcc \
17
+ && gem install bundler --version=2.4.6 \
19
18
  && bundle install
20
19
 
20
+ ## install python and jupyterlab
21
+ # Install Python and JupyterLab
22
+ RUN apt-get install -y --no-install-recommends \
23
+ python3 python3-pip python3-dev && \
24
+ pip3 install --no-cache-dir jupyterlab && \
25
+ pip3 install jupyterlab-language-pack-zh-CN
26
+
27
+ RUN gem install pry
28
+ RUN gem install iruby
29
+ RUN iruby register --force
30
+
31
+ # Expose the JupyterLab port
32
+ EXPOSE 8888
33
+
21
34
  # Copy the rest of our application code into the container.
22
35
  # We do this after bundle install, to avoid having to run bundle
23
36
  # everytime we do small fixes in the source code.
@@ -27,8 +40,7 @@ COPY . .
27
40
  RUN gem build luo.gemspec && \
28
41
  gem install ./luo-*.gem --no-document
29
42
 
30
- RUN git config --global --add safe.directory /workdir
31
-
32
43
  WORKDIR /workdir
44
+ RUN rm -rf /luo
33
45
 
34
46
  ENTRYPOINT ["luo"]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- luo (0.1.17)
4
+ luo (0.1.19)
5
5
  dotenv (~> 2.8, >= 2.8.1)
6
6
  dry-cli (~> 1.0)
7
7
  dry-configurable (~> 1.0, >= 1.0.1)
@@ -0,0 +1,6 @@
1
+ services:
2
+ luo:
3
+ build: .
4
+ command: r
5
+ ports:
6
+ - 8888:8888
data/init.rb ADDED
@@ -0,0 +1,16 @@
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
data/lib/luo/cli.rb CHANGED
@@ -37,7 +37,7 @@ module Luo
37
37
  desc "Run Luo"
38
38
 
39
39
  def call(*)
40
- exec "ruby app.rb"
40
+ exec "jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root"
41
41
  end
42
42
  end
43
43
 
@@ -14,6 +14,7 @@ module Luo
14
14
  gemfile = <<-GEMFILE.gsub(/^ */, '')
15
15
  source 'https://rubygems.org'
16
16
  gem 'luo', '~> #{version}'
17
+ gem 'iruby'
17
18
  GEMFILE
18
19
  File.open('Gemfile', 'w') do |file|
19
20
  file.puts(gemfile)
@@ -40,6 +41,7 @@ module Luo
40
41
  copy_file('env', '.env')
41
42
  copy_file('time_agent.rb', 'agents/time_agent.rb')
42
43
  copy_file('weather_agent.rb', 'agents/weather_agent.rb')
44
+ copy_file('luo.ipynb', 'luo.ipynb')
43
45
  copy_file("test.yml", "test.yml")
44
46
  end
45
47
 
@@ -7,4 +7,10 @@ require 'luo'
7
7
  include Luo
8
8
 
9
9
  Loader.push_dir(File.join(__dir__, 'agents'))
10
- Loader.setup
10
+ Loader.setup
11
+
12
+ begin
13
+ IRuby::Kernel.instance.switch_backend!(:pry)
14
+ rescue => e
15
+ #
16
+ end
@@ -0,0 +1,167 @@
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
+ }
data/lib/luo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Luo
4
- VERSION = "0.1.17"
4
+ VERSION = "0.1.20"
5
5
  end
data/luo CHANGED
@@ -1,19 +1,14 @@
1
1
  #!/bin/bash
2
2
 
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
- # "$@"
3
+ if [[ $1 == "update" ]]; then
4
+ echo "Pulling the latest Docker image..."
5
+ docker pull ghcr.io/mjason/luo:latest
6
+ fi
7
+
8
+ echo "Running the Docker container..."
14
9
 
15
- # 性能高
16
10
  docker run --rm -it \
11
+ -p 8888:8888 \
17
12
  -v "$PWD:/workdir" \
18
13
  ghcr.io/mjason/luo:latest \
19
- "$@"
14
+ "$@"
data/luo.ipynb ADDED
@@ -0,0 +1,84 @@
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
+ }
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.17
4
+ version: 0.1.20
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 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -187,7 +187,9 @@ files:
187
187
  - README.md
188
188
  - README.zh.md
189
189
  - Rakefile
190
+ - docker-compose.yml
190
191
  - exe/luo
192
+ - init.rb
191
193
  - lib/luo.rb
192
194
  - lib/luo/agent.rb
193
195
  - lib/luo/agent_runner_base.rb
@@ -206,6 +208,7 @@ files:
206
208
  - lib/luo/projects/application.rb
207
209
  - lib/luo/projects/env
208
210
  - lib/luo/projects/init.rb
211
+ - lib/luo/projects/luo.ipynb
209
212
  - lib/luo/projects/prompts/agent_input.md.erb
210
213
  - lib/luo/projects/prompts/agent_system.md.erb
211
214
  - lib/luo/projects/prompts/agent_tool_input.md.erb
@@ -229,6 +232,7 @@ files:
229
232
  - lib/luo/xinghuo_agent_runner.rb
230
233
  - luo
231
234
  - luo.gemspec
235
+ - luo.ipynb
232
236
  - sig/luo.rbs
233
237
  - sig/luo/agent.rbs
234
238
  - sig/luo/agent_runner_base.rbs