jekyll-chatgpt-translate 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/README.md +9 -4
- data/jekyll-chatgpt-translate.gemspec +1 -1
- data/lib/jekyll-chatgpt-translate/chatgpt.rb +4 -0
- data/lib/jekyll-chatgpt-translate/plain.rb +2 -2
- data/lib/jekyll-chatgpt-translate/version.rb +1 -1
- data/test/test_chatgpt.rb +14 -0
- data/test/test_plain.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76c9c7e2f01f4350b38e1343d88918c9a89bfb5ace6bc84855bba6cd401cf027
|
4
|
+
data.tar.gz: 35dbf1ac0f89d6a3a68de2a1f36ae451686b665a8ef4a3f9adc4054623d45dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db448c1104508d9084c1b28ea687fda646b72c6c03b78e72c4423106c28d9414120b323957f0c967a7932926870fac33a7a7dc713571c0179f58cd5cdfca0f00
|
7
|
+
data.tar.gz: 96f431eb35b166ab4cc82575f8dbee0b80e845f5801d3d7436aede3d75becb196e3dd2aee36595742f0a664237bbe804d449e1f10348579b509111384beabb73
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -60,9 +60,14 @@ Full list of options available to specify in `_config.yml`:
|
|
60
60
|
* `api_key_file` (optional) — the file with OpenAI API key. If this option is not specified,
|
61
61
|
it is expected to have the key in the `OPENAI_API_KEY` environment variable.
|
62
62
|
|
63
|
-
* `
|
63
|
+
* `api_key` (optional) — the OpenAI API key itself. This is a very bad idea to
|
64
|
+
specify it right in the `_config.yml` file, but it's still possible.
|
64
65
|
|
65
|
-
* `
|
66
|
+
* `model` (optional) — specifies the model to use by ChatGPT,
|
67
|
+
[examples are here](https://github.com/alexrudall/ruby-openai#models).
|
68
|
+
|
69
|
+
* `source` (optional) — is the [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
|
70
|
+
code of the source language.
|
66
71
|
|
67
72
|
* `no_download` (optional) — if this attribute is present, the plugin won't try
|
68
73
|
to find HTML versions of translated pages in the Internet and won't try to
|
@@ -79,7 +84,7 @@ This layout will be specified for the pages generated by this plugin.
|
|
79
84
|
|
80
85
|
* `targets` (mandatory) — an array of target languages, each of which has the following attributes
|
81
86
|
|
82
|
-
* `language` (mandatory) — ISO-
|
87
|
+
* `language` (mandatory) — [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) code of the target language
|
83
88
|
|
84
89
|
* `permalink` (mandatory) — template to use for newly generated pages
|
85
90
|
|
@@ -93,7 +98,7 @@ This layout will be specified for the pages generated by this plugin.
|
|
93
98
|
* `version` (optional) — the version that will be attached to each generated page,
|
94
99
|
in order to avoid repetitive translations on one hand and enable re-translations
|
95
100
|
when the `version` is changed on another hand. By default, the version of
|
96
|
-
|
101
|
+
this plugin will be used, unless you set your own value.
|
97
102
|
|
98
103
|
## How to Contribute
|
99
104
|
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
29
29
|
s.required_ruby_version = '>= 2.6'
|
30
30
|
s.name = 'jekyll-chatgpt-translate'
|
31
|
-
s.version = '0.0.
|
31
|
+
s.version = '0.0.25'
|
32
32
|
s.license = 'MIT'
|
33
33
|
s.summary = 'Translate Jekyll Pages Through ChatGPT'
|
34
34
|
s.description = [
|
data/test/test_chatgpt.rb
CHANGED
@@ -44,6 +44,20 @@ class GptTranslate::ChatGPTTest < Minitest::Test
|
|
44
44
|
assert_equal('done!', chat.translate('[OpenAI](https://openai.com) is the creator of ChatGPT', min: 10))
|
45
45
|
end
|
46
46
|
|
47
|
+
def test_unordered_list_item
|
48
|
+
stub_request(:any, 'https://api.openai.com/v1/chat/completions')
|
49
|
+
.to_return(body: '{"choices":[{"message":{"content": "done!"}}]}')
|
50
|
+
chat = GptTranslate::ChatGPT.new('fake-key', 'gpt-3.5-turbo', 'en', 'ru')
|
51
|
+
assert_equal("* done!\n\n* done!", chat.translate("* First\n\n* Second", min: 1))
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_ordered_list_item
|
55
|
+
stub_request(:any, 'https://api.openai.com/v1/chat/completions')
|
56
|
+
.to_return(body: '{"choices":[{"message":{"content": "done!"}}]}')
|
57
|
+
chat = GptTranslate::ChatGPT.new('fake-key', 'gpt-3.5-turbo', 'en', 'ru')
|
58
|
+
assert_equal("1. done!\n\n1. done!", chat.translate("1. First\n\n2. Second", min: 1))
|
59
|
+
end
|
60
|
+
|
47
61
|
def test_dry_mode
|
48
62
|
chat = GptTranslate::ChatGPT.new('', 'foo', 'xx', 'xx')
|
49
63
|
assert_equal(38, chat.translate('This text should not be sent to OpenAI', min: 100).length)
|
data/test/test_plain.rb
CHANGED
@@ -42,25 +42,25 @@ class GptTranslate::PlainTest < Minitest::Test
|
|
42
42
|
|
43
43
|
def test_lists
|
44
44
|
assert_equal(
|
45
|
-
"first\n\
|
45
|
+
"* first\n\n* second\n\n* third",
|
46
46
|
GptTranslate::Plain.new("* first\n\n* second\n\n* third").to_s
|
47
47
|
)
|
48
48
|
assert_equal(
|
49
|
-
'first',
|
49
|
+
'* first',
|
50
50
|
GptTranslate::Plain.new("* first\n\n\n\n").to_s
|
51
51
|
)
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_ordered_list
|
55
55
|
assert_equal(
|
56
|
-
"first\n\
|
56
|
+
"1. first\n\n1. second\n\n1. third",
|
57
57
|
GptTranslate::Plain.new("1. first\n\n2. second\n\n3. third").to_s
|
58
58
|
)
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_compact_list
|
62
62
|
assert_equal(
|
63
|
-
"first\n\
|
63
|
+
"* first\n\n* second\n\n* third",
|
64
64
|
GptTranslate::Plain.new("* first\n* second\n* third").to_s
|
65
65
|
)
|
66
66
|
end
|
@@ -151,11 +151,11 @@ class GptTranslate::PlainTest < Minitest::Test
|
|
151
151
|
|
152
152
|
In this *lovely* letter I will explain how objects work in C++:
|
153
153
|
|
154
|
-
Declare a class
|
154
|
+
* Declare a class
|
155
155
|
|
156
|
-
Make an instance of it
|
156
|
+
* Make an instance of it
|
157
157
|
|
158
|
-
Delete the instance
|
158
|
+
* Delete the instance
|
159
159
|
|
160
160
|
## More details
|
161
161
|
|