andreska commited on
Commit
b6e1d0d
·
verified ·
1 Parent(s): c2dd4a5

Updated to use Datasets instead of locally stored file

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,19 +1,19 @@
1
  import os
2
  import streamlit as st
3
- import docx
4
  from huggingface_hub import InferenceClient
5
 
6
  api_key = os.getenv("HF_API_KEY")
7
  client = InferenceClient(api_key=api_key)
8
- file_path = "Adrega_P.I._User_Manual.docx"
9
 
10
- def read_docx(file_path):
11
- doc = docx.Document(file_path)
12
  text = []
13
- for paragraph in doc.paragraphs:
14
- text.append(paragraph.text)
15
  return "\n".join(text)
16
- context = read_docx(file_path)
 
17
 
18
  st.title("Adrega AI Help")
19
  user_input = st.text_input('Ask me a question')
 
1
  import os
2
  import streamlit as st
3
+ from datasets import load_dataset
4
  from huggingface_hub import InferenceClient
5
 
6
  api_key = os.getenv("HF_API_KEY")
7
  client = InferenceClient(api_key=api_key)
8
+ dataset = load_dataset("alpha_test_data.txt", split="test")
9
 
10
+ def read_dataset(dataset):
 
11
  text = []
12
+ from item in dataset:
13
+ text.append(item['text'])
14
  return "\n".join(text)
15
+
16
+ context = read_dataset(dataset)
17
 
18
  st.title("Adrega AI Help")
19
  user_input = st.text_input('Ask me a question')