sublayer 0.0.5 → 0.0.7

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: 05adf0abb1924f82c0e60a66265331c2b9cfead17a39114fc0dd9c395e5e00ff
4
- data.tar.gz: 20a1dfdfbdec1bb59356736150dfc48e623838fc8807e13e743a08205a8d6105
3
+ metadata.gz: 07ead9b290805b3d7e173f8e613dd4670bdd304a094cb7a00505ac9d94285b9b
4
+ data.tar.gz: 89eba4a05eebb012013a68e06f4d44e8a1710db0ea8a808ed03557241f4baf74
5
5
  SHA512:
6
- metadata.gz: 9bc8be69c42f61099bd35163d7b15661cee6244fd5d26a7b1ca0d2cb6b4932c08ed57721a88def4ba2168a27d04080242c19d3c5282d0d9724826de4c1fc9a77
7
- data.tar.gz: 7b3e0f0948534ac8313568d8318db2fac51a60467fb8d879d648bccd900ca67ff1dcb7757330f9c5348e69ce463e4376684959d154007365095abd290eea9cda
6
+ metadata.gz: a6f07414c4a7a2798f2b93133bd921cae8ffe380104f813564109ab16b985dd58c416f6b176f33d75910898b56d47ea98262a1f1035071cb29dddf2f53277b82
7
+ data.tar.gz: 45953c8a3a63c526bd310f4928a1570210e54e6e1be5718ff50b28041a8e9e93ca175d8d984ca6abd8aa729b87f5c84bf922e547c6a8f22ef62272bd240eade2
data/README.md CHANGED
@@ -26,7 +26,7 @@ Sublayer is model-agnostic and can be used with any AI model. Below are the
26
26
 
27
27
  Expects you to have an OpenAI API key set in the `OPENAI_API_KEY` environment variable.
28
28
 
