mgreg555 commited on
Commit
28f8ec9
·
verified ·
1 Parent(s): 20d6845

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -13
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 HfApi, HfFolder
92
 
93
- api = HfApi()
94
 
95
- def write_to_file(file_name, value):
96
- with open(file_name, 'a', encoding='utf-8') as file:
97
- file.write(find_previous_question(value) + ';' + str(value) + '\n')
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):