File size: 393 Bytes
3ac4f4b
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
from langchain_openai import ChatOpenAI

from langchain_core.prompts import ChatPromptTemplate

os.environ["OPENAI_API_KEY"] = os.getenv("k1")

prompt = ChatPromptTemplate.from_messages([("system","you are a good assistant for translation to {il} to {ol}"),
            ("human","{i}")])

chain = prompt|llm

re = chain.invoke({"il":"english","ol":"french","i":"what is the captal of india"})