thlanza commited on
Commit
ec04958
0 Parent(s):

Duplicate from thlanza/LLMsIntro

Browse files
Files changed (5) hide show
  1. .env-sample +1 -0
  2. .gitattributes +35 -0
  3. README.md +13 -0
  4. app.py +37 -0
  5. requirements.txt +5 -0
.env-sample ADDED
@@ -0,0 +1 @@
 
 
1
+ OPENAI_API_KEY=""
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: LLMsIntro
3
+ emoji: 🚀
4
+ colorFrom: green
5
+ colorTo: indigo
6
+ sdk: streamlit
7
+ sdk_version: 1.26.0
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: thlanza/LLMsIntro
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain.llms import HuggingFaceHub
3
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
4
+
5
+
6
+ # Answer:
7
+ # [
8
+ # 0:{
9
+ # "generated_text":"I like rice I like rice I like rice I like ri"
10
+ # }
11
+ # ]
12
+
13
+ #Function to return the response
14
+ def load_answer(question):
15
+ tokenizer = AutoTokenizer.from_pretrained("unicamp-dl/translation-pt-en-t5")
16
+ model = AutoModelForSeq2SeqLM.from_pretrained("unicamp-dl/translation-pt-en-t5")
17
+ pten_pipeline = pipeline('text2text-generation', model=model, tokenizer=tokenizer)
18
+ return pten_pipeline(question)[0]["generated_text"]
19
+
20
+ #App UI starts here
21
+ st.set_page_config(page_title="Lanza Chatbot", page_icon=":robot:")
22
+ st.header("Lanza Chatbot")
23
+
24
+ #Gets the user input
25
+ def get_text():
26
+ input_text = st.text_input("You: ", key="input")
27
+ return input_text
28
+
29
+ user_input=get_text()
30
+ response = load_answer(user_input)
31
+
32
+ submit = st.button('Generate')
33
+
34
+ if submit:
35
+
36
+ st.subheader("Answer:")
37
+ st.write(response)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ langchain
2
+ Openai
3
+ Streamlit
4
+ transformers
5
+ torch