JulesGM / ParlAI_SearchEngine

A search engine for ParlAI's BlenderBot project (and probably other ones as well)
Creative Commons Attribution 4.0 International
132 stars 48 forks source link

How do I call your server from the MacOS terminal linux command line? #2

Closed hitchingsh closed 3 years ago

hitchingsh commented 3 years ago

When trying to setup blenderbot2 with your search it does not seem to fetch the queries. On my Mac in the terminal window here's what I did:

$ git clone https://github.com/RodolfoFigueroa/ParlAI.git ./ParlAI $ git clone https://github.com/pytorch/fairseq ./fairseq $ pip install -r ./ParlAI/requirements.txt $ cd ParlAI/ $ python ./setup.py develop $ cd ../fairseq $ pip install --editable ./ $ cd .. $ git clone https://github.com/JulesGM/ParlAI_SearchEngine $ pip install -r ./ParlAI_SearchEngine/requirements.txt $ python ./ParlAI_SearchEngine/search_server.py serve --host 0.0.0.0:8080& $ parlai interactive --model-file zoo:blenderbot2/blenderbot2_400M/model --search-server http://0.0.0.0:8080

10:39:39 | Current ParlAI commit: ad57e5281de76ed42a378bdd2bcdef2fafc54ab8 Enter [DONE] if you want to end the episode, [EXIT] to quit. 10:39:39 | creating task(s): interactive Enter Your Message: Who went into space this week? blenderbot2/lib/python3.7/site-packages/torch/_tensor.py:575: UserWarning: floor_divide is deprecated, and will be removed in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor'). (Triggered internally at ../aten/src/ATen/native/BinaryOps.cpp:467.) return torch.floor_divide(self, other)

[BlenderBot2Fid]: I'm not sure, but I'm pretty sure it was Elon Musk. _POTENTIALLY_UNSAFE__ Enter Your Message: who won the superbowl this year [BlenderBot2Fid]: I don't think Elon Musk has ever been to space, but it would be cool if he did. Enter Your Message: [BlenderBot2Fid]: That's a good question. I don't know who won the Super Bowl this year, though. Enter Your Message:

and when I try to curl I get the following error:

$ curl -X GET "http://0.0.0.0:8080?q=baseball" 127.0.0.1 - - [21/Jul/2021 10:32:34] code 501, message Unsupported method ('GET') 127.0.0.1 - - [21/Jul/2021 10:32:34] "GET /?q=baseball HTTP/1.1" 501 - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

Error response

Error response

Error code: 501

Message: Unsupported method ('GET').

Error code explanation: HTTPStatus.NOT_IMPLEMENTED - Server does not support this operation.

any help would be appreciated. Thank you.

JulesGM commented 3 years ago

The server is in POST

JulesGM commented 3 years ago

The following works for me:

curl -X POST "http://0.0.0.0:8080" -d "q=baseball&n=5"
hitchingsh commented 3 years ago

@JulesGM - Thank you very much that worked! Adding the command line call to the README would be super helpful.

On the Mac to get your API to work when getting a certificate error I had to go to the Applications/Python3.7 directory and click on the file: InstallCertificates.command. I know this is not your issue and does seem like it might be basic but still might be a helpful tip for others.

Also, once I installed blenderbot2 I also had to do the following to get your search server to parse the HTML files returned to blenderbot2:

pip install bs4 pip install html5lib pip install lxml

Thanks again!

JulesGM commented 3 years ago

I added the command to the README. I added html5lib and lxml to the requirements.txt file.

JulesGM commented 3 years ago

Thanks!

hitchingsh commented 3 years ago

Awesome!