Skip to content

kevinluo201/rails-guide-ai

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generative AI Rails Guide translator

This is a fork of https://github.com/rails/rails but it is only for updating the lastest files under guides/ and will never be merged back.

What's this?

This is an experimental project that tries using generative AI to translate the Rails guide. The current results are:

Code

It only has 2 new files.

  • guides/rails_guides/ai_translator.rb: it's the main program.
  • guides/ai_translate.rb: it's the starting point

You can do the following steps if you want to play around with it.

  1. Set a new environment variable call OPENAI_ACCESS_TOKEN and set its value to your personal access token on OpenAI.
  2. add a new language in RailsGuide::AiTranslator, for example, 'jp' => 'Japanese'
  3. Open the terminal, go to guides/ and start translating by executing
ruby ./ai_translate.rb jp
  1. You can also translate a single file, just add a filename after the command
ruby ./ai_translate.rb jp getting_started.md
  1. After all files are translated, you can just execute the rails existing script to generate HTML, CSS and JS. Unfortunately, it is likely to fail when you do that. Usually, it is because there are duplicated titles which lead to duplicated id in the HTML. You can fix it by finding out which title has the problem and can change that title a bit to avoid the problem. It can also have different problems when translating into different languages. Just try solving them so the process can finish.
bundle exec rake guides:generate:html GUIDES_LANGUAGE=jp

Help Wanted

It is just an experimental project now. There are several issues that can be improved. If you think it is an interesting topic, feel free to discuss it with me.

Current Issues

Anchor links

The table of content is solved by disabling Turbo. However, there are anchor links spread among the articles. They cannot be converted to the correct URL smoothly, especially when it refers to an anchor on another page.

Versioning

The Rails Guide has versions. A version is kind of a snapshot of the guide at a particular time. I haven't thought of a good way to manage them.

Different models

I'm now using gpt-3.5-turbo. I live in Canada so I cannot use Google's Bard. Feel free to change the code to be able to switch different models, like gpt4 or llamas 2

EPUB

Epub files can be generated by the Rails guide script. However, it has errors when I want to import them into the Epub reader software, such as "Books" on OSX. I think it may related to the broken anchor links.

Other stuff

If you have any ideas that can make this project more sustainable, please discuss it with me. For example, it's a guide for Rails, why not build it as a Rails app?

Packages

No packages published

Languages

  • Ruby 93.4%
  • JavaScript 4.9%
  • HTML 1.3%
  • CSS 0.4%
  • Shell 0.0%
  • Dockerfile 0.0%