Tonic commited on
Commit
83e252e
1 Parent(s): 3f8a3f7

Update maker.py

Browse files
Files changed (1) hide show
  1. maker.py +6 -3
maker.py CHANGED
@@ -59,7 +59,7 @@ Sure, I'd be happy to help you build a bot! I'm generating a title, system promp
59
 
60
  def predict_beta(message, chatbot=[], system_prompt=system_prompt, max_new_tokens=900, temperature=0.4, top_p=0.9, repetition_penalty=0.9, advanced=True):
61
  client = Client(tulu)
62
-
63
  try:
64
  result = client.predict(
65
  message,
@@ -73,12 +73,15 @@ def predict_beta(message, chatbot=[], system_prompt=system_prompt, max_new_token
73
  )
74
 
75
  if result is not None and len(result) > 0:
76
- bot_message = result[0]
 
 
 
77
  print(bot_message)
78
  return bot_message
79
  else:
80
  raise gr.Error("No response received from the model.")
81
-
82
  except Exception as e:
83
  error_msg = f"An error occurred: {str(e)}"
84
  raise gr.Error(error_msg)
 
59
 
60
  def predict_beta(message, chatbot=[], system_prompt=system_prompt, max_new_tokens=900, temperature=0.4, top_p=0.9, repetition_penalty=0.9, advanced=True):
61
  client = Client(tulu)
62
+ start_phrase = "Sure, I'd be happy to help you build a bot!"
63
  try:
64
  result = client.predict(
65
  message,
 
73
  )
74
 
75
  if result is not None and len(result) > 0:
76
+ bot_message = result[0]
77
+ last_response_start = bot_message.rfind("start_phrase)
78
+ if last_response_start != -1:
79
+ bot_message = bot_message[last_response_start:]
80
  print(bot_message)
81
  return bot_message
82
  else:
83
  raise gr.Error("No response received from the model.")
84
+
85
  except Exception as e:
86
  error_msg = f"An error occurred: {str(e)}"
87
  raise gr.Error(error_msg)