wissem29 commited on
Commit
8e9272d
·
verified ·
1 Parent(s): 5e083ab

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +45 -0
  2. readme.txt +14 -0
  3. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain import HuggingFaceHub
2
+ from langchain.schema import HumanMessage,SystemMessage,AIMessage
3
+
4
+ from dotenv import load_dotenv
5
+
6
+ load_dotenv()
7
+
8
+ import streamlit as st
9
+ ##streamlit app
10
+ st.set_page_config(page_title="Chatbot")
11
+ st.header('Langchain Application')
12
+
13
+
14
+
15
+ # Initialization session
16
+ ##if 'key' not in st.session_state:
17
+ # st.session_state['key'] =[
18
+ # SystemMessage(content='You are AI ')
19
+ # ]
20
+
21
+
22
+ # function to load huggingface model and get response
23
+ def get_huggingface_response(question):
24
+ llm_huggingface=HuggingFaceHub(repo_id="google/flan-t5-large",model_kwargs={"temperature":0.0})
25
+
26
+ #st.session_state['key'].append(HumanMessage(content=question))
27
+ #response=llm_huggingface(st.session_state['key'])
28
+ response = llm_huggingface(question)
29
+ #st.session_state['key'].append(AIMessage(content=response))
30
+ return(response)
31
+
32
+
33
+
34
+
35
+ ##streamlit input
36
+ input=st.text_input("Input: ",key="input")
37
+ ## call function
38
+ response=get_huggingface_response(input)
39
+
40
+ ##streamlit button
41
+ submit=st.button('Generate')
42
+ ## click button
43
+ if submit:
44
+ st.subheader("The response is ")
45
+ st.write(response)
readme.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ install python
2
+ create virtual envirement (venv)
3
+
4
+ install langchain
5
+ install openai
6
+ install ipykernel(for notbook)
7
+
8
+ install huggingface
9
+
10
+
11
+
12
+
13
+
14
+
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ langchain
2
+ openai
3
+ huggingface_hub
4
+ python-dotenv
5
+ streamlit