kubrabuzlu commited on
Commit
eb150a7
·
verified ·
1 Parent(s): e84e83a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py CHANGED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ from langchain_huggingface import HuggingFaceEndpoint
4
+
5
+ api_key = os.environ.get("HUGGINGFACEHUB_API_TOKEN")
6
+
7
+ def load_answer(question):
8
+ llm = HuggingFaceEndpoint(
9
+ repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
10
+ )
11
+ answer = llm.invoke(question)
12
+ return answer
13
+
14
+ st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
15
+ st.header("LangChain Demo")
16
+
17
+ def get_text():
18
+ input_text = st.text_input("You: ", key="input")
19
+ return input_text
20
+
21
+ user_input = get_text()
22
+ if user_input != "":
23
+ response = load_answer(user_input)
24
+
25
+ submit = st.button('Generate')
26
+ if submit:
27
+ st.subheader("Answer:")
28
+ st.write(response)