Skip to content

Commit

Permalink
fix Codacy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
GoGoJoestar committed Jul 4, 2023
1 parent 98907d4 commit 58d1020
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions scripts/inference/gradio_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,8 @@ def gentask():
ret = self.mfunc(callback=_callback, **self.kwargs)
except ValueError:
pass
except:
except Exception as e:

Check warning on line 175 in scripts/inference/gradio_demo.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/inference/gradio_demo.py#L175

Unused variable 'e'

Check notice on line 175 in scripts/inference/gradio_demo.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/inference/gradio_demo.py#L175

local variable 'e' is assigned to but never used (F841)
traceback.print_exc()
pass

clear_torch_cache()
self.q.put(self.sentinel)
Expand Down Expand Up @@ -235,7 +234,6 @@ def predict(
prompt = generate_prompt(input)
inputs = tokenizer(prompt, return_tensors="pt")
input_ids = inputs["input_ids"].to(device)
original_size = len(input_ids[0])

generate_params = {
'input_ids': input_ids,
Expand Down Expand Up @@ -266,7 +264,7 @@ def generate_with_streaming(**kwargs):
break
new_tokens = tokenizer.decode(
next_token_ids, skip_special_tokens=True)
if type(tokenizer) is LlamaTokenizer and len(next_token_ids) > 0:
if isinstance(tokenizer, LlamaTokenizer) and len(next_token_ids) > 0:
if tokenizer.convert_ids_to_tokens(int(next_token_ids[0])).startswith('▁'):
new_tokens = ' ' + new_tokens

Expand Down

0 comments on commit 58d1020

Please sign in to comment.