Catmeow commited on
Commit
e33c78e
1 Parent(s): 1644e4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -16,11 +16,13 @@ def generate(text,the_model,max_length,temperature,repetition_penalty):
16
 
17
  def complete_with_gpt(text,context,the_model,max_length,temperature,repetition_penalty):
18
  # Use the last 50 characters of the text as context
19
- # text[:-context] +
20
  return generate(text[-context:],the_model,max_length,temperature,repetition_penalty)
21
 
22
  def send(text1,context,text2):
23
- return text1 + text2[context:]
 
 
 
24
 
25
  with gr.Blocks() as demo:
26
  textbox = gr.Textbox(placeholder="Type here and press enter...", lines=4)
 
16
 
17
  def complete_with_gpt(text,context,the_model,max_length,temperature,repetition_penalty):
18
  # Use the last 50 characters of the text as context
 
19
  return generate(text[-context:],the_model,max_length,temperature,repetition_penalty)
20
 
21
  def send(text1,context,text2):
22
+ if len(text1)<context:
23
+ return text1 + text2[len(text1):]
24
+ else:
25
+ return text1 + text2[context:]
26
 
27
  with gr.Blocks() as demo:
28
  textbox = gr.Textbox(placeholder="Type here and press enter...", lines=4)