Spaces:
Runtime error
Runtime error
Create utils.py
Browse files
utils.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain_core.prompts import ChatPromptTemplate
|
| 2 |
+
from langchain_groq import ChatGroq
|
| 3 |
+
|
| 4 |
+
def get_quote(topic):
|
| 5 |
+
chat = ChatGroq(temperature=0.9, model_name="mixtral-8x7b-32768")
|
| 6 |
+
system = "You are a helpful assistant who generate the motivational quotes based on the user topic provided.\
|
| 7 |
+
The output quote should be one liner and catchy. "
|
| 8 |
+
human = "Generate a motivational quote on {topic}"
|
| 9 |
+
prompt = ChatPromptTemplate.from_messages([("system", system), ("human", human)])
|
| 10 |
+
|
| 11 |
+
chain = prompt | chat
|
| 12 |
+
|
| 13 |
+
response = chain.invoke({"topic": topic})
|
| 14 |
+
return response.content
|