mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-01 00:50:12 +00:00
feat: add github action to check spelling (#326)
This commit is contained in:
parent
c2498286f0
commit
b4817f2c9b
10
.github/workflows/make_test_ebook.yaml
vendored
10
.github/workflows/make_test_ebook.yaml
vendored
@ -13,6 +13,16 @@ env:
|
||||
BBM_CAIYUN_API_KEY: ${{ secrets.BBM_CAIYUN_API_KEY }}
|
||||
|
||||
jobs:
|
||||
typos-check:
|
||||
name: Spell Check with Typos
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Actions Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Check spelling with custom config file
|
||||
uses: crate-ci/typos@v1.16.6
|
||||
with:
|
||||
config: ./typos.toml
|
||||
testing:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -35,7 +35,7 @@ Find more info here for using liteLLM: https://github.com/BerriAI/litellm/blob/m
|
||||
- Use `--proxy` option to specify proxy server for internet access. Enter a string such as `http://127.0.0.1:7890`.
|
||||
- Use `--resume` option to manually resume the process after an interruption.
|
||||
- epub is made of html files. By default, we only translate contents in `<p>`.
|
||||
Use `--translate-tags` to specify tags need for translation. Use comma to seperate multiple tags. For example:
|
||||
Use `--translate-tags` to specify tags need for translation. Use comma to separate multiple tags. For example:
|
||||
`--translate-tags h1,h2,h3,p,div`
|
||||
- Use `--book_from` option to specify e-reader type (Now only `kobo` is available), and use `--device_path` to specify the mounting point.
|
||||
- If you want to change api_base like using Cloudflare Workers, use `--api_base <URL>` to support it.
|
||||
|
@ -274,7 +274,7 @@ So you are close to reaching the limit. You have to choose your own value, there
|
||||
options.openai_key
|
||||
or env.get(
|
||||
"OPENAI_API_KEY",
|
||||
) # XXX: for backward compatability, deprecate soon
|
||||
) # XXX: for backward compatibility, deprecate soon
|
||||
or env.get(
|
||||
"BBM_OPENAI_API_KEY",
|
||||
) # suggest adding `BBM_` prefix for all the bilingual_book_maker ENVs.
|
||||
@ -287,15 +287,15 @@ So you are close to reaching the limit. You have to choose your own value, there
|
||||
elif options.model == "caiyun":
|
||||
API_KEY = options.caiyun_key or env.get("BBM_CAIYUN_API_KEY")
|
||||
if not API_KEY:
|
||||
raise Exception("Please provid caiyun key")
|
||||
raise Exception("Please provide caiyun key")
|
||||
elif options.model == "deepl":
|
||||
API_KEY = options.deepl_key or env.get("BBM_DEEPL_API_KEY")
|
||||
if not API_KEY:
|
||||
raise Exception("Please provid deepl key")
|
||||
raise Exception("Please provide deepl key")
|
||||
elif options.model == "claude":
|
||||
API_KEY = options.claude_key or env.get("BBM_CLAUDE_API_KEY")
|
||||
if not API_KEY:
|
||||
raise Exception("Please provid claude key")
|
||||
raise Exception("Please provide claude key")
|
||||
else:
|
||||
API_KEY = ""
|
||||
|
||||
|
@ -41,7 +41,7 @@ class ChatGPTAPI(Base):
|
||||
prompt_sys_msg
|
||||
or environ.get(
|
||||
"OPENAI_API_SYS_MSG",
|
||||
) # XXX: for backward compatability, deprecate soon
|
||||
) # XXX: for backward compatibility, deprecate soon
|
||||
or environ.get(PROMPT_ENV_MAP["system"])
|
||||
or ""
|
||||
)
|
||||
|
@ -44,7 +44,7 @@ class GPT4(Base):
|
||||
prompt_sys_msg
|
||||
or environ.get(
|
||||
"OPENAI_API_SYS_MSG",
|
||||
) # XXX: for backward compatability, deprecate soon
|
||||
) # XXX: for backward compatibility, deprecate soon
|
||||
or environ.get(PROMPT_ENV_MAP["system"])
|
||||
or ""
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ Txt files and srt files are plain text files. This program can translate plain t
|
||||
python3 make_book.py --book_name test_books/the_little_prince.txt --test --language zh-hans
|
||||
|
||||
## epub
|
||||
epub is made of html files. By default, we only translate contents in `<p>`. Use `--translate-tags` to specify tags need for translation. Use comma to seperate multiple tags. For example: `--translate-tags h1,h2,h3,p,div`
|
||||
epub is made of html files. By default, we only translate contents in `<p>`. Use `--translate-tags` to specify tags need for translation. Use comma to separate multiple tags. For example: `--translate-tags h1,h2,h3,p,div`
|
||||
|
||||
bbook_maker --book_name test_books/animal_farm.epub --openai_key ${openai_key} --translate-tags div,p
|
||||
|
||||
@ -17,4 +17,4 @@ If you want to translate strings in an e-book that aren't labeled with any tags,
|
||||
Use `--book_from` option to specify e-reader type (Now only `kobo` is available), and use `--device_path` to specify the mounting point.
|
||||
|
||||
# Translate books download from Rakuten Kobo on kobo e-reader
|
||||
bbook_maker --book_from kobo --device_path /tmp/kobo
|
||||
bbook_maker --book_from kobo --device_path /tmp/kobo
|
||||
|
@ -1,4 +1,5 @@
|
||||
# Tweek the prompt
|
||||
# Tweak the prompt
|
||||
|
||||
To tweak the prompt, use the `--prompt` parameter. Valid placeholders for the `user` role template include `{text}` and `{language}`. It supports a few ways to configure the prompt:
|
||||
|
||||
- If you don't need to set the `system` role content, you can simply set it up like this: `--prompt "Translate {text} to {language}."` or `--prompt prompt_template_sample.txt`
|
||||
@ -25,4 +26,4 @@ python3 make_book.py --book_name test_books/animal_farm.epub --prompt prompt_tem
|
||||
python3 make_book.py --book_name test_books/animal_farm.epub --prompt prompt_template_sample.json
|
||||
# or
|
||||
python3 make_book.py --book_name test_books/animal_farm.epub --prompt "Please translate \`{text}\` to {language}"
|
||||
```
|
||||
```
|
||||
|
@ -16,6 +16,6 @@ nav:
|
||||
- Command line options: cmd.md
|
||||
- Translate from different source: book_source.md
|
||||
- Environment setting: env_settings.md
|
||||
- Tweek the prompt: prompt.md
|
||||
- Tweak the prompt: prompt.md
|
||||
- Disclaimer: disclaimer.md
|
||||
|
@ -128,7 +128,7 @@ def test_google_translate_txt_batch_size(test_book_dir, tmpdir):
|
||||
reason="No BBM_CAIYUN_API_KEY in environment variable.",
|
||||
)
|
||||
def test_caiyun_translate_txt(test_book_dir, tmpdir):
|
||||
"""Test caiyun tranlate txt"""
|
||||
"""Test caiyun translate txt"""
|
||||
shutil.copyfile(
|
||||
os.path.join(test_book_dir, "the_little_prince.txt"),
|
||||
os.path.join(tmpdir, "the_little_prince.txt"),
|
||||
|
8
typos.toml
Normal file
8
typos.toml
Normal file
@ -0,0 +1,8 @@
|
||||
# See https://github.com/crate-ci/typos/blob/master/docs/reference.md to configure typos
|
||||
[default.extend-words]
|
||||
sur = "sur"
|
||||
banch = "banch" # TODO: not sure if this is a typo or not
|
||||
fo = "fo"
|
||||
ba = "ba"
|
||||
[files]
|
||||
extend-exclude = ["LICENSE"]
|
Loading…
x
Reference in New Issue
Block a user