Skip to content

Commit

Permalink
tutorial103
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Jul 11, 2024
1 parent bec62fe commit 887d2c9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tutorial103/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from langchain_openai import ChatOpenAI
from langchain.prompts import PromptTemplate

llm=ChatOpenAI(model="gpt-4o")

def generateArticle(topic):
template="""
you are an expert article writer who can write any article on given {topic}, dont ask followup question
whatever is given use that and use your intelligence to write the article
"""
prompt=PromptTemplate.from_template(template)
chain=prompt|llm
response=chain.invoke({"topic":topic})
return response.content

def translateArticle(content,language):
template="""
you are an expert translator who can tanslate anything into any given language.
here you have to translate {content} into {language}.
"""
prompt=PromptTemplate.from_template(template)
chain=prompt|llm
response=chain.invoke({"content":content,"language":language})
print(response.content)


translateArticle(generateArticle("semiconductor usage"),"german")
Binary file added tutorial103/tutorial103.pptx
Binary file not shown.

0 comments on commit 887d2c9

Please sign in to comment.