File size: 579 Bytes
dd892c5
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from langchain_core.prompts import ChatPromptTemplate
from langchain_groq import ChatGroq

def get_quote(topic):
  chat = ChatGroq(temperature=0.9, model_name="mixtral-8x7b-32768")
  system = "You are a helpful assistant who generate the motivational quotes based on the user topic provided.\
  The output quote should be one liner and catchy. "
  human = "Generate a motivational quote on {topic}"
  prompt = ChatPromptTemplate.from_messages([("system", system), ("human", human)])

  chain = prompt | chat

  response = chain.invoke({"topic": topic})
  return response.content