Skip to content

Commit

Permalink
⚡️Support all
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenSheiBot committed Oct 1, 2024
1 parent 57c7ac7 commit 987b411
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/python-docxloader.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ jobs:
- name: Copy input.docx and config.yaml
run: |
python download.py output/${{ vars.CN_TITLE }} ${{ vars.CN_TITLE }} ${{ secrets.S3_ACCESS_KEY }} ${{ secrets.S3_SECRET_KEY }} ${{ secrets.S3_ENDPOINT }} ${{ secrets.S3_BUCKET_NAME }}
sed -i 's/POE-API-KEY/'"${{ secrets.POE_API_KEY }}"'/g' translation.yaml.example
sed -i 's/GOOGLE-API-KEY/'"${{ secrets.GOOGLE_API_KEY }}"'/g' translation.yaml.example
mv translation.yaml.example translation.yaml
if [ -n "${{ secrets.TRANSLATION_CONFIG }}" ]; then
echo "${{ secrets.TRANSLATION_CONFIG }}" > translation.yaml
else
sed -i 's/POE-API-KEY/'"${{ secrets.POE_API_KEY }}"'/g' translation.yaml.example
sed -i 's/GOOGLE-API-KEY/'"${{ secrets.GOOGLE_API_KEY }}"'/g' translation.yaml.example
mv translation.yaml.example translation.yaml
fi
sed -i 's/CN-TITLE/'"${{ vars.CN_TITLE }}"'/g' .env.example
sed -i 's/JP-TITLE/'"${{ vars.JP_TITLE }}"'/g' .env.example
sed -i 's/PROMPT-EXAMPLE/'"${{ vars.PROMPT }}"'/g' .env.example
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/python-srtloader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ jobs:
- name: Copy input.srt and config.yaml
run: |
python download.py output/${{ vars.CN_TITLE }} ${{ vars.CN_TITLE }} ${{ secrets.S3_ACCESS_KEY }} ${{ secrets.S3_SECRET_KEY }} ${{ secrets.S3_ENDPOINT }} ${{ secrets.S3_BUCKET_NAME }}
sed -i 's/POE-API-KEY/'"${{ secrets.POE_API_KEY }}"'/g' translation.yaml.example
sed -i 's/GOOGLE-API-KEY/'"${{ secrets.GOOGLE_API_KEY }}"'/g' translation.yaml.example
mv translation.yaml.example translation.yaml
if [ -n "${{ secrets.TRANSLATION_CONFIG }}" ]; then
echo "${{ secrets.TRANSLATION_CONFIG }}" > translation.yaml
else
sed -i 's/POE-API-KEY/'"${{ secrets.POE_API_KEY }}"'/g' translation.yaml.example
sed -i 's/GOOGLE-API-KEY/'"${{ secrets.GOOGLE_API_KEY }}"'/g' translation.yaml.example
mv translation.yaml.example translation.yaml
fi
sed -i 's/CN-TITLE/'"${{ vars.CN_TITLE }}"'/g' .env.example
sed -i 's/JP-TITLE/'"${{ vars.JP_TITLE }}"'/g' .env.example
sed -i 's/PROMPT-EXAMPLE/'"${{ vars.PROMPT }}"'/g' .env.example
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/python-txtloader.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ jobs:
- name: Copy input.txt and config.yaml
run: |
python download.py output/${{ vars.CN_TITLE }} ${{ vars.CN_TITLE }} ${{ secrets.S3_ACCESS_KEY }} ${{ secrets.S3_SECRET_KEY }} ${{ secrets.S3_ENDPOINT }} ${{ secrets.S3_BUCKET_NAME }}
sed -i 's/POE-API-KEY/'"${{ secrets.POE_API_KEY }}"'/g' translation.yaml.example
sed -i 's/GOOGLE-API-KEY/'"${{ secrets.GOOGLE_API_KEY }}"'/g' translation.yaml.example
mv translation.yaml.example translation.yaml
if [ -n "${{ secrets.TRANSLATION_CONFIG }}" ]; then
echo "${{ secrets.TRANSLATION_CONFIG }}" > translation.yaml
else
sed -i 's/POE-API-KEY/'"${{ secrets.POE_API_KEY }}"'/g' translation.yaml.example
sed -i 's/GOOGLE-API-KEY/'"${{ secrets.GOOGLE_API_KEY }}"'/g' translation.yaml.example
mv translation.yaml.example translation.yaml
fi
sed -i 's/CN-TITLE/'"${{ vars.CN_TITLE }}"'/g' .env.example
sed -i 's/JP-TITLE/'"${{ vars.JP_TITLE }}"'/g' .env.example
sed -i 's/PROMPT-EXAMPLE/'"${{ vars.PROMPT }}"'/g' .env.example
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Github actions can be used to automate the translation process if your book is s
5. Add the following secrets:
- `GOOGLE_API_KEY`: Your [Gemini API keys](https://aistudio.google.com/app/u/0/apikey?pli=1).
- `POE_API_KEY`: (Optional) Your [Poe API keys](https://poe.com/api_key).
- `TRANSLATION_CONFIG`: (Optional) For more advanced configuration, you can provide a JSON config similar to the example `translation.yaml.example` file to use models other than gemini-1.5-flash.
- `TRANSLATION_CONFIG`: (Optional) For more advanced configuration, you can provide a JSON config similar to the example `translation.yaml.example` file to use models other than `gemini-1.5-flash`*.
- `S3_ACCESS_KEY`: Your S3 access key.
- `S3_SECRET_KEY`: Your S3 secret key.
- `S3_ENDPOINT`: Your S3 bucket endpoint.
Expand All @@ -33,6 +33,7 @@ Github actions can be used to automate the translation process if your book is s
9. Go to the `Actions` tab and manually trigger the workflow.
10. The translated book will be available in both Chinese and bilingual formats in your S3 bucket.

* The `TRANSLATION_CONFIG` supports all google models (make sure your config entry name contains "Gemini"), all poe models (make sure your config entry name contains "Poe"), and all other models supported by [LiteLLM](https://docs.litellm.ai/docs/providers). Note that the `gemini-1.5-flash` **does not** need to be prefixed as `gemini/gemini-1.5-flash` as in LiteLLM, unless you don't include "Gemini" in the name.


## Running Locally
Expand Down
4 changes: 3 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ PDF格式暂不支持,推荐由Adobe Acrobat或类似工具转换成EPUB或DOC
5. 添加下述Repository secrets:
- `GOOGLE_API_KEY`: 你的 [Gemini API keys](https://aistudio.google.com/app/u/0/apikey?pli=1).
- `POE_API_KEY`: (可选) 你的 [Poe API keys](https://poe.com/api_key).
- `TRANSLATION_CONFIG`: (可选) 为了更高级的配置,你可以提供一个类似于示例 `translation.yaml.example` 文件的 JSON 配置,以使用除 gemini-1.5-flash 之外的模型。
- `TRANSLATION_CONFIG`: (可选) 为了更高级的配置,你可以提供一个类似于示例 `translation.yaml.example` 文件的 JSON 配置,以使用除 gemini-1.5-flash 之外的模型。*
- `S3_ACCESS_KEY`: 你的 S3 access key.
- `S3_SECRET_KEY`: 你的 S3 secret key.
- `S3_ENDPOINT`: 你的 S3 bucket endpoint.
Expand All @@ -31,6 +31,8 @@ PDF格式暂不支持,推荐由Adobe Acrobat或类似工具转换成EPUB或DOC
9. 转到 `Action` 选项卡,手动触发工作流程。
10. 翻译后的书籍将以中文和双语两种格式出现在您的 S3 文件桶中。

* `TRANSLATION_CONFIG` 支持所有谷歌模型(确保您的配置条目名称包含“Gemini”)、所有 Poe 模型(确保您的配置条目名称包含“Poe”)以及所有其他由 [LiteLLM](https://docs.litellm.ai/docs/providers) 支持的模型。请注意,`gemini-1.5-flash` **不需要** 像 LiteLLM 中那样加前缀为 `gemini/gemini-1.5-flash`,除非配置条目名不包含“Gemini”。



## 本地运行
Expand Down

0 comments on commit 987b411

Please sign in to comment.