MADE Logo

MAKE | DEPLOY | REPEAT

MAKE AI Agents with Python.

Empowering innovation with advanced machine learning solutions, designed for seamless development and unmatched performance.
from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage, SystemMessage
from langchain_core.prompts import ChatPromptTemplate

def main(request):
    """Translate text from one language to another."""

    text = request.payload["text"]
    source = request.payload["source"]
    target = request.payload["target"]

    model = ChatOpenAI(model="gpt-4o-mini")
    messages = [
        SystemMessage(f"Translate from {source} to {target}"),
        HumanMessage(text),
    ]
    response = model.invoke(messages)
    return response.content