JosueElias commited on
Commit
f6e7168
·
1 Parent(s): cd4d499

Adding global exception.

Browse files
Files changed (2) hide show
  1. app.py +39 -35
  2. my_dataset.py +3 -7
app.py CHANGED
@@ -1,41 +1,45 @@
1
- import streamlit as st
2
- from mi_clase import pipeline
3
- st.title("Ask your scientific question!")
4
- expected_format = "What is color?\nA)Is a name.\nB)Is something horrible.\nC)I don't know.\nD)You should ask someone else.\nE)Ask in a pyshic book."
5
- txt = st.text_area(
6
- "follow this format while making your question:",
7
- expected_format)
8
  try:
9
- lista = txt.split("E)")
10
- e = lista[1]
11
- lista = lista[0].split("D)")
12
- d = lista[1]
13
- lista = lista[0].split("C)")
14
- c = lista[1]
15
- lista = lista[0].split("B)")
16
- b = lista[1]
17
- lista = lista[0].split("A)")
18
- a = lista[1]
19
- q = lista[0]
 
 
 
 
 
 
 
 
20
 
21
- mi_dict= {
22
- "prompt":q,
23
- "A":a,
24
- "B":b,
25
- "C":c,
26
- "D":d,
27
- "E":e
28
- }
 
 
 
 
 
 
 
 
29
 
30
- try:
31
- answer = pipeline.give_the_best_answer(mi_dict)
32
- st.write(mi_dict)
33
- st.write(answer)
34
  except Exception as e:
35
- st.error("something bad happend to the model")
36
  st.error(e)
37
 
38
- except:
39
- st.error("Your question doesn't have the required format. Please, correct it.")
40
- st.error(e)
41
-
 
 
 
 
 
 
 
 
1
  try:
2
+ import streamlit as st
3
+ from mi_clase import pipeline
4
+ st.title("Ask your scientific question!")
5
+ expected_format = "What is color?\nA)Is a name.\nB)Is something horrible.\nC)I don't know.\nD)You should ask someone else.\nE)Ask in a pyshic book."
6
+ txt = st.text_area(
7
+ "follow this format while making your question:",
8
+ expected_format)
9
+ try:
10
+ lista = txt.split("E)")
11
+ e = lista[1]
12
+ lista = lista[0].split("D)")
13
+ d = lista[1]
14
+ lista = lista[0].split("C)")
15
+ c = lista[1]
16
+ lista = lista[0].split("B)")
17
+ b = lista[1]
18
+ lista = lista[0].split("A)")
19
+ a = lista[1]
20
+ q = lista[0]
21
 
22
+ mi_dict= {
23
+ "prompt":q,
24
+ "A":a,
25
+ "B":b,
26
+ "C":c,
27
+ "D":d,
28
+ "E":e
29
+ }
30
+
31
+ try:
32
+ answer = pipeline.give_the_best_answer(mi_dict)
33
+ st.write(mi_dict)
34
+ st.write(answer)
35
+ except Exception as e:
36
+ st.error("something bad happend to the model")
37
+ st.error(e)
38
 
 
 
 
 
39
  except Exception as e:
40
+ st.error("Your question doesn't have the required format. Please, correct it.")
41
  st.error(e)
42
 
43
+ except Exception as e:
44
+ st.error("error at the beggining")
45
+ st.error(e)
 
my_dataset.py CHANGED
@@ -1,17 +1,13 @@
1
- '''
2
- load dataset:
3
- https://huggingface.co/docs/datasets/loading#hugging-face-hub
4
- '''
5
 
6
  from datasets import load_from_disk, Dataset
7
  from huggingface_hub import hf_hub_download
8
  from datasets import load_dataset
9
  import faiss
10
- # load wikipedia dataset
11
  datasetx = load_dataset("JosueElias/pipeline_dataset2")
12
- # load faiss file and get route of file
13
  path2 = hf_hub_download(repo_id="JosueElias/pipeline_faiss", filename="faiss.index", repo_type="dataset")
14
- # save wikipedia dataset locally
15
  datasetx.save_to_disk("./directory")
16
  # delete variable to have more memory space
17
  del datasetx
 
 
 
 
 
1
 
2
  from datasets import load_from_disk, Dataset
3
  from huggingface_hub import hf_hub_download
4
  from datasets import load_dataset
5
  import faiss
6
+ # load wikipedia dataset https://huggingface.co/docs/datasets/loading#hugging-face-hub
7
  datasetx = load_dataset("JosueElias/pipeline_dataset2")
8
+ # load faiss file and get route of file https://huggingface.co/docs/huggingface_hub/guides/download#from-latest-version
9
  path2 = hf_hub_download(repo_id="JosueElias/pipeline_faiss", filename="faiss.index", repo_type="dataset")
10
+ # save wikipedia dataset locally https://huggingface.co/docs/datasets/process#save
11
  datasetx.save_to_disk("./directory")
12
  # delete variable to have more memory space
13
  del datasetx