New vectorstore, examples, removed radio selectors and reduced window size
Browse files- app.py +15 -6
- models/openai_vs.index +1 -1
- models/openai_vs.pkl +2 -2
- utils.py +126 -0
app.py
CHANGED
@@ -68,21 +68,30 @@ def bot(history):
|
|
68 |
return history
|
69 |
|
70 |
with gr.Blocks() as demo:
|
|
|
71 |
|
72 |
-
|
|
|
|
|
73 |
|
74 |
with gr.Row():
|
75 |
# Create radio button to select model
|
76 |
-
radio = gr.Radio(models, label="Choose a model", value="GPT-3.5", type="value")
|
77 |
with gr.Row():
|
78 |
-
with gr.Column(scale=0.75):
|
79 |
txt = gr.Textbox(
|
80 |
label="Coursera Voice Q&A Bot",
|
81 |
placeholder="Enter text and press enter, or upload an image", lines=1
|
82 |
-
)
|
|
|
|
|
|
|
83 |
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
86 |
|
87 |
txt.submit(add_text, [chatbot, txt, radio], [chatbot, txt], postprocess=False).then(
|
88 |
bot, chatbot, chatbot
|
|
|
68 |
return history
|
69 |
|
70 |
with gr.Blocks() as demo:
|
71 |
+
# Title on top in middle of the page
|
72 |
|
73 |
+
gr.HTML("<h1 style='text-align: center;color: blue'>Course Assistant - 3D Printing Revolution</h1>")
|
74 |
+
|
75 |
+
chatbot = gr.Chatbot(get_first_message([]), elem_id="chatbot").style(height=500)
|
76 |
|
77 |
with gr.Row():
|
78 |
# Create radio button to select model
|
79 |
+
radio = gr.Radio(models, label="Choose a model", value="GPT-3.5", type="value", visible=False)
|
80 |
with gr.Row():
|
81 |
+
# with gr.Column(scale=0.75):
|
82 |
txt = gr.Textbox(
|
83 |
label="Coursera Voice Q&A Bot",
|
84 |
placeholder="Enter text and press enter, or upload an image", lines=1
|
85 |
+
)
|
86 |
+
|
87 |
+
# with gr.Column(scale=0.25):
|
88 |
+
audio = gr.Audio(source="microphone", type="filepath", visible=False)
|
89 |
|
90 |
+
with gr.Row():
|
91 |
+
gr.Examples(
|
92 |
+
examples=['What is 3D printing?', 'Who are the instructors of the course?', 'What is the course about?',
|
93 |
+
'Which software can be used to create a design file for 3D printing?', 'What are the key takeaways from the course?'], inputs=[txt],
|
94 |
+
label="Examples")
|
95 |
|
96 |
txt.submit(add_text, [chatbot, txt, radio], [chatbot, txt], postprocess=False).then(
|
97 |
bot, chatbot, chatbot
|
models/openai_vs.index
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 2199597
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3b1005a3d6565b4511ca7a3f53c8b21fb279b7e508694ca10553857506dafd8f
|
3 |
size 2199597
|
models/openai_vs.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:807e1e7a285df094ec49ec67f44438d8a300e017fc1290073dd4c60432c9473b
|
3 |
+
size 2513084
|
utils.py
CHANGED
@@ -18,6 +18,127 @@ from langchain.text_splitter import CharacterTextSplitter
|
|
18 |
from langchain.vectorstores.faiss import FAISS
|
19 |
from langchain.cache import InMemoryCache
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
langchain.llm_cache = InMemoryCache()
|
22 |
|
23 |
global model_name
|
@@ -139,6 +260,11 @@ def get_html_files():
|
|
139 |
def fetch_data_for_embeddings():
|
140 |
document_list = get_text_files()
|
141 |
document_list.extend(get_html_files())
|
|
|
|
|
|
|
|
|
|
|
142 |
print("document list: " + str(len(document_list)))
|
143 |
return document_list
|
144 |
|
|
|
18 |
from langchain.vectorstores.faiss import FAISS
|
19 |
from langchain.cache import InMemoryCache
|
20 |
|
21 |
+
# Create a dict of filenames and their corresponding url links to be used as source in line #203
|
22 |
+
file_url_mapping = {
|
23 |
+
'docs/01_course-orientation/01_about-the-course/01_introduction-to-the-3d-printing-specialization.en.txt':
|
24 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/mLvWU/introduction-to-the-3d-printing-specialization',
|
25 |
+
'docs/01_course-orientation/01_about-the-course/02_welcome-to-the-3d-printing-revolution.en.txt':
|
26 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/zQ7lG/welcome-to-the-3d-printing-revolution',
|
27 |
+
|
28 |
+
'docs/03_module-2-why-is-it-revolutionary/03_the-3d-printing-revolution-facts-concepts/02_how-will-3d-printing-change-business.en.txt':
|
29 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/D8VUj/how-will-3d-printing-change-business',
|
30 |
+
|
31 |
+
'docs/03_module-2-why-is-it-revolutionary/03_the-3d-printing-revolution-facts-concepts/01_whats-special-about-3d-printing.en.txt':
|
32 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/WmJQL/whats-special-about-3d-printing',
|
33 |
+
|
34 |
+
'docs/03_module-2-why-is-it-revolutionary/03_the-3d-printing-revolution-facts-concepts/04_remixing-products-exercise-overview.en.txt':
|
35 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/J3Tq3/remixing-products-exercise-overview',
|
36 |
+
|
37 |
+
'docs/03_module-2-why-is-it-revolutionary/03_the-3d-printing-revolution-facts-concepts/03_the-future-of-3d-printing.en.txt':
|
38 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/tjSlh/the-future-of-3d-printing',
|
39 |
+
|
40 |
+
'docs/03_module-2-why-is-it-revolutionary/02_an-early-look-at-the-coming-revolution/01_tour-of-the-illinois-makerlab-vishal-sachdev.en.txt':
|
41 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/rcVnN/tour-of-the-illinois-makerlab-vishal-sachdev',
|
42 |
+
|
43 |
+
'docs/03_module-2-why-is-it-revolutionary/02_an-early-look-at-the-coming-revolution/02_meet-the-makers-arielle-rausin-cameron-alberg-scott-zelman.en.txt':
|
44 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/J2nD2/meet-the-makers-arielle-rausin-cameron-alberg-scott-zelman',
|
45 |
+
'docs/03_module-2-why-is-it-revolutionary/04_the-revolutionaries/03_shapeways-lauren-slowik.en.txt':
|
46 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/mi1zr/shapeways-lauren-slowik',
|
47 |
+
'docs/03_module-2-why-is-it-revolutionary/04_the-revolutionaries/04_3d-fashion-francis-bitonti.en.txt':
|
48 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/KmYxf/3d-fashion-francis-bitonti',
|
49 |
+
'docs/03_module-2-why-is-it-revolutionary/04_the-revolutionaries/06_whats-next-hod-lipson.en.txt':
|
50 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/3zKRN/whats-next-hod-lipson',
|
51 |
+
'docs/03_module-2-why-is-it-revolutionary/04_the-revolutionaries/05_3d-printed-battery-paul-braun.en.txt':
|
52 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/mrEAK/3d-printed-battery-paul-braun',
|
53 |
+
'docs/03_module-2-why-is-it-revolutionary/04_the-revolutionaries/02_normal-nikki-kaufman.en.txt':
|
54 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/I8QXq/normal-nikki-kaufman',
|
55 |
+
'docs/03_module-2-why-is-it-revolutionary/04_the-revolutionaries/01_voodoo-manufacturing-max-friefeld.en.txt':
|
56 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/atrTP/voodoo-manufacturing-max-friefeld',
|
57 |
+
'docs/04_course-conclusion/01_course-wrap-up-whats-next/01_the-3d-printing-revolution-wrap-up.en.txt':
|
58 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/f6XvX/the-3d-printing-revolution-wrap-up',
|
59 |
+
'docs/04_course-conclusion/01_course-wrap-up-whats-next/03_gies-online-programs.en.txt':
|
60 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/JdvZk/gies-online-programs',
|
61 |
+
|
62 |
+
'docs/02_module-1-what-is-3d-printing/05_optional-content/01_like-this-course-learn-more-with-the-imba-optional.en.txt':
|
63 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/MIATt/like-this-course-learn-more-with-the-imba-optional',
|
64 |
+
'docs/02_module-1-what-is-3d-printing/03_3d-printing-facts-concepts/04_where-designs-come-from.en.txt':
|
65 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/0fU1x/where-designs-come-from',
|
66 |
+
'docs/02_module-1-what-is-3d-printing/03_3d-printing-facts-concepts/05_where-to-find-3d-printers.en.txt':
|
67 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/3XTPj/where-to-find-3d-printers',
|
68 |
+
'docs/02_module-1-what-is-3d-printing/03_3d-printing-facts-concepts/01_history-of-3d-printing.en.txt':
|
69 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/HMvuh/history-of-3d-printing',
|
70 |
+
'docs/02_module-1-what-is-3d-printing/03_3d-printing-facts-concepts/02_how-3d-printers-work.en.txt':
|
71 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/dNpvw/how-3d-printers-work',
|
72 |
+
'docs/02_module-1-what-is-3d-printing/03_3d-printing-facts-concepts/03_materials-costs.en.txt':
|
73 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/j63D2/materials-costs',
|
74 |
+
'docs/02_module-1-what-is-3d-printing/03_3d-printing-facts-concepts/06_3d-printing-applications.en.txt':
|
75 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/EJdi9/3d-printing-applications',
|
76 |
+
|
77 |
+
'docs/02_module-1-what-is-3d-printing/04_more-3d-printing-insights/03_selective-laser-melting-rodrigo-gutierrez.en.txt':
|
78 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/kkpwz/selective-laser-melting-rodrigo-gutierrez',
|
79 |
+
'docs/02_module-1-what-is-3d-printing/04_more-3d-printing-insights/04_3d-printing-ecosystem-aaron-roy.en.txt':
|
80 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/2zjzy/3d-printing-ecosystem-aaron-roy',
|
81 |
+
|
82 |
+
'docs/02_module-1-what-is-3d-printing/04_more-3d-printing-insights/01_3d-printing-demonstration-danny-lohan.en.txt':
|
83 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/5b8IG/3d-printing-demonstration-danny-lohan',
|
84 |
+
|
85 |
+
'docs/02_module-1-what-is-3d-printing/04_more-3d-printing-insights/02_3d-printing-vs-additive-manufacturing-mark-cotteleer.en.txt':
|
86 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/qBvTb/3d-printing-vs-additive-manufacturing-mark-cotteleer',
|
87 |
+
'docs/02_module-1-what-is-3d-printing/02_3d-printing-insights/02_my-3d-printing-story-aric-rindfleisch.en.txt':
|
88 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/hhWc8/my-3d-printing-story-aric-rindfleisch',
|
89 |
+
|
90 |
+
'docs/02_module-1-what-is-3d-printing/02_3d-printing-insights/04_3d-printing-the-maker-movement-hackerspaces-chris-meyer.en.txt':
|
91 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/8HO88/3d-printing-the-maker-movement-hackerspaces-chris-meyer',
|
92 |
+
'docs/02_module-1-what-is-3d-printing/02_3d-printing-insights/06_what-would-you-make-exercise-overview.en.txt':
|
93 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/kfDp2/what-would-you-make-exercise-overview',
|
94 |
+
|
95 |
+
'docs/02_module-1-what-is-3d-printing/02_3d-printing-insights/05_the-birth-of-desktop-3d-printing-matt-griffin.en.txt':
|
96 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/RlvEF/the-birth-of-desktop-3d-printing-matt-griffin',
|
97 |
+
'docs/02_module-1-what-is-3d-printing/02_3d-printing-insights/03_tour-of-sector67-chris-meyer.en.txt':
|
98 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/HXJrm/tour-of-sector67-chris-meyer',
|
99 |
+
'docs/02_module-1-what-is-3d-printing/02_3d-printing-insights/01_views-on-3d-printing-champaign-new-york.en.txt':
|
100 |
+
'https://www.coursera.org/learn/3d-printing-revolution/lecture/jvULv/views-on-3d-printing-champaign-new-york',
|
101 |
+
'docs/01_course-orientation/01_about-the-course/05_glossary_instructions.html':
|
102 |
+
'https://www.coursera.org/learn/3d-printing-revolution/supplement/515pX/glossary',
|
103 |
+
'docs/01_course-orientation/01_about-the-course/03_syllabus_instructions.html':
|
104 |
+
'https://www.coursera.org/learn/3d-printing-revolution/supplement/l2J8d/syllabus',
|
105 |
+
'docs/01_course-orientation/01_about-the-course/06_learner-stories_instructions.html':
|
106 |
+
'https://www.coursera.org/learn/3d-printing-revolution/supplement/goE8a/learner-stories',
|
107 |
+
'docs/01_course-orientation/01_about-the-course/04_about-the-discussion-forums_instructions.html':
|
108 |
+
'https://www.coursera.org/learn/3d-printing-revolution/supplement/HA7H7/about-the-discussion-forums',
|
109 |
+
'docs/01_course-orientation/02_about-your-classmates/02_social-media_illinois.edu.html':
|
110 |
+
'https://www.facebook.com/illinois.edu',
|
111 |
+
'docs/01_course-orientation/02_about-your-classmates/01_updating-your-profile_instructions.html':
|
112 |
+
'https://www.coursera.org/learn/3d-printing-revolution/supplement/f2iFO/updating-your-profile',
|
113 |
+
|
114 |
+
'docs/01_course-orientation/02_about-your-classmates/02_social-media_termsDknlfPe-5xKJJaHWl4j6kveY2GjKiZxK_vd-JDIN3-6piB5w.2PhI_l8TrILDNPPI-v-VPg.kolgdmfhbhzcbgm3-lv_.html':
|
115 |
+
'https://www.coursera.org/about/termsDknlfPe-5xKJJaHWl4j6kveY2GjKiZxK_vd-JDIN3-6piB5w.2PhI_l8TrILDNPPI-v-VPg.kOLGdmfhbhzCbGM3-lv_j477mwb9Ffuxi5xhEac6Biqu1NvspELKPGjNRjoAzuv8LasLtq22lxzrgdd9C8Y4JQ4gHm7FuRqTL4rlby3Pb_N4mpVXMkT83a3Ob_0QWVHv7LiZghGDTwCWYxU4lMfZpfsqsm7PoQ7HfKUFvHwgUIbOGox3ZZgJtBE2t-TDkbegcktpcn6k2VqZZ0WYvQTad7oijs5WHJLfL7EYiUGb01udFqMaOLIPP1msztyo496GDNUgBSvsJcPfHE20dluqe5_KzaSoXzKxXdiW12DjKJk_XDNc14mf41U17h5HgMXg',
|
116 |
+
'docs/01_course-orientation/02_about-your-classmates/02_social-media_instructions.html':
|
117 |
+
'https://www.coursera.org/learn/3d-printing-revolution/supplement/1vga3/social-media',
|
118 |
+
|
119 |
+
'docs/03_module-2-why-is-it-revolutionary/03_the-3d-printing-revolution-facts-concepts/05_remixing-products-exercise_peer_assignment_instructions.html':
|
120 |
+
'https://www.coursera.org/learn/3d-printing-revolution/peer/FAZ0P/remixing-products-exercise',
|
121 |
+
'docs/03_module-2-why-is-it-revolutionary/01_module-2-information/01_module-2-overview_instructions.html':
|
122 |
+
'https://www.coursera.org/learn/3d-printing-revolution/supplement/UwuNp/module-2-overview',
|
123 |
+
'docs/04_course-conclusion/01_course-wrap-up-whats-next/02_congratulations_instructions.html':
|
124 |
+
'https://www.coursera.org/learn/3d-printing-revolution/supplement/vISgA/congratulations',
|
125 |
+
'docs/05_Resources/03_3d-printing-services-and-products/01__resources.html':
|
126 |
+
'https://www.coursera.org/learn/3d-printing-revolution/resources/aPz3d',
|
127 |
+
'docs/05_Resources/04_3d-printing-community/01__resources.html':
|
128 |
+
'https://www.coursera.org/learn/3d-printing-revolution/resources/lfbM9',
|
129 |
+
'docs/05_Resources/02_3d-printing-softwares/01__resources.html':
|
130 |
+
'https://www.coursera.org/learn/3d-printing-revolution/resources/ltlHt',
|
131 |
+
'docs/05_Resources/01_books-articles/01__resources.html':
|
132 |
+
'https://www.coursera.org/learn/3d-printing-revolution/resources/FH3x3',
|
133 |
+
'docs/05_Resources/05_explore-the-imba/01__resources.html':
|
134 |
+
'https://www.coursera.org/learn/3d-printing-revolution/resources/0AejF',
|
135 |
+
'docs/02_module-1-what-is-3d-printing/01_module-1-overview/01_module-1-overview_instructions.html':
|
136 |
+
'https://www.coursera.org/learn/3d-printing-revolution/supplement/HZXB5/module-1-overview',
|
137 |
+
|
138 |
+
'docs/02_module-1-what-is-3d-printing/02_3d-printing-insights/07_what-would-you-make-exercise_peer_assignment_instructions.html':
|
139 |
+
'https://www.coursera.org/learn/3d-printing-revolution/peer/t8bqq/what-would-you-make-exercise'}
|
140 |
+
|
141 |
+
|
142 |
langchain.llm_cache = InMemoryCache()
|
143 |
|
144 |
global model_name
|
|
|
260 |
def fetch_data_for_embeddings():
|
261 |
document_list = get_text_files()
|
262 |
document_list.extend(get_html_files())
|
263 |
+
|
264 |
+
# use file_url_mapping to set metadata of document to url which has been set as the source
|
265 |
+
for document in document_list:
|
266 |
+
document.metadata["url"] = file_url_mapping.get(document.metadata["source"])
|
267 |
+
|
268 |
print("document list: " + str(len(document_list)))
|
269 |
return document_list
|
270 |
|