Update app.py
Browse files
app.py
CHANGED
|
@@ -88,22 +88,16 @@ def chat(query,history):
|
|
| 88 |
"""## Setting up UI with gradio"""
|
| 89 |
|
| 90 |
import gradio as gr
|
| 91 |
-
from huggingface_hub import
|
| 92 |
|
| 93 |
-
|
| 94 |
|
| 95 |
-
def write_to_file(file_name,
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
print(file_name)
|
| 100 |
-
api.upload_file(
|
| 101 |
-
path_or_fileobj=file_name, # Use the file path instead of the file object
|
| 102 |
-
repo_id="mgreg555/docs_chat",
|
| 103 |
-
repo_type="space",
|
| 104 |
-
path_in_repo=file_name # Ensure this matches the file name if you want to keep the same name in the repo
|
| 105 |
-
)
|
| 106 |
|
|
|
|
| 107 |
|
| 108 |
|
| 109 |
def vote(tmp, index_state, data: gr.LikeData):
|
|
|
|
| 88 |
"""## Setting up UI with gradio"""
|
| 89 |
|
| 90 |
import gradio as gr
|
| 91 |
+
from huggingface_hub import HfFileSystem
|
| 92 |
|
| 93 |
+
fs = HfFileSystem(token=OS["acces_token"])
|
| 94 |
|
| 95 |
+
def write_to_file(file_name,content):
|
| 96 |
+
file_path = f"spaces/mgreg555/docs_chat/" + file_name
|
| 97 |
+
with fs.open(file_path, "a") as file:
|
| 98 |
+
file.write(content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
+
# Example usage
|
| 101 |
|
| 102 |
|
| 103 |
def vote(tmp, index_state, data: gr.LikeData):
|