trix-genius 0.0.14 → 0.1.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/generators/trix_genius/install/install_generator.rb +1 -1
 - data/lib/generators/trix_genius/install/templates/trix_genius.rb +4 -4
 - data/lib/generators/trix_genius/install/templates/trix_genius_controller.rb +5 -4
 - data/spec/generators/trix_genius/install/install_generator_spec.rb +1 -1
 - data/spec/tmp/dummy_app/app/controllers/trix_genius_controller.rb +5 -4
 - data/spec/tmp/dummy_app/app/javascript/controllers/application.js +1 -1
 - data/spec/tmp/dummy_app/config/initializers/trix_genius.rb +4 -4
 - 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: 05ebdc43ab189099199225ca593632dd48606ed04a3a8c517a538672b4262b2e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 384e3465038e32372293c6bc3f2a6d9990e78be80226d135251f1f48649b04b4
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a47ca9c4fa3552d08ff016b1633eccc00d4f5f06b8fb571828e02de7b0aff85ed81e64cac1cdd37d6b1269c9f002e1fcffda80d772980fed4a5e83f03e9b8068
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d781f74a992cfac430634d776fa236ad1a5f9ef10a7417f77cae268afd94a0e9b1ac896b2a64b01fbf1a240e02d3b96fbd9a074db6f74a8b5c169a5ecf6d262c
         
     | 
| 
         @@ -28,7 +28,7 @@ module TrixGenius 
     | 
|
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                    if File.exist?(js_application_controller_path)
         
     | 
| 
       30 
30 
     | 
    
         
             
                      application_controller_file = File.read(js_application_controller_path)
         
     | 
| 
       31 
     | 
    
         
            -
                      inject_into_file js_application_controller_path, "\n" + 'import TrixController from "controllers/ 
     | 
| 
      
 31 
     | 
    
         
            +
                      inject_into_file js_application_controller_path, "\n" + 'import TrixController from "controllers/trix_genius_controller"' + "\n", after: 'import { Application } from "@hotwired/stimulus"'
         
     | 
| 
       32 
32 
     | 
    
         
             
                      inject_into_file js_application_controller_path, "\n" + 'application.register("trix", TrixController)' + ("\n" * 2), before: 'export { application }'
         
     | 
| 
       33 
33 
     | 
    
         
             
                    else
         
     | 
| 
       34 
34 
     | 
    
         
             
                      puts javascript_application_controller_msg
         
     | 
