tiny_pair 1.0.0 → 2.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.
- checksums.yaml +4 -4
- data/lib/tiny_pair.rb +39 -16
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4acbf237fbd17f3191100d48e5549fee2ba87c760d8c6b5ff92fcea828aa3efd
|
4
|
+
data.tar.gz: 72001b4be9760b31e800842d994d4c98216c37bf738fdf7b42fc3c8e0976b140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61ebbb83b85b7bee5facdcacb02f5f3b4c6ec325dbc5ebe7efe9bca57d1b8849e1d2d22689e03ec7acf7f56553c48058b8be6e3f7ae0980a1c66988ad2556944
|
7
|
+
data.tar.gz: 131394bfe45e73929477de3080cb66513da319f8eb30f98cf31d42a8a0d8d63967abd3079c20c7c58231711c5812909ad6ae334d5dda1e6c7d274a3d94d60e3b
|
data/lib/tiny_pair.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'gemini-ai'
|
2
2
|
|
3
3
|
# if you can write the specification for some code, shouldn't the computer be
|
4
4
|
# able to write the implementation?
|
@@ -7,17 +7,21 @@ require 'tiny_gemini'
|
|
7
7
|
# what happens:
|
8
8
|
#
|
9
9
|
# tp = TinyPair.new
|
10
|
-
# puts tp.
|
10
|
+
# puts tp.(prompt: TinyPair::TEST_TEXT)
|
11
|
+
#
|
12
|
+
# override model instructions if you like:
|
13
|
+
# tp = TinyPair.new(instructions: <your custom instructions>)
|
14
|
+
#
|
11
15
|
class TinyPair
|
12
|
-
|
16
|
+
TEST_MODEL_INSTRUCTIONS = <<~INSTR
|
13
17
|
You will be given some minitest tests in Ruby, and I want you to return the matching Ruby implementation.
|
14
18
|
|
15
|
-
You should use the latest version of Ruby you know of, and try to keep the output code to an 80-column width
|
19
|
+
You should use the latest version of Ruby you know of, and try to keep the output code to an 80-column width.
|
16
20
|
|
17
|
-
|
21
|
+
Only reply with a code snippet; no documentation, and no explanation.
|
18
22
|
INSTR
|
19
23
|
|
20
|
-
|
24
|
+
TEST_TEXT = <<~TEST_TEXT
|
21
25
|
class TestCalc < Minitest::Test
|
22
26
|
def test_add_two_and_two
|
23
27
|
assert_equal 4, Calc.add(2, 2)
|
@@ -37,19 +41,38 @@ class TinyPair
|
|
37
41
|
end
|
38
42
|
TEST_TEXT
|
39
43
|
|
40
|
-
def initialize(
|
41
|
-
@client =
|
42
|
-
|
43
|
-
|
44
|
-
|
44
|
+
def initialize(api_key: ENV['TINY_PAIR_GEMINI_API_KEY'], model: ENV['TINY_PAIR_GEMINI_MODEL'])
|
45
|
+
@client = Gemini.new(
|
46
|
+
credentials: {
|
47
|
+
service: 'generative-language-api',
|
48
|
+
api_key: api_key,
|
49
|
+
},
|
50
|
+
options: { model: model, server_sent_events: false }
|
45
51
|
)
|
46
52
|
end
|
47
53
|
|
48
54
|
# tests: the raw text of a series of minitest tests
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
55
|
+
def llm(prompt:, instructions:)
|
56
|
+
instructions = instructions.lines.map(&:strip).select{|l| !l.empty? }.join(' ')
|
57
|
+
request_body = {
|
58
|
+
# NOTE: this doesn't seem to work, and I'm not sure why, so I put it in the
|
59
|
+
# prompt
|
60
|
+
# system_instruction: {
|
61
|
+
# role: 'user',
|
62
|
+
# parts: { text: instructions }
|
63
|
+
# },
|
64
|
+
contents: {
|
65
|
+
role: 'user',
|
66
|
+
parts: [
|
67
|
+
{ text: instructions },
|
68
|
+
{ text: prompt }
|
69
|
+
]
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
@client
|
74
|
+
.generate_content(request_body)['candidates']
|
75
|
+
.first['content']['parts']
|
76
|
+
.first['text']
|
54
77
|
end
|
55
78
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_pair
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Lunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: gemini-ai
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description: a tiny
|
27
|
+
description: a tiny pair programming gem that uses an LLM
|
28
28
|
email: jefflunt@gmail.com
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
@@ -50,8 +50,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '0'
|
52
52
|
requirements: []
|
53
|
-
rubygems_version: 3.
|
53
|
+
rubygems_version: 3.5.23
|
54
54
|
signing_key:
|
55
55
|
specification_version: 4
|
56
|
-
summary: a tiny
|
56
|
+
summary: a tiny pair programming gem that uses an LLM
|
57
57
|
test_files: []
|