rodrisouza commited on
Commit
869aece
·
verified ·
1 Parent(s): 1f73e37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -59,7 +59,7 @@ def load_model(model_name):
59
  tokenizer = AutoTokenizer.from_pretrained(
60
  model_path,
61
  padding_side='left',
62
- token=hugging_face_token,
63
  trust_remote_code=True
64
  )
65
 
@@ -70,7 +70,7 @@ def load_model(model_name):
70
 
71
  model = AutoModelForCausalLM.from_pretrained(
72
  model_path,
73
- token=hugging_face_token,
74
  trust_remote_code=True
75
  )
76
 
@@ -85,6 +85,7 @@ def load_model(model_name):
85
  return tokenizer, model
86
 
87
 
 
88
  # Ensure the initial model is loaded
89
  tokenizer, model = load_model(selected_model)
90
 
@@ -146,7 +147,7 @@ def send_selected_story(title, model_name, system_prompt):
146
  global data # Ensure data is reset
147
  data = [] # Reset data for new story
148
  interaction_count = 1 # Reset interaction count for new story
149
- tokenizer, model = load_model(model_name)
150
  selected_story = title
151
  for story in stories:
152
  if story["title"] == title:
@@ -170,6 +171,7 @@ Here is the story:
170
  else:
171
  print("Story title does not match.")
172
 
 
173
  # Function to save comment and score
174
  def save_comment_score(chat_responses, score, comment, story_name, user_name, system_prompt):
175
  full_chat_history = ""
 
59
  tokenizer = AutoTokenizer.from_pretrained(
60
  model_path,
61
  padding_side='left',
62
+ use_auth_token=hugging_face_token,
63
  trust_remote_code=True
64
  )
65
 
 
70
 
71
  model = AutoModelForCausalLM.from_pretrained(
72
  model_path,
73
+ use_auth_token=hugging_face_token,
74
  trust_remote_code=True
75
  )
76
 
 
85
  return tokenizer, model
86
 
87
 
88
+
89
  # Ensure the initial model is loaded
90
  tokenizer, model = load_model(selected_model)
91
 
 
147
  global data # Ensure data is reset
148
  data = [] # Reset data for new story
149
  interaction_count = 1 # Reset interaction count for new story
150
+ tokenizer, model = load_model(model_name) # Load the appropriate model
151
  selected_story = title
152
  for story in stories:
153
  if story["title"] == title:
 
171
  else:
172
  print("Story title does not match.")
173
 
174
+
175
  # Function to save comment and score
176
  def save_comment_score(chat_responses, score, comment, story_name, user_name, system_prompt):
177
  full_chat_history = ""