Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an option to create a draft translation with GPT #133

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
48 changes: 46 additions & 2 deletions docassemble/ALDashboard/data/questions/generate_translation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,45 @@ metadata:
title: |
Translation support tool
---
mandatory: True
code: |
the_yaml_path
if not the_task.ready():
waiting_screen
show_translation_results
---
# code: |
# translations = [
# translation_file(the_yaml_path, tr_lang, use_gpt=use_gpt)
# for tr_lang
# in tr_langs.split()
# ]
---
code: |
the_task = background_action('translate_file')
---
event: waiting_screen
question: |
Please wait while we translate your file
subquestion: |
<div class="spinner-border" role="status">
<span class="visually-hidden">Processing...</span>
</div>
reload: True
---
event: translate_file
code: |
translations = [
translation_file(the_yaml_path, tr_lang)
translation_file(the_yaml_path, tr_lang, use_gpt=use_gpt, openai_api=get_config("openai api key", get_config("open ai", {}).get("key")))
for tr_lang
in tr_langs.split()
]
background_response_action('save_translations', translations=translations)
---
event: save_translations
code: |
translations = action_argument('translations')
background_response()
---
question: |
What file do you want to translate?
Expand All @@ -28,8 +61,19 @@ fields:
]
- "Language codes (like: es, one per line)": tr_langs
datatype: area
- Include a draft translation with GPT or Google Translate: use_gpt
datatype: yesno
show if:
code: |
gpt_is_available() # or google_translate_is_available()
- note: |
To use OpenAI's GPT-3, you need to set up an OpenAI account and get an API key.
show if:
code: |
not gpt_is_available()

---
mandatory: True
event: show_translation_results
question: |
Translation results
subquestion: |
Expand Down
6 changes: 3 additions & 3 deletions docassemble/ALDashboard/package_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ def fetch_github_repo_version(repo_list, key_pkgs, github_user) -> dict:
version_num = decoded_line[str_start:str_end][9:].replace(
"',\n", ""
)
v[
"version"
] = version_num # Add version number to the original repo_list.
v["version"] = (
version_num # Add version number to the original repo_list.
)
has_version_num = True
break

Expand Down
Loading
Loading