Aityz commited on
Commit
d487dbb
1 Parent(s): 1c340be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -12,7 +12,13 @@ def generate(instruction, input = None, maxtokens: int = 20):
12
  ln = f'Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: {instruction} ### Response:'
13
  inputs = tokenizer(ln, return_tensors="pt")
14
  output = model.generate(inputs=inputs['input_ids'], max_new_tokens=maxtokens)
15
- return tokenizer.decode(output[0].tolist())
 
 
 
 
 
 
16
 
17
- inter = gr.Interface(fn=generate, inputs=["textbox", "textbox", gr.Slider(1, 1000, value=100)], outputs="textbox")
18
  inter.launch(share=False)
 
12
  ln = f'Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: {instruction} ### Response:'
13
  inputs = tokenizer(ln, return_tensors="pt")
14
  output = model.generate(inputs=inputs['input_ids'], max_new_tokens=maxtokens)
15
+ if input is not None:
16
+ inputlength = len(input)
17
+ if input is None:
18
+ inputlength = 0
19
+ length = len(instruction) + inputlength + 154
20
+ res = tokenizer.decode(output[0].tolist())
21
+ return res[length:]
22
 
23
+ inter = gr.Interface(fn=generate, inputs=["textbox", "textbox", gr.Slider(1, 1000, value=20)], outputs="textbox")
24
  inter.launch(share=False)