Joblib
English
llm
human-feedback
weak supervision
data filtering
Inference Endpoints
Christopher Glaze commited on
Commit
5038a86
1 Parent(s): cbc0f63

Update data contract

Browse files
Files changed (2) hide show
  1. handler.py +5 -8
  2. tests.py +3 -10
handler.py CHANGED
@@ -118,19 +118,18 @@ class EndpointHandler():
118
  return self.response_pipeline.predict_proba(df1)[:,1]
119
 
120
 
121
- def __call__(self, data: Dict[str, Union[Dict, List, pd.DataFrame]]):
122
 
123
  inputs = data['inputs']
124
 
125
  is_dict = isinstance(inputs, dict)
126
- is_list = isinstance(inputs, list)
127
 
128
  if is_dict:
129
  df = pd.DataFrame([inputs])
130
- elif is_list:
131
- df = pd.DataFrame(inputs)
132
  else:
133
- df = inputs
 
 
134
 
135
  if 'dataset' not in df.columns:
136
  df['dataset'] = ''
@@ -146,7 +145,5 @@ class EndpointHandler():
146
 
147
  if is_dict:
148
  return predictions[0]
149
- elif is_list:
150
- return predictions
151
  else:
152
- return pd.DataFrame(predictions, index=df.index)
 
118
  return self.response_pipeline.predict_proba(df1)[:,1]
119
 
120
 
121
+ def __call__(self, data: Dict[str, Union[Dict, List]]):
122
 
123
  inputs = data['inputs']
124
 
125
  is_dict = isinstance(inputs, dict)
 
126
 
127
  if is_dict:
128
  df = pd.DataFrame([inputs])
 
 
129
  else:
130
+ df = pd.DataFrame(inputs)
131
+
132
+ df = df.fillna('')
133
 
134
  if 'dataset' not in df.columns:
135
  df['dataset'] = ''
 
145
 
146
  if is_dict:
147
  return predictions[0]
 
 
148
  else:
149
+ return predictions
tests.py CHANGED
@@ -14,16 +14,9 @@ pred=response_model_handler(payload)
14
  print(pred)
15
 
16
  payload = {'inputs': [{"instruction": "What are some ways to stay energized throughout the day?",
17
- "response": "Drink lots of coffee!"}]*2}
18
-
19
- # test the handler
20
- pred=response_model_handler(payload)
21
-
22
- print(pred)
23
-
24
-
25
- payload = {'inputs': pd.DataFrame([{"instruction": "What are some ways to stay energized throughout the day?",
26
- "response": "Drink lots of coffee!"}]*2)}
27
 
28
  # test the handler
29
  pred=response_model_handler(payload)
 
14
  print(pred)
15
 
16
  payload = {'inputs': [{"instruction": "What are some ways to stay energized throughout the day?",
17
+ "response": "Drink lots of coffee!"},
18
+ {"instruction": "What are some ways to stay energized throughout the day?",
19
+ "response": "Buy lots of sailboats!"}]}
 
 
 
 
 
 
 
20
 
21
  # test the handler
22
  pred=response_model_handler(payload)