TMVishnu commited on
Commit
52b32be
·
verified ·
1 Parent(s): 752a022

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -67,16 +67,14 @@ def generate_text(prompt, max_tokens=50, temperature=0.8):
67
  probs = torch.nn.functional.softmax(logits, dim=-1)
68
  next_token = torch.multinomial(probs, num_samples=1)
69
  x = torch.cat([x, next_token], dim=1)
70
-
71
- if next_token.item() == tokenizer.eos_token_id:
72
- break
73
 
74
  output_tokens = x[0].tolist()
75
  output = tokenizer.decode(output_tokens)
76
  return output
77
 
78
  except Exception as e:
79
- return f"Error: {str(e)}"
 
80
 
81
  demo = gr.Interface(
82
  fn=generate_text,
 
67
  probs = torch.nn.functional.softmax(logits, dim=-1)
68
  next_token = torch.multinomial(probs, num_samples=1)
69
  x = torch.cat([x, next_token], dim=1)
 
 
 
70
 
71
  output_tokens = x[0].tolist()
72
  output = tokenizer.decode(output_tokens)
73
  return output
74
 
75
  except Exception as e:
76
+ import traceback
77
+ return f"Error: {str(e)}\n\n{traceback.format_exc()}"
78
 
79
  demo = gr.Interface(
80
  fn=generate_text,