mk-84 commited on
Commit
222baa1
1 Parent(s): e76767b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_core.prompts import ChatPromptTemplate
2
+ from langchain_core.output_parsers import StrOutputParser
3
+ from langchain_groq import ChatGroq
4
+
5
+ import streamlit as st
6
+ import os
7
+ from dotenv import load_dotenv
8
+
9
+ load_dotenv()
10
+
11
+ os.environ["GROQ_API_KEY"] = os.getenv("GROQ_API_KEY")
12
+ os.environ["LANGCHAIN_API_KEY"] = os.getenv("LANGCHAIN_API_KEY")
13
+ os.environ["LANGCHAIN_TRACING_V2"] = "true"
14
+ os.environ["LANGCHAIN_PROJECT"] = "sarcastic_bot"
15
+
16
+ # build a LLM chain
17
+ promptTemplate = ChatPromptTemplate.from_messages(
18
+ [
19
+ ("system", "Reply with {way} to all the questions"),
20
+ ("user", "Question:{question}"),
21
+ ]
22
+ )
23
+
24
+ model = ChatGroq(model="mixtral-8x7b-32768")
25
+ parser = StrOutputParser()
26
+
27
+ chain = promptTemplate|model|parser
28
+
29
+ #create streamlit
30
+ st.title("Sarcastic GROQ")
31
+ input_text = st.text_input("Ask you question mate!")
32
+
33
+ if input_text:
34
+ st.write(chain.invoke({"way": "sarcasm", "question": input_text}))