OzTianlu commited on
Commit
937e44a
·
verified ·
1 Parent(s): ef1f16d

Upload handler.py

Browse files
Files changed (1) hide show
  1. handler.py +8 -1
handler.py CHANGED
@@ -101,11 +101,18 @@ class EndpointHandler:
101
 
102
  if _is_messages(item):
103
  # Chat template path exists in repo; tokenizer.apply_chat_template will use it if configured
104
- input_ids = self.tokenizer.apply_chat_template(
105
  item,
106
  return_tensors="pt",
107
  add_generation_prompt=True,
108
  )
 
 
 
 
 
 
 
109
  else:
110
  if not isinstance(item, str):
111
  item = str(item)
 
101
 
102
  if _is_messages(item):
103
  # Chat template path exists in repo; tokenizer.apply_chat_template will use it if configured
104
+ result = self.tokenizer.apply_chat_template(
105
  item,
106
  return_tensors="pt",
107
  add_generation_prompt=True,
108
  )
109
+ # Handle both single tensor and tuple/dict returns
110
+ if isinstance(result, dict):
111
+ input_ids = result["input_ids"]
112
+ elif isinstance(result, tuple):
113
+ input_ids = result[0]
114
+ else:
115
+ input_ids = result
116
  else:
117
  if not isinstance(item, str):
118
  item = str(item)