nvinay1803 commited on
Commit
f85115e
·
verified ·
1 Parent(s): 6069f5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -56,14 +56,22 @@ model_name = "tiiuae/falcon-7b-instruct"
56
  tokenizer = AutoTokenizer.from_pretrained(model_name)
57
 
58
 
59
- class ContentHandler(HuggingFaceEndpoint.ContentHandler):
60
- content_type = "application/json"
61
- accepts = "application/json"
62
- len_prompt = 0
63
 
64
  def transform_input(self, prompt: str, model_kwargs: Dict) -> bytes:
65
  self.len_prompt = len(prompt)
66
- input_str = json.dumps({"inputs": prompt, "parameters": {"max_new_tokens": 100, "stop": ["Human:"], "do_sample": False, "repetition_penalty": 1.1}})
 
 
 
 
 
 
 
 
67
  return input_str.encode('utf-8')
68
 
69
  def transform_output(self, output: bytes) -> str:
 
56
  tokenizer = AutoTokenizer.from_pretrained(model_name)
57
 
58
 
59
+ class ContentHandler(HuggingFaceEndpoint.CallbackHandler):
60
+ def __init__(self, model_name):
61
+ self.model_name = model_name
62
+ self.len_prompt = 0
63
 
64
  def transform_input(self, prompt: str, model_kwargs: Dict) -> bytes:
65
  self.len_prompt = len(prompt)
66
+ input_str = json.dumps({
67
+ "inputs": prompt,
68
+ "parameters": {
69
+ "max_new_tokens": 100,
70
+ "stop": ["Human:"],
71
+ "do_sample": False,
72
+ "repetition_penalty": 1.1
73
+ }
74
+ })
75
  return input_str.encode('utf-8')
76
 
77
  def transform_output(self, output: bytes) -> str: