add method to feed a data point.
from typing import Optional, Dict, Tuple, List
from requests import post
from pandas import DataFrame
+from requests import post
from vespa.query import Query, VespaResult
from vespa.evaluation import EvalMetric
@@ -76,6 +77,21 @@ class Vespa(object):
r = post(self.search_end_point, json=body)
return VespaResult(vespa_result=r.json())
+ def feed_data_point(self, schema: str, data_id: str, fields: Dict):
+ """
+ Feed a data point to a Vespa app.
+
+ :param schema: The schema that we are sending data to.
+ :param data_id: Unique id associated with this data point.
+ :param fields: Dict containing all the fields required by the `schema`.
+ :return: Response of the HTTP POST request.
+ """
+ end_point = "{}/document/v1/{}/{}/docid/{}".format(
+ self.end_point, schema, schema, str(data_id)
+ )
+ response = post(end_point, json=fields)
+ return response
+
def collect_training_data_point(
self,
query: str,