| 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            Rails.application.config.deepseek = {
         
     | 
| 
      
 2 
     | 
    
         
            +
              api_url: ENV['API_URL'],
         
     | 
| 
      
 3 
     | 
    
         
            +
              api_key: ENV['DEEPSEEK_API_KEY']
         
     | 
| 
      
 4 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -1,7 +1,8 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            require 'faraday'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class TrixGeniusController < ApplicationController
         
     | 
| 
       2 
4 
     | 
    
         
             
              skip_before_action :verify_authenticity_token
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              # POST /correct_orthography
         
     | 
| 
       5 
6 
     | 
    
         
             
              def correct_spelling
         
     | 
| 
       6 
7 
     | 
    
         
             
                text = params.require(:text)
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
         @@ -18,7 +19,7 @@ class OrthographyController < ApplicationController 
     | 
|
| 
       18 
19 
     | 
    
         
             
              def call_ai_service(text)
         
     | 
| 
       19 
20 
     | 
    
         
             
                headers = {
         
     | 
| 
       20 
21 
     | 
    
         
             
                  'Content-Type' => 'application/json',
         
     | 
| 
       21 
     | 
    
         
            -
                  'Authorization' => "Bearer #{ 
     | 
| 
      
 22 
     | 
    
         
            +
                  'Authorization' => "Bearer #{Rails.application.config.deepseek[:api_key}"
         
     | 
| 
       22 
23 
     | 
    
         
             
                }
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
25 
     | 
    
         
             
                body = {
         
     | 
| 
         @@ -28,7 +29,7 @@ class OrthographyController < ApplicationController 
     | 
|
| 
       28 
29 
     | 
    
         
             
                  max_tokens: 500
         
     | 
| 
       29 
30 
     | 
    
         
             
                }.to_json
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                response = Faraday.post( 
     | 
| 
      
 32 
     | 
    
         
            +
                response = Faraday.post(Rails.application.config.deepseek[:api_url],, body, headers)
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
       33 
34 
     | 
    
         
             
                if response.success?
         
     | 
| 
       34 
35 
     | 
    
         
             
                  return JSON.parse(response.body)['choices'][0]['message']['content'].split('"')[1]
         
     | 
| 
         @@ -69,7 +69,7 @@ RSpec.describe TrixGenius::Generators::InstallGenerator, type: :generator do 
     | 
|
| 
       69 
69 
     | 
    
         
             
              it "Should updates controller application.js with import line" do
         
     | 
| 
       70 
70 
     | 
    
         
             
                run_generator
         
     | 
| 
       71 
71 
     | 
    
         
             
                assert_file "app/javascript/controllers/application.js" do |content|
         
     | 
| 
       72 
     | 
    
         
            -
                  expect(content).to include('import TrixController from "controllers/ 
     | 
| 
      
 72 
     | 
    
         
            +
                  expect(content).to include('import TrixController from "controllers/trix_genius_controller"')
         
     | 
| 
       73 
73 
     | 
    
         
             
                  expect(content).to include('application.register("trix", TrixController)')
         
     | 
| 
       74 
74 
     | 
    
         
             
                end
         
     | 
| 
       75 
75 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,7 +1,8 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            require 'faraday'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class TrixGeniusController < ApplicationController
         
     | 
| 
       2 
4 
     | 
    
         
             
              skip_before_action :verify_authenticity_token
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              # POST /correct_orthography
         
     | 
| 
       5 
6 
     | 
    
         
             
              def correct_spelling
         
     | 
| 
       6 
7 
     | 
    
         
             
                text = params.require(:text)
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
         @@ -18,7 +19,7 @@ class OrthographyController < ApplicationController 
     | 
|
| 
       18 
19 
     | 
    
         
             
              def call_ai_service(text)
         
     | 
| 
       19 
20 
     | 
    
         
             
                headers = {
         
     | 
| 
       20 
21 
     | 
    
         
             
                  'Content-Type' => 'application/json',
         
     | 
| 
       21 
     | 
    
         
            -
                  'Authorization' => "Bearer #{ 
     | 
| 
      
 22 
     | 
    
         
            +
                  'Authorization' => "Bearer #{Rails.application.config.deepseek[:api_key}"
         
     | 
| 
       22 
23 
     | 
    
         
             
                }
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
25 
     | 
    
         
             
                body = {
         
     | 
| 
         @@ -28,7 +29,7 @@ class OrthographyController < ApplicationController 
     | 
|
| 
       28 
29 
     | 
    
         
             
                  max_tokens: 500
         
     | 
| 
       29 
30 
     | 
    
         
             
                }.to_json
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                response = Faraday.post( 
     | 
| 
      
 32 
     | 
    
         
            +
                response = Faraday.post(Rails.application.config.deepseek[:api_url],, body, headers)
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
       33 
34 
     | 
    
         
             
                if response.success?
         
     | 
| 
       34 
35 
     | 
    
         
             
                  return JSON.parse(response.body)['choices'][0]['message']['content'].split('"')[1]
         
     | 
| 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            Rails.application.config.deepseek = {
         
     | 
| 
      
 2 
     | 
    
         
            +
              api_url: ENV['API_URL'],
         
     | 
| 
      
 3 
     | 
    
         
            +
              api_key: ENV['DEEPSEEK_API_KEY']
         
     | 
| 
      
 4 
     | 
    
         
            +
            }
         
     |