WinterGYC commited on
Commit
a1c6298
1 Parent(s): 25f60a6

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +8 -8
handler.py CHANGED
@@ -1,11 +1,11 @@
1
  import torch
2
  from typing import Dict, List, Any
3
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
 
4
 
5
  # get dtype
6
  dtype = torch.bfloat16 if torch.cuda.get_device_capability()[0] == 8 else torch.float16
7
 
8
-
9
  class EndpointHandler:
10
  def __init__(self, path=""):
11
  # load the model
@@ -23,15 +23,15 @@ class EndpointHandler:
23
  prediction = self.pipeline(inputs, **parameters)
24
  else:
25
  prediction = self.pipeline(inputs)
26
- print("---start---")
27
- print(prediction)
28
- print("---end---")
29
 
30
  # ignoring parameters! Default to configs in generation_config.json.
31
  messages = [{"role": "user", "content": data}]
32
  response = self.model.chat(self.tokenizer, messages)
33
- print("---start chat response---")
34
- print(response)
35
- print("---end chat response---")
36
 
37
- return [{'generated_text': response}]
 
1
  import torch
2
  from typing import Dict, List, Any
3
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
4
+ import logging
5
 
6
  # get dtype
7
  dtype = torch.bfloat16 if torch.cuda.get_device_capability()[0] == 8 else torch.float16
8
 
 
9
  class EndpointHandler:
10
  def __init__(self, path=""):
11
  # load the model
 
23
  prediction = self.pipeline(inputs, **parameters)
24
  else:
25
  prediction = self.pipeline(inputs)
26
+ logging.warn("---start---")
27
+ logging.warn(prediction)
28
+ logging.warn("---end---")
29
 
30
  # ignoring parameters! Default to configs in generation_config.json.
31
  messages = [{"role": "user", "content": data}]
32
  response = self.model.chat(self.tokenizer, messages)
33
+ logging.warn("---start chat response---")
34
+ logging.warn(response)
35
+ logging.warn("---end chat response---")
36
 
37
+ return [[{response: 1.0}]]