Spaces:
Sleeping
Sleeping
Updated to use Datasets instead of locally stored file
Browse files
app.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
| 1 |
import os
|
| 2 |
import streamlit as st
|
| 3 |
-
import
|
| 4 |
from huggingface_hub import InferenceClient
|
| 5 |
|
| 6 |
api_key = os.getenv("HF_API_KEY")
|
| 7 |
client = InferenceClient(api_key=api_key)
|
| 8 |
-
|
| 9 |
|
| 10 |
-
def
|
| 11 |
-
doc = docx.Document(file_path)
|
| 12 |
text = []
|
| 13 |
-
|
| 14 |
-
text.append(
|
| 15 |
return "\n".join(text)
|
| 16 |
-
|
|
|
|
| 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')
|