andreska commited on
Commit
93cfa6a
·
verified ·
1 Parent(s): f873ddd

Updated app to include local help-file as contexct

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -1,13 +1,23 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
- from datasets import load_dataset
 
 
 
 
 
 
 
 
 
4
 
5
  pipe = pipeline("question-answering")
6
  #pipe = pipeline("text-generation")
7
 
8
  st.title("Adrega AI Help")
9
  dataset = load_dataset("andreska/adregadocs", split="test")
10
- context = dataset[0]["text"]
 
11
  #context = "Adrega is a very cool company, that implements AI. Rett fra Rio is a company that specializes in body waxing and is owned by Cintia" #dataset[0]["text"]
12
 
13
  user_input = st.text_input('Ask me a question')
 
1
  import streamlit as st
2
  from transformers import pipeline
3
+ import docx
4
+ #from datasets import load_dataset
5
+
6
+ file_path = "Adrega_P.I._User_Manual.docx"
7
+ def read_docx("Adrega_P.I._User_Manual.docx"):
8
+ doc = docx.Document(file_path)
9
+ text = []
10
+ for paragraph in doc.paragraphs:
11
+ text.append(paragraph.text)
12
+ return "\n".join(text)
13
 
14
  pipe = pipeline("question-answering")
15
  #pipe = pipeline("text-generation")
16
 
17
  st.title("Adrega AI Help")
18
  dataset = load_dataset("andreska/adregadocs", split="test")
19
+ context = read_docx(file_path)
20
+ #context = dataset[0]["text"]
21
  #context = "Adrega is a very cool company, that implements AI. Rett fra Rio is a company that specializes in body waxing and is owned by Cintia" #dataset[0]["text"]
22
 
23
  user_input = st.text_input('Ask me a question')