Grok-Mistral / app.py
Rohan246's picture
Update app.py
b2a467d verified
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain import PromptTemplate, LLMChain
from langchain_groq import ChatGroq
import streamlit as st
import os
def get_response(input_text):
groq_api_key=os.getenv("GROK")
llm=ChatGroq(groq_api_key=groq_api_key,
model_name="mixtral-8x7b-32768")
prompt=ChatPromptTemplate.from_messages(
[
("system","You are a therapist. Be like a friend to them. Ask about their day. Make them feel safe and heard. Dont tell them before hand if and only if specifically they ask you that they want to talk with a therapist then tell them to contact someone from our website. "),
("user","Question:{question}")
]
)
#prompt = PromptTemplate(template=prompt, input_variables=["question"])
#llm_chain = LLMChain(prompt=prompt, llm=llm)
output_parser=StrOutputParser()
chain=prompt|llm|output_parser
response=chain.invoke({"question":input_text})
return response
def main():
st.title("Freud")
input_text=st.text_input("How are you Today?")
if st.button("Say"):
if input_text.strip() !="":
response=get_response(input_text)
st.write(response)
else:
st.warning("Please enter a question.")
if __name__=="__main__":
main()