def translate_chunk(chunk, model='gpt-3.5-turbo',
dest_language='English',
sample_translation=("\poglavje{Osnove Geometrije} \label{osn9Geom}", "\poglavje{The basics of Geometry} \label{osn9Geom}")
):
prompt = f'''Translate only the text from the following LaTeX document into {dest_language}. Leave all LaTeX commands unchanged
"""
{sample_translation[0]}
{chunk}"""
{sample_translation[1]}
'''
response = client.chat.completions.create(
messages=[{"role": "user", "content":prompt}],
model=model,
temperature=0,
top_p=1,
max_tokens=1500,
)
result = response.choices[0].message.content.strip()
result = result.replace('"""', '') # remove the double quotes, as we used them to surround the text
return result
print(translate_chunk(chunks[800], model='gpt-3.5-turbo', dest_language='English'))