k96beni commited on
Commit
ca91c25
·
verified ·
1 Parent(s): 38bc51b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -17,7 +17,7 @@ login(token=HF_TOKEN)
17
 
18
  REPO_ID = "ChargeNodeEurope/Chatbot_4o_mini" # Exempel
19
  REPO_LOCAL_PATH = "chatbot_faq_repo"
20
- FAQ_CSV_PATH = "faq_städad_utf8_fixed.csv"
21
 
22
  repo = Repository(
23
  local_dir=REPO_LOCAL_PATH,
@@ -26,9 +26,9 @@ repo = Repository(
26
  use_auth_token=HF_TOKEN
27
  )
28
 
29
- faq_path = os.path.join(REPO_LOCAL_PATH, FAQ_CSV_PATH)
30
  try:
31
- df = pd.read_csv(faq_path, sep=";")
32
  df.dropna(subset=["Fråga", "Svar"], inplace=True)
33
  except Exception as e:
34
  raise FileNotFoundError(f"Kunde inte ladda FAQ-filen: {str(e)}")
@@ -98,7 +98,7 @@ def lägg_till_faq(fråga, svar, kategori):
98
  df = pd.concat([df, ny_rad], ignore_index=True)
99
 
100
  # Spara och pusha
101
- df.to_csv(faq_path, index=False, sep=";")
102
  uppdatera_embeddings() # Skapa nya embeddings
103
 
104
  repo.git_add()
@@ -131,7 +131,7 @@ def uppdatera_faq(gammal_fråga, nytt_svar, ny_kategori):
131
  df.loc[match_index, "Kategori"] = ny_kategori
132
 
133
  try:
134
- df.to_csv(faq_path, index=False, sep=";")
135
  uppdatera_embeddings()
136
 
137
  repo.git_add()
@@ -154,7 +154,7 @@ def ta_bort_faq(fråga_att_radera):
154
  df.drop(match_index, inplace=True)
155
 
156
  try:
157
- df.to_csv(faq_path, index=False, sep=";")
158
  uppdatera_embeddings()
159
 
160
  repo.git_add()
@@ -210,4 +210,4 @@ with gr.Blocks() as demo:
210
  btn_show.click(fn=visa_senaste_faq, inputs=[], outputs=out_log)
211
 
212
  if __name__ == "__main__":
213
- demo.launch()
 
17
 
18
  REPO_ID = "ChargeNodeEurope/Chatbot_4o_mini" # Exempel
19
  REPO_LOCAL_PATH = "chatbot_faq_repo"
20
+ FAQ_XLSX_PATH = "FAQ stadat.xlsx"
21
 
22
  repo = Repository(
23
  local_dir=REPO_LOCAL_PATH,
 
26
  use_auth_token=HF_TOKEN
27
  )
28
 
29
+ faq_path = os.path.join(REPO_LOCAL_PATH, FAQ_XLSX_PATH)
30
  try:
31
+ df = pd.read_excel(faq_path)
32
  df.dropna(subset=["Fråga", "Svar"], inplace=True)
33
  except Exception as e:
34
  raise FileNotFoundError(f"Kunde inte ladda FAQ-filen: {str(e)}")
 
98
  df = pd.concat([df, ny_rad], ignore_index=True)
99
 
100
  # Spara och pusha
101
+ df.to_excel(faq_path, index=False)
102
  uppdatera_embeddings() # Skapa nya embeddings
103
 
104
  repo.git_add()
 
131
  df.loc[match_index, "Kategori"] = ny_kategori
132
 
133
  try:
134
+ df.to_excel(faq_path, index=False)
135
  uppdatera_embeddings()
136
 
137
  repo.git_add()
 
154
  df.drop(match_index, inplace=True)
155
 
156
  try:
157
+ df.to_excel(faq_path, index=False)
158
  uppdatera_embeddings()
159
 
160
  repo.git_add()
 
210
  btn_show.click(fn=visa_senaste_faq, inputs=[], outputs=out_log)
211
 
212
  if __name__ == "__main__":
213
+ demo.launch()