translation_api 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd0bf92d0abd7ee5ece885abaf35110441d86e35c5b7c56126928781aafe4ca3
4
- data.tar.gz: 394ffe1c9ad32ca3e7806e1ae6e14236fe17b3dcb021dc628141b6851590ebe4
3
+ metadata.gz: fef1087b2a2ddc29d3a942318b98fee14c24d941250665e69e7a875eba931b56
4
+ data.tar.gz: 4104acc87346c85fc82f0dd6da55475ad308535f63b8ec0f09db6afa73e341bb
5
5
  SHA512:
6
- metadata.gz: eaa97abc650985f580c6de3cdbf8eb872cca14e78d7625875b004c1b7e6ca4a2b9090444086c93c353eea0ec4b2ba695eef4e7b22e0c6ac1fae6c7cbbb5af5c9
7
- data.tar.gz: 79e67af130d3d290e01c89392e1abe094b5eab77ca0a71f845d1f2c6590a5b78a70c1873fa246ea6a1b41aaa59a76390b992c4396bf681006c3a011a6872007b
6
+ metadata.gz: 8bf6cac81b1c2e6153194bcd7ec173f3333a19972c07f66a425121c5c2276fa982c10f0ce6e3d81ff7c31457b63e657a0e6046f2e566a08705e38108bc739278
7
+ data.tar.gz: '06609efa3d55a13d4cd8eb54a6ea6580cfa94382bb6cc81c272fad94ee78ce029fb18bb7d9317324b575e7b611d8ea2b1d4f3c1845bcf74d027e2c95101fcb42'
data/CHANGELOG.md CHANGED
@@ -52,3 +52,7 @@
52
52
  ## [1.2.0] - 2025-11-23
53
53
 
54
54
  - Gemini対応
55
+
56
+ ## [1.3.0] - 2026-04-11
57
+
58
+ - OpenAIのモデルを更新
data/Rakefile CHANGED
@@ -1,39 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
- require "rubocop/rake_task"
6
- require "yard"
7
- require_relative "rake_helper"
8
-
9
- desc "analysis"
10
- task :analysis do
11
- sh "bundle install"
12
-
13
- RakeHelper.init_rake_tasks
14
-
15
- puts "--- rspec ---"
16
- Rake::Task[:spec].invoke
17
-
18
- puts "--- rubocop ---"
19
- Rake::Task[:rubocop].invoke
20
-
21
- puts "--- yard ---"
22
- Rake::Task[:yard].invoke
23
- end
24
-
25
- desc "push to github packages and rubygems"
26
- task :push do
27
- sh "bundle install"
28
-
29
- puts "--- build ---"
30
- RakeHelper.build_gem
31
-
32
- puts "--- push to github packages ---"
33
- RakeHelper.push_to_github_packages
34
-
35
- puts "--- push to rubygems ---"
36
- RakeHelper.push_to_rubygems
37
- end
38
-
39
- task default: :analysis
3
+ require "push_gem"
data/how_to_publish.txt CHANGED
@@ -2,9 +2,9 @@ some code change
2
2
  version.rb change
3
3
  changelog.md change
4
4
 
5
- $rake analysis
5
+ $rake gem:check
6
6
 
7
7
  $git commit
8
8
  $git push
9
9
 
10
- $rake push
10
+ $rake gem:push
@@ -24,19 +24,17 @@ class TranslationAPI
24
24
  private
25
25
 
26
26
  def request(text)
