customer_support_agent2 / translator.py
Shrouk04's picture
Upload 35 files
acf2c2f verified
Raw
History Blame Contribute Delete
610 Bytes
import ollama
from config import MODEL_NAME, TEMPERATURE
client = ollama.Client()
def translate_ar_to_en(text):
"""
Translate Arabic text to English using Ollama.
"""
prompt = f"""
Translate the following Arabic text to English.
Return ONLY the translation.
Arabic text:
{text}
"""
response = client.generate(
model=MODEL_NAME,
prompt=prompt,
options={"temperature": 0} # deterministic translation
)
# Ollama returns the response text
return response["response"].strip() if isinstance(response, dict) else str(response)