peterpull commited on
Commit
b5fa340
·
1 Parent(s): bc87b32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -15,15 +15,16 @@ os.environ["OPENAI_API_KEY"] = os.environ['SECRET_CODE']
15
  # Need to write to persistent dataset because cannot store temp data on spaces
16
  DATASET_REPO_URL = "https://huggingface.co/datasets/peterpull/MediatorBot"
17
  DATA_FILENAME = "data.txt"
 
18
  DATA_FILE = os.path.join("data", DATA_FILENAME)
 
19
 
20
-
21
-
22
- # I am guessing we need a write access token.
23
  HF_TOKEN = os.environ.get("HF_TOKEN")
24
  print("HF TOKEN is none?", HF_TOKEN is None)
25
  print("HF hub ver", huggingface_hub.__version__)
26
 
 
27
  repo = Repository(
28
  local_dir='data',
29
  clone_from=DATASET_REPO_URL,
@@ -64,7 +65,7 @@ def get_index(index_file_path):
64
 
65
  # passes the prompt to the chatbot
66
  def chatbot(input_text, mentioned_person='Mediator John Haynes'):
67
- index = get_index('./index/indexsmall.json')
68
  prompt = f"You are {mentioned_person}: {input_text}\n\n At the end of your answer ask a provocative question."
69
  response = index.query(prompt, response_mode="compact")
70
 
 
15
  # Need to write to persistent dataset because cannot store temp data on spaces
16
  DATASET_REPO_URL = "https://huggingface.co/datasets/peterpull/MediatorBot"
17
  DATA_FILENAME = "data.txt"
18
+ INDEX_FILENAME = "index_base_89MB.json"
19
  DATA_FILE = os.path.join("data", DATA_FILENAME)
20
+ INDEX_FILE = os.path.join("data", INDEX_FILENAME)
21
 
22
+ # we need a write access token.
 
 
23
  HF_TOKEN = os.environ.get("HF_TOKEN")
24
  print("HF TOKEN is none?", HF_TOKEN is None)
25
  print("HF hub ver", huggingface_hub.__version__)
26
 
27
+ #Clones the distant repo to the local repo
28
  repo = Repository(
29
  local_dir='data',
30
  clone_from=DATASET_REPO_URL,
 
65
 
66
  # passes the prompt to the chatbot
67
  def chatbot(input_text, mentioned_person='Mediator John Haynes'):
68
+ index = get_index(INDEX_FILE)
69
  prompt = f"You are {mentioned_person}: {input_text}\n\n At the end of your answer ask a provocative question."
70
  response = index.query(prompt, response_mode="compact")
71