Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/andrewyng/translation-agent
/ functions
Functions
41 in github.com/andrewyng/translation-agent
⨍
Functions
41
◇
Types & classes
0
↳
Endpoints
1
↓ 9 callers
Function
num_tokens_in_string
Calculate the number of tokens in a given string using a specified encoding. Args: str (str): The input string to be tokenized.
src/translation_agent/utils.py:263
↓ 8 callers
Function
get_completion
Generate a completion using the OpenAI API. Args: prompt (str): The user's prompt or query. system_message (str, optiona
src/translation_agent/utils.py:20
↓ 4 callers
Function
one_chunk_improve_translation
Use the reflection to improve the translation, treating the entire text as one chunk. Args: source_lang (str): The source language o
src/translation_agent/utils.py:175
↓ 4 callers
Function
one_chunk_initial_translation
Translate the entire text as one chunk using an LLM. Args: source_lang (str): The source language of the text. target_lang (
src/translation_agent/utils.py:72
↓ 4 callers
Function
one_chunk_reflect_on_translation
Use an LLM to reflect on the translation, treating the entire text as one chunk. Args: source_lang (str): The source language of the
src/translation_agent/utils.py:100
↓ 3 callers
Function
calculate_chunk_size
Calculate the chunk size based on the token count and token limit. Args: token_count (int): The total number of tokens. toke
src/translation_agent/utils.py:594
↓ 3 callers
Function
model_load
( endpoint: str, base_url: str, model: str, api_key: Optional[str] = None, temperatur
app/patch.py:21
↓ 3 callers
Function
multichunk_improve_translation
Improves the translation of a text from source language to target language by considering expert suggestions. Args: source_lang (str
src/translation_agent/utils.py:468
↓ 3 callers
Function
multichunk_initial_translation
Translate a text in multiple chunks from the source language to the target language. Args: source_lang (str): The source language of
src/translation_agent/utils.py:288
↓ 3 callers
Function
multichunk_reflect_on_translation
Provides constructive criticism and suggestions for improving a partial translation. Args: source_lang (str): The source language of
src/translation_agent/utils.py:347
↓ 2 callers
Function
one_chunk_translate_text
Translate a single chunk of text from the source language to the target language. This function performs a two-step translation process:
src/translation_agent/utils.py:231
↓ 2 callers
Function
tokenize
(text)
app/process.py:48
↓ 1 callers
Function
diff_texts
(text1, text2)
app/process.py:66
↓ 1 callers
Function
extract_docx
(path)
app/process.py:39
↓ 1 callers
Function
extract_pdf
(path)
app/process.py:31
↓ 1 callers
Function
extract_text
(path)
app/process.py:25
↓ 1 callers
Function
multichunk_translation
Improves the translation of multiple text chunks based on the initial translation and reflection. Args: source_lang (str): The sourc
src/translation_agent/utils.py:554
↓ 1 callers
Function
translator
Translate the source_text from source_lang to target_lang.
app/process.py:90
↓ 1 callers
Function
translator_sec
Translate the source_text from source_lang to target_lang.
app/process.py:171
Function
close_btn_hide
(output_diff)
app/app.py:157
Function
close_btn_show
()
app/app.py:153
Function
decorator
(func)
app/patch.py:63
Function
enable_sec
(choice)
app/app.py:113
Function
example_data
()
tests/test_agent.py:153
Function
export_txt
(strings)
app/app.py:124
Function
get_completion
Generate a completion using the OpenAI API. Args: prompt (str): The user's prompt or query. system_message (str, op
app/patch.py:88
Function
huanik
( endpoint: str, base: str, model: str, api_key: str, choice: str, endpoint2: st
app/app.py:17
Function
rate_limit
(get_max_per_minute)
app/patch.py:62
Function
read_doc
(path)
app/app.py:98
Function
switch
(source_lang, source_text, target_lang, output_final)
app/app.py:136
Function
test_get_completion_json_mode_api_call
()
tests/test_agent.py:23
Function
test_get_completion_non_json_mode_api_call
()
tests/test_agent.py:43
Function
test_num_tokens_in_string
()
tests/test_agent.py:262
Function
test_one_chunk_improve_translation
(mock_get_completion, example_data)
tests/test_agent.py:164
Function
test_one_chunk_initial_translation
()
tests/test_agent.py:63
Function
test_one_chunk_reflect_on_translation
()
tests/test_agent.py:97
Function
test_one_chunk_translate_text
(mocker)
tests/test_agent.py:218
Function
translate
Translate the source_text from source_lang to target_lang.
src/translation_agent/utils.py:635
Function
update_menu
(visible)
app/app.py:120
Function
update_model
(endpoint)
app/app.py:83
Function
wrapper
(*args, **kwargs)
app/patch.py:68