jtl11 commited on
Commit
7632e39
·
verified ·
1 Parent(s): a6001dc

Upload folder using huggingface_hub

Browse files
__pycache__/handler.cpython-311.pyc CHANGED
Binary files a/__pycache__/handler.cpython-311.pyc and b/__pycache__/handler.cpython-311.pyc differ
 
handler.py CHANGED
@@ -49,13 +49,12 @@ class EndpointHandler():
49
 
50
  task = 'Given a web search query, retrieve relevant passages that answer the query'
51
 
52
- query = data.pop("query", None)
53
- documents = data.pop("documents", None)
54
 
55
- if query is None or documents is None:
56
  raise ValueError("query and documents are required.")
57
 
58
- pairs = [self.format_instruction(task, query, doc) for doc in documents]
59
 
60
  # Tokenize the input texts
61
  inputs = self.process_inputs(pairs)
 
49
 
50
  task = 'Given a web search query, retrieve relevant passages that answer the query'
51
 
52
+ inputs = data.pop("inputs", data)
 
53
 
54
+ if 'query' not in inputs or 'documents' not in inputs:
55
  raise ValueError("query and documents are required.")
56
 
57
+ pairs = [self.format_instruction(task, inputs['query'], doc) for doc in inputs['documents']]
58
 
59
  # Tokenize the input texts
60
  inputs = self.process_inputs(pairs)
test_handler.py CHANGED
@@ -4,13 +4,13 @@ from handler import EndpointHandler
4
  my_handler = EndpointHandler(path=".")
5
 
6
  # prepare sample payload
7
- payload = dict(
8
  query = "What is the capital of China?",
9
  documents = [
10
  "The capital of China is Beijing.",
11
  "Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun.",
12
  ],
13
- )
14
 
15
  # test the handler
16
  scores=my_handler(payload)
 
4
  my_handler = EndpointHandler(path=".")
5
 
6
  # prepare sample payload
7
+ payload = dict(inputs=dict(
8
  query = "What is the capital of China?",
9
  documents = [
10
  "The capital of China is Beijing.",
11
  "Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun.",
12
  ],
13
+ ))
14
 
15
  # test the handler
16
  scores=my_handler(payload)