Windows command prompt display Good Morning in my native language using OpenAI

Great things to see first time using OpenAI - I can see Good Morning message in my native Bengali language in Windows Command prompt!



Below the artifacts you need to install before run the code

pip install langchain

pip install langchain-openai

pip install langgraph


And, you need a key from https://smith.langchain.com


Finally, the code goes below...

import getpass
import os

from langchain_openai import ChatOpenAI
from langchain.schema import HumanMessage

from langchain_core.prompts import ChatPromptTemplate

if not os.environ.get("OPENAI_API_KEY"):
  os.environ["OPENAI_API_KEY"] = getpass.getpass("YOUR OPENAPI KEY GOES HERE")

chat = ChatOpenAI(model="gpt-4o-mini", temperature=0.7)

system_template = "Translate the following from English into {language}"

prompt_template = ChatPromptTemplate.from_messages(
    [("system", system_template), ("user", "{text}")]
)

#You can change language whatever you want
prompt = prompt_template.invoke({"language": "Bengali", "text": "Good morning!"})

response = chat.invoke(prompt)
print(response.content)

Comments

Popular posts from this blog

SharePoint Framework Reference Guide

SharePoint Admin Center

How to fix Azure DevOps error MSB4126