rootacess commited on
Commit
abe259c
β€’
1 Parent(s): 46cd95f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -47,18 +47,20 @@ def generate(query: str, temperature=0.9, max_new_tokens=256, top_p=0.95, repeti
47
  seed=42,
48
  )
49
 
50
- stream = client.generate_stream(prompt, **generate_kwargs)
51
- output = ""
52
-
53
- previous_token = ""
54
- for response in stream:
55
- if response.token.text == "<|endoftext|>":
56
- return output
57
- else:
58
- output += response.token.text
59
- previous_token = response.token.text
60
- yield output
61
- return output
 
 
62
 
63
 
64
  def process_example(**krwags):
 
47
  seed=42,
48
  )
49
 
50
+ try:
51
+ stream = client.generate_stream(prompt, **generate_kwargs)
52
+ output = ""
53
+ previous_token = ""
54
+ for response in stream:
55
+ if response.token.text == "<|endoftext|>":
56
+ return output
57
+ else:
58
+ output += response.token.text
59
+ previous_token = response.token.text
60
+ yield output
61
+ return output
62
+ except errors.UnknownError:
63
+ return "Please wait for a while, The OctoCoder model is currently loading... πŸ™"
64
 
65
 
66
  def process_example(**krwags):