import openai def translate(text, target_lang): """Translate text to target language using OpenAI's GPT-3 API.""" client = openai.Client() response = client.chat.completions.create( messages=[{"role": "system", "content": f"You are AI-translator and you should translate text to {target_lang}"}, {'role': 'user', 'content': f'Please translate this text to {target_lang}: {text}. ' f'Answer with tranlsatrion and no additional information.'}, ], model="gpt-3.5-turbo", ) return response.choices[0].message.content