Spaces:
Sleeping
Sleeping
Try to read a docx file
Browse files
app.py
CHANGED
|
@@ -1,9 +1,18 @@
|
|
| 1 |
import os
|
| 2 |
import streamlit as st
|
|
|
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
api_key = os.getenv("HF_API_KEY")
|
| 6 |
client = InferenceClient(api_key=api_key)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
user_input = st.text_input('Ask me a question')
|
| 9 |
messages = [{"role": "user","content": user_input}]
|
|
|
|
| 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 |
|
| 17 |
user_input = st.text_input('Ask me a question')
|
| 18 |
messages = [{"role": "user","content": user_input}]
|