fromjinaimportClient, Documentfromjina.types.requestimportResponsedefprint_matches(resp: Response): # the callback function invoked when task is doneforidx, dinenumerate(resp.docs[0].matches[:3]): # print top-3 matchesprint(f'[{idx}]{d.scores["euclid"].value:2f}: "{d.text}"')
c=Client(protocol='http', port_expose=12345) # connect to localhost:12345c.post('/search', Document(text='request(on=something)'), on_done=print_matches)
,它打印以下结果:
Client@1608[S]:connected to the gateway at localhost:12345!
[0]0.168526: "@requests(on='/index')"
[1]0.181676: "@requests(on='/search')"
[2]0.192049: "query.matches = [Document(self._docs[int(idx)], copy=True, score=d) for idx, d in enumerate(dist)]"
$ uvicorn main:app --reloadINFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)INFO: Started reloader process [28720]INFO: Started server process [28722]INFO: Waiting for application startup.INFO: Application startup complete.
Check out https://docs.djangoproject.com/en/dev/internals/contributing/ for
information about getting involved.
要运行Django的测试套件,请执行以下操作:
Follow the instructions in the “Unit tests” section of docs/internals/contributing/writing-code/unit-tests.txt, published online at
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/#running-the-unit-tests