jekyll-chatgpt-translate 0.0.23 → 0.0.24
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 496c59378248bd1973071e0ed6d01d0e55253cf0c47dce9f72b2704ba315e9e3
|
4
|
+
data.tar.gz: 13905a9d5f52ed1558f1e0679af7ec236936b4d77eb97d0c8e63ce3e0cb72ac7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63e2c67379437c2f6aa20cff512452fcb2d2237b1e5d8a1d8bb0155c67a4ee044bfb4957765bff3daab4d24fdb875779ec9bffd8419e1331f0efd3667ee19d38
|
7
|
+
data.tar.gz: 84ab3c8daa5173849cbcaeeb067ddf7470fa04b099c1793582c99f44f4a64e0fbf65b842817e0c489996cd742d8335de3f4fc62576aaede50212aeb4ff7d7c22
|
@@ -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.24'
|
32
32
|
s.license = 'MIT'
|
33
33
|
s.summary = 'Translate Jekyll Pages Through ChatGPT'
|
34
34
|
s.description = [
|
@@ -59,7 +59,7 @@ class GptTranslate::ChatGPT
|
|
59
59
|
elsif par.start_with?('```') || par.end_with?('```')
|
60
60
|
Jekyll.logger.debug("Not translating this code block: #{par.inspect}")
|
61
61
|
par
|
62
|
-
elsif par =~ /^[^\p{Alnum}\*'"]/
|
62
|
+
elsif par =~ /^[^\p{Alnum}\*'"\[]/
|
63
63
|
Jekyll.logger.debug("Not translating this, b/c it's not a plain text: #{par.inspect}")
|
64
64
|
par
|
65
65
|
elsif @key.empty?
|
@@ -62,6 +62,7 @@ class GptTranslate::Generator < Jekyll::Generator
|
|
62
62
|
site.posts.docs.shuffle.each do |doc|
|
63
63
|
plain = GptTranslate::Plain.new(doc.content).to_s
|
64
64
|
config['targets'].each do |target|
|
65
|
+
start = Time.now
|
65
66
|
link = GptTranslate::Permalink.new(doc, target['permalink']).to_path
|
66
67
|
lang = target['language']
|
67
68
|
raise 'Language must be defined for each target' if target.nil?
|
@@ -106,7 +107,8 @@ class GptTranslate::Generator < Jekyll::Generator
|
|
106
107
|
)
|
107
108
|
site.pages << Jekyll::Page.new(site, site.source, File.dirname(path), File.basename(path))
|
108
109
|
translated += 1
|
109
|
-
Jekyll.logger.info("Translated via ChatGPT
|
110
|
+
Jekyll.logger.info("Translated via ChatGPT \
|
111
|
+
in #{(Time.now - start).round(2)}s: #{path} (#{File.size(path)} bytes)")
|
110
112
|
end
|
111
113
|
doc.data["translated-#{lang}-url"] = link
|
112
114
|
doc.data['chatgpt-model'] = model
|
data/test/test_chatgpt.rb
CHANGED
@@ -37,6 +37,13 @@ class GptTranslate::ChatGPTTest < Minitest::Test
|
|
37
37
|
assert_equal('Hello, world!', chat.translate('Hello, world!'))
|
38
38
|
end
|
39
39
|
|
40
|
+
def test_start_with_link
|
41
|
+
stub_request(:any, 'https://api.openai.com/v1/chat/completions')
|
42
|
+
.to_return(body: '{"choices":[{"message":{"content": "done!"}}]}')
|
43
|
+
chat = GptTranslate::ChatGPT.new('fake-key', 'gpt-3.5-turbo', 'en', 'ru')
|
44
|
+
assert_equal('done!', chat.translate('[OpenAI](https://openai.com) is the creator of ChatGPT', min: 10))
|
45
|
+
end
|
46
|
+
|
40
47
|
def test_dry_mode
|
41
48
|
chat = GptTranslate::ChatGPT.new('', 'foo', 'xx', 'xx')
|
42
49
|
assert_equal(38, chat.translate('This text should not be sent to OpenAI', min: 100).length)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-chatgpt-translate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: iri
|