27
- @client.chat(
28
- parameters: {
29
- model: @model.name,
30
- messages: [
31
- { role: "system", content: @prompt.system_prompt },
32
- { role: "user", content: @prompt.user_prompt + text }
33
- ]
34
- }
27
+ @client.chat.completions.create(
28
+ model: @model.name,
29
+ messages: [
30
+ { role: "system", content: @prompt.system_prompt },
31
+ { role: "user", content: @prompt.user_prompt + text }
32
+ ]
35
33
  )
36
34
  end
37
35
 
38
36
  def init_client
39
- ::OpenAI::Client.new(access_token: ENV["OPENAI_API_KEY"])
37
+ ::OpenAI::Client.new(api_key: ENV["OPENAI_API_KEY"])
40
38
  end
41
39
 
42
40
  def validate_api_key!
@@ -5,7 +5,6 @@ class TranslationAPI
5
5
  class OpenAI
6
6
  class Cost
7
7
  ONE_MILLION = 1_000_000
8
- BASE_MODEL_COST = 1.25 / ONE_MILLION
9
8
 
10
9
  def initialize(model)
11
10
  @model = model
@@ -32,8 +31,8 @@ class TranslationAPI
32
31
  def base
33
32
  {
34
33
  @model.class.base => {
35
- input: BASE_MODEL_COST,
36
- output: BASE_MODEL_COST * normal_io_ratio[:output]
34
+ input: 2.50 / ONE_MILLION,
35
+ output: 15.00 / ONE_MILLION
37
36
  }
38
37
  }
39
38
  end
@@ -41,33 +40,20 @@ class TranslationAPI
41
40
  def mini
42
41
  {
43
42
  @model.class.mini => {
44
- input: BASE_MODEL_COST / normal_cost_diff_ratio,
45
- output: (BASE_MODEL_COST * normal_io_ratio[:output]) / normal_cost_diff_ratio
43
+ input: 0.75 / ONE_MILLION,
44
+ output: 4.50 / ONE_MILLION
46
45
  }
47
46
  }
48
47
  end
49
48
 
50
49
  def nano
51
- mini_cost = mini.values[0][:input]
52
-
53
50
  {
54
51
  @model.class.nano => {
55
- input: mini_cost / normal_cost_diff_ratio,
56
- output: (mini_cost * normal_io_ratio[:output]) / normal_cost_diff_ratio
52
+ input: 0.20 / ONE_MILLION,
53
+ output: 1.25 / ONE_MILLION
57
54
  }
58
55
  }
59
56
  end
60
-
61
- def normal_io_ratio
62
- {
63
- input: 1.0,
64
- output: 8.0
65
- }
66
- end
67
-
68
- def normal_cost_diff_ratio
69
- 5.0
70
- end
71
57
  end
72
58
  end
73
59
  end
@@ -7,9 +7,9 @@ class TranslationAPI
7
7
  class OpenAI
8
8
  class Model < Llm::Model
9
9
  SUPPORTED_MODELS = [
10
- "gpt-5",
11
- "gpt-5-mini",
12
- "gpt-5-nano"
10
+ "gpt-5.4",
11
+ "gpt-5.4-mini",
12
+ "gpt-5.4-nano"
13
13
  ].freeze
14
14
 
15
15
  def self.base
@@ -9,15 +9,15 @@ class TranslationAPI
9
9
  end
10
10
 
11
11
  def translated_text
12
- @response.dig("choices", 0, "message", "content")
12
+ @response.choices[0].message.content
13
13
  end
14
14
 
15
15
  def dig_used_tokens(type:)
16
16
  case type
17
17
  when :input
18
- @response.dig("usage", "prompt_tokens")
18
+ @response.usage.prompt_tokens
19
19
  when :output
20
- @response.dig("usage", "completion_tokens")
20
+ @response.usage.completion_tokens
21
21
  else
22
22
  raise ArgumentError, "Invalid token type: #{type}"
23
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TranslationAPI
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translation_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - milkeclair
@@ -52,7 +52,7 @@ dependencies:
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  - !ruby/object:Gem::Dependency
55
- name: ruby-openai
55
+ name: openai
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - ">="
@@ -97,7 +97,6 @@ files:
97
97
  - lib/translation_api/provider/openai/model.rb
98
98
  - lib/translation_api/provider/openai/response.rb
99
99
  - lib/translation_api/version.rb
100
- - rake_helper.rb
101
100
  homepage: https://github.com/milkeclair/translation_api
102
101
  licenses:
103
102
  - MIT
data/rake_helper.rb DELETED
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class RakeHelper
4
- GITHUB_PACKAGES_PUSH_COMMAND =
5
- "gem push --key github --host https://rubygems.pkg.github.com/milkeclair " \
6
- "pkg/translation_api-#{TranslationAPI::VERSION}.gem".freeze
7
-
8
- RUBYGEMS_PUSH_COMMAND =
9
- "gem push --host https://rubygems.org " \
10
- "pkg/translation_api-#{TranslationAPI::VERSION}.gem".freeze
11
-
12
- def self.init_rake_tasks
13
- RSpec::Core::RakeTask.new(:spec) { |task| task.verbose = false }
14
- RuboCop::RakeTask.new
15
- YARD::Rake::YardocTask.new
16
- end
17
-
18
- def self.build_gem
19
- abort("gemのビルドに失敗しました") unless system("rake build")
20
- end
21
-
22
- def self.push_to_github_packages
23
- abort("githubへのgemのpushに失敗しました") unless system(GITHUB_PACKAGES_PUSH_COMMAND)
24
- end
25
-
26
- def self.push_to_rubygems
27
- abort("rubygemsへのgemのpushに失敗しました") unless system(RUBYGEMS_PUSH_COMMAND)
28
- end
29
- end