29
- Visit [OpenAI](https://openai.com/product) to get an API key.
29
+ Visit [OpenAI](https://openai.com/product) to get an API key.
30
30
 
31
31
  Usage:
32
32
  ```ruby
@@ -71,26 +71,60 @@ Sublayer.configuration.ai_provider = Sublayer::Providers::Groq
71
71
  Sublayer.configuration.ai_model = "mixtral-8x7b-32768"
72
72
  ```
73
73
 
74
- ### Local (Experimental with Hermes2)
74
+ ### Local
75
75
 
76
- *Tested against the latest [Hermes 2 Mistral
77
- Model](https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B-GGUF)*
76
+ If you've never run a local model before see the [Local Model Quickstart](#local-model-quickstart) below. Know that local models take several GB of space.
78
77
 
79
- Support for running a local model and serving an API on https://localhost:8080
78
+ The model you use must have the ChatML formatted v1/chat/completions endpoint to work with sublayer (many models do by default)
80
79
 
81
- The simplest way to do this is to download
82
- [llamafile](https://github.com/Mozilla-Ocho/llamafile) and download one of the
83
- server llamafiles they provide.
84
-
85
- We've also tested with [Hermes 2 Mistral](https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B-GGUF) from
86
- [Nous
87
- Research](https://nousresearch.com/).
80
+ Usage:
88
81
 
82
+ Run your local model on http://localhost:8080 and then set:
89
83
  ```ruby
90
84
  Sublayer.configuration.ai_provider = Sublayer::Providers::Local
91
85
  Sublayer.configuration.ai_model = "LLaMA_CPP"
92
86
  ```
93
87
 
88
+ #### Local Model Quickstart:
89
+
90
+ Instructions to run a local model
91
+
92
+ 1. Setting up Llamafile
93
+
94
+ ```bash
95
+ cd where/you/keep/your/projects
96
+ git clone git@github.com:Mozilla-Ocho/llamafile.git
97
+ cd llamafile
98
+ ```
99
+
100
+ Download: https://cosmo.zip/pub/cosmos/bin/make (windows users need this too: https://justine.lol/cosmo3/)
101
+
102
+ ```bash
103
+ # within llamafile directory
104
+ chmod +x path/to/the/downloaded/make
105
+ path/to/the/downloaded/make -j8
106
+ sudo path/to/the/downloaded/make install PREFIX=/usr/local
107
+ ```
108
+ You can now run llamfile
109
+
110
+ 2. Downloading Model
111
+
112
+ click [here](https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B-GGUF/resolve/main/Hermes-2-Pro-Mistral-7B.Q5_K_M.gguf?download=true) to download Mistral_7b.Q5_K_M (5.13 GB)
113
+
114
+ 3. Running Llamafile with a model
115
+
116
+ ```bash
117
+ llamafile -ngl 9999 -m path/to/the/downloaded/Hermes-2-Pro-Mistral-7B.Q5_K_M.gguf --host 0.0.0.0 -c 4096
118
+ ```
119
+
120
+ You are now running a local model on http://localhost:8080
121
+
122
+ #### Recommended Settings for Apple M1 users:
123
+ ```bash
124
+ llamafile -ngl 9999 -m Hermes-2-Pro-Mistral-7B.Q5_K_M.gguf --host 0.0.0.0 --nobrowser -c 2048 --gpu APPLE -t 12
125
+ ```
126
+ run `sysctl -n hw.logicalcpu` to see what number to give the `-t` threads option
127
+
94
128
  ## Concepts
95
129
 
96
130
  ### Generators
@@ -99,12 +133,12 @@ Generators are responsible for generating specific outputs based on input data.
99
133
  They focus on a single generation task and do not perform any actions or complex
100
134
  decision-making. Generators are the building blocks of the Sublayer framework.
101
135
 
102
- Examples (in the /examples/ directory):
103
- - CodeFromDescriptionGenerator: Generates code based on a description and the
136
+ Examples (in the `/lib/sublayer/generators/examples` directory):
137
+ - `CodeFromDescriptionGenerator`: Generates code based on a description and the
104
138
  technologies used.
105
- - DescriptionFromCodeGenerator: Generates a description of the code passed in to
139
+ - `DescriptionFromCodeGenerator`: Generates a description of the code passed in to
106
140
  it.
107
- - CodeFromBlueprintGenerator: Generates code based on a blueprint, a blueprint
141
+ - `CodeFromBlueprintGenerator`: Generates code based on a blueprint, a blueprint
108
142
  description, and a description of the desired code.
109
143
 
110
144
 
@@ -0,0 +1,6 @@
1
+ module Sublayer
2
+ module Agents
3
+ class Base
4
+ end
5
+ end
6
+ end
@@ -4,7 +4,21 @@ module Sublayer
4
4
  attr_reader :name
5
5
 
6
6
  def self.create(options)
7
- ("Sublayer::Components::OutputAdapters::"+options[:type].to_s.camelize).constantize.new(options)
7
+ klass = if options.has_key?(:class)
8
+ klass = options[:class]
9
+ if klass.is_a?(String)
10
+ klass.constantize
11
+ elsif klass.is_a?(Class)
12
+ klass
13
+ else
14
+ raise "Invalid :class option"
15
+ end
16
+ elsif (type = options[:type])
17
+ "Sublayer::Components::OutputAdapters::#{type.to_s.camelize}".constantize
18
+ else
19
+ raise "Output adapter must be specified with :class or :type"
20
+ end
21
+ klass.new(options)
8
22
  end
9
23
  end
10
24
  end
@@ -30,7 +30,7 @@ module Sublayer
30
30
  response = HTTParty.post(
31
31
  "https://api.anthropic.com/v1/messages",
32
32
  headers: {
33
- "x-api-key": ENV["ANTHROPIC_API_KEY"],
33
+ "x-api-key": ENV.fetch("ANTHROPIC_API_KEY"),
34
34
  "anthropic-version": "2023-06-01",
35
35
  "content-type": "application/json"
36
36
  },
@@ -5,7 +5,7 @@ module Sublayer
5
5
  module Providers
6
6
  class OpenAI
7
7
  def self.call(prompt:, output_adapter:)
8
- client = ::OpenAI::Client.new(access_token: ENV["OPENAI_API_KEY"])
8
+ client = ::OpenAI::Client.new(access_token: ENV.fetch("OPENAI_API_KEY"))
9
9
 
10
10
  response = client.chat(
11
11
  parameters: {
@@ -0,0 +1,6 @@
1
+ module Sublayer
2
+ module Tasks
3
+ class Base
4
+ end
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sublayer
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.7"
5
5
  end
data/sublayer.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.metadata["homepage_uri"] = "https://docs.sublayer.com"
18
18
  spec.metadata["documentation_uri"] = "https://docs.sublayer.com"
19
19
  spec.metadata["bug_tracker_uri"] = "https://github.com/sublayerapp/sublayer/issues"
20
+ spec.metadata["source_code_uri"] = "https://github.com/sublayerapp/sublayer"
20
21
 
21
22
  # Specify which files should be added to the gem when it is released.
22
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -37,6 +38,8 @@ Gem::Specification.new do |spec|
37
38
  spec.add_dependency "httparty"
38
39
 
39
40
  spec.add_development_dependency "rspec", "~> 3.12"
40
- spec.add_development_dependency "pry", " ~> 0.14"
41
+ spec.add_development_dependency "pry", "~> 0.14"
42
+ spec.add_development_dependency "vcr", "~> 6.0"
43
+ spec.add_development_dependency "webmock", "~> 3.0"
41
44
  spec.add_development_dependency "clag"
42
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sublayer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Werner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-08 00:00:00.000000000 Z
11
+ date: 2024-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai
@@ -122,6 +122,34 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0.14'
125
+ - !ruby/object:Gem::Dependency
126
+ name: vcr
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '6.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '6.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: webmock
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.0'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: clag
127
155
  requirement: !ruby/object:Gem::Requirement
@@ -147,20 +175,22 @@ files:
147
175
  - LICENSE
148
176
  - README.md
149
177
  - Rakefile
150
- - examples/code_from_blueprint_generator.rb
151
- - examples/code_from_description_generator.rb
152
- - examples/description_from_code_generator.rb
153
- - examples/invalid_to_valid_json_generator.rb
154
178
  - lib/sublayer.rb
155
179
  - lib/sublayer/actions/base.rb
180
+ - lib/sublayer/agents/base.rb
156
181
  - lib/sublayer/components/output_adapters.rb
157
182
  - lib/sublayer/components/output_adapters/single_string.rb
158
183
  - lib/sublayer/generators/base.rb
184
+ - lib/sublayer/generators/examples/code_from_blueprint_generator.rb
185
+ - lib/sublayer/generators/examples/code_from_description_generator.rb
186
+ - lib/sublayer/generators/examples/description_from_code_generator.rb
187
+ - lib/sublayer/generators/examples/invalid_to_valid_json_generator.rb
159
188
  - lib/sublayer/providers/claude.rb
160
189
  - lib/sublayer/providers/gemini.rb
161
190
  - lib/sublayer/providers/groq.rb
162
191
  - lib/sublayer/providers/local.rb
163
192
  - lib/sublayer/providers/open_ai.rb
193
+ - lib/sublayer/tasks/base.rb
164
194
  - lib/sublayer/version.rb
165
195
  - sublayer.gemspec
166
196
  homepage: https://docs.sublayer.com
@@ -170,6 +200,7 @@ metadata:
170
200
  homepage_uri: https://docs.sublayer.com
171
201
  documentation_uri: https://docs.sublayer.com
172
202
  bug_tracker_uri: https://github.com/sublayerapp/sublayer/issues
203
+ source_code_uri: https://github.com/sublayerapp/sublayer
173
204
  post_install_message:
174
205
  rdoc_options: []
175
206
  require_paths: