Sharathhebbar24 commited on
Commit
9ad96fc
·
1 Parent(s): c7c34a9

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Hello! It seems like you want to import the Streamlit library in Python. Streamlit is a powerful open-source framework used for building web applications with interactive data visualizations and machine learning models. To import Streamlit, you'll need to ensure that you have it installed in your Python environment.
2
+ #Once you have Streamlit installed, you can import it into your Python script using the import statement,
3
+
4
+ import streamlit as st
5
+
6
+
7
+ from langchain.llms import HuggingFaceHub
8
+
9
+ #Function to return the response
10
+ def load_answer(question):
11
+ model_name = "google/flan-t5-large"
12
+ # model_name = "starmpcc/Asclepius-13B"
13
+
14
+ model_kwargs = {
15
+ "temperature": 0.9,
16
+ "max_length": 1024
17
+ }
18
+
19
+ llm = HuggingFaceHub(
20
+ repo_id = model_name,
21
+ model_kwargs = model_kwargs
22
+ )
23
+ answer=llm(question)
24
+ return answer
25
+
26
+
27
+ #App UI starts here
28
+ st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
29
+ st.header("LangChain Demo")
30
+
31
+ #Gets the user input
32
+ def get_text():
33
+ input_text = st.text_input("You: ", key="input")
34
+ return input_text
35
+
36
+
37
+ user_input=get_text()
38
+ response = load_answer(user_input)
39
+
40
+ submit = st.button('Generate')
41
+
42
+ #If generate button is clicked
43
+ if submit:
44
+
45
+ st.subheader("Answer:")
46
+
47
+ st.write(response)
48
+