Rohan246 commited on
Commit
1ff47d6
·
verified ·
1 Parent(s): eb1ce13

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_community.embeddings import HuggingFaceBgeEmbeddings
2
+ from langchain_community.llms import HuggingFaceEndpoint
3
+ from langchain_core.prompts import ChatPromptTemplate
4
+ from langchain_community.llms import HuggingFaceHub
5
+ from langchain_core.output_parsers import StrOutputParser
6
+ from langchain import PromptTemplate, LLMChain
7
+ from langchain_groq import ChatGroq
8
+ import streamlit as st
9
+ import os
10
+ def get_response(input_text):
11
+ groq_api_key="GROK-API-KEY"
12
+ llm=ChatGroq(groq_api_key=groq_api_key,
13
+ model_name="mixtral-8x7b-32768")
14
+ prompt=ChatPromptTemplate.from_messages(
15
+ [
16
+ ("system","You are the equivalent of a therapist. Please be empathetic and kind towards the user think of them as a person who has no one to talk to.Ask them what they need. Or what they want or if they need someone to listen to."),
17
+ ("user","Question:{question}")
18
+ ]
19
+ )
20
+ #prompt = PromptTemplate(template=prompt, input_variables=["question"])
21
+ #llm_chain = LLMChain(prompt=prompt, llm=llm)
22
+ output_parser=StrOutputParser()
23
+ chain=prompt|llm|output_parser
24
+ response=chain.invoke({"question":input_text})
25
+ return response
26
+ def main():
27
+ st.title("Therapy Bot")
28
+ input_text=st.text_input("How are you Today ?")
29
+ if st.button("Say"):
30
+ if input_text.strip() !="":
31
+ response=get_response(input_text)
32
+ st.write(response)
33
+ else:
34
+ st.warning("Please enter a question.")
35
+ if __name__=="__main__":
36
+ main()