Spaces:
Runtime error
Runtime error
File size: 1,355 Bytes
1ff47d6 b3ae2ea 1ff47d6 2bb5fa0 1ff47d6 b2a467d 1ff47d6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
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() |