tiny_pair 1.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/tiny_pair.rb +55 -0
  3. metadata +57 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a8277eb9531bc7cac4382beef85c9005df5052ff947cec691c3017bf00f276e5
4
+ data.tar.gz: df2adc92464f9b22fccb83f593a0e9ea047217c5545329f30f43e09adebee20c
5
+ SHA512:
6
+ metadata.gz: 83f3d378f2d080da1031a80813c39011beba51d4e7255e6515055618fee687f32be091671ae202780b0d77ac2c265d13b3ee855409367173ef34a89f106c766f
7
+ data.tar.gz: 28b4e2b443c0deae01f215d76c1aa7faf4c02ad19002b2fffc472c30c361a6eaef453510d1d3b98a7228a5b5c8ed0658a7383e2de9e35b2cd78b6a70d9072b4e
data/lib/tiny_pair.rb ADDED
@@ -0,0 +1,55 @@
1
+ require 'tiny_gemini'
2
+
3
+ # if you can write the specification for some code, shouldn't the computer be
4
+ # able to write the implementation?
5
+ #
6
+ # get your Google Gemini API key ready, and then run the following code to see
7
+ # what happens:
8
+ #
9
+ # tp = TinyPair.new
10
+ # puts tp.implement(tests: TinyPair::TESTS)
11
+ class TinyPair
12
+ MODEL_INSTRUCTIONS = <<~INSTR
13
+ You will be given some minitest tests in Ruby, and I want you to return the matching Ruby implementation.
14
+
15
+ You should use the latest version of Ruby you know of, and try to keep the output code to an 80-column width
16
+
17
+ Do not explain the code or any surrounding documentation: only provide the implementation code in plaintext and nothing else.
18
+ INSTR
19
+
20
+ TESTS = <<~TEST_TEXT
21
+ class TestCalc < Minitest::Test
22
+ def test_add_two_and_two
23
+ assert_equal 4, Calc.add(2, 2)
24
+ end
25
+
26
+ def test_add_two_and_seven
27
+ assert_equal 9, Calc.add(2, 7)
28
+ end
29
+
30
+ def test_multi_three_and_five
31
+ assert_equal 15, Calc.multi(3, 5)
32
+ end
33
+
34
+ def test_multi_six_and_nineteen
35
+ assert_equal 114, Calc.multi(6, 19)
36
+ end
37
+ end
38
+ TEST_TEXT
39
+
40
+ def initialize(instructions: MODEL_INSTRUCTIONS)
41
+ @client = TinyGemini.new(
42
+ model: 'gemini-1.5-flash',
43
+ system_instruction: MODEL_INSTRUCTIONS,
44
+ api_key: ENV['GEMINI_KEY']
45
+ )
46
+ end
47
+
48
+ # tests: the raw text of a series of minitest tests
49
+ def implement(tests:)
50
+ @client.prompt({
51
+ parts: { text: tests },
52
+ role: 'user'
53
+ })
54
+ end
55
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tiny_pair
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Lunt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-08-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tiny_gemini
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: a tiny gem pair programming with a computer
28
+ email: jefflunt@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/tiny_pair.rb
34
+ homepage: https://github.com/jefflunt/tiny_pair
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.4.19
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: a tiny gem pair programming with a computer
57
+ test_files: []