sid027 / dt1-23

1 stars 5 forks source link

Issue in the Flask application #10

Open sonjahuber1 opened 8 months ago

sonjahuber1 commented 8 months ago

The bubble app did not run after completing all the steps, i tested directly in the end point ( http://34.65.182.30:5000/chat?model_id=facebook/blenderbot-400M-distill&input=test ) and it showed an issue within the call_huggingface_chat_model function in the Flask application, specifically at the point where it tries to jsonify the response from the Hugging Face API.

To test the API I used a a curl command on my terminal, and it showed me the GTP generated answers.

so I also got a suggestion to update the main.py file, so i guess it is about the JSON responses in Flask. what would you recommend? is it possible to modify the responses without changing the main.py file?

sid027 commented 8 months ago

I do not think that you should need to update the main.py. Can you post the error please?

sonjahuber1 commented 8 months ago
Screenshot 2023-11-10 at 13 20 27

also there is a problem with mixed content, even though i have the Allow CORS running and i changed security settings. (also the latest version of chrome has removed the option to allow mixed content)

e-kartofel commented 8 months ago

Solved in Teams: image Although this solution requires the user to perform a complex setting operation in their browser, it is specified like this in the Assignment specs. image

Please @sid027 close the threat if the solution is good.

margohasi commented 8 months ago

@sonjahuber1 Did you solve this issue? I have the same problem with CORS Policy and I have allowed mixed content. I don't know how to solve this issue.

sonjahuber1 commented 8 months ago

unfortunately not, @margohasi could you share if you find a solution please?

margohasi commented 8 months ago

@sonjahuber1 I think it is because of Mac Book Security. So there is a command where you can type into your local terminal to deactivate all the browser settings (dylan helped me with this command):

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-web-security --user-data-dir="/Users/margauxhasler/GitHub/ChromeDevSession"

-> but ask ChatGPT how to use it. Because it really exposes you to security issues: _"Make sure that no instances of Chrome are currently running before executing this command, as it may not work if there's already an open instance.

Here are step-by-step instructions:

Open Terminal: You can find the Terminal application in the Applications/Utilities folder, or you can search for it using Spotlight (Cmd + Space and type "Terminal").

Execute the Command: Copy and paste the command into your Terminal window and press Enter.

New Chrome Instance: Chrome should open a new window with web security disabled. This allows you to bypass CORS policy for local development purposes.

Close Chrome When Done: When you're finished with your development work, make sure to close this Chrome instance to prevent security risks. You can close it like any other application, using Cmd + Q.

Security Warning: Running Chrome with web security disabled is risky and should only be done when absolutely necessary and only for development purposes. Do not browse the internet with this Chrome instance, as it could expose you to security threats. Always use a secure, regular instance of Chrome for all other web browsing."_ ChatGPT

sid027 commented 8 months ago

13

joshlevent commented 8 months ago
Screenshot 2023-11-10 at 13 20 27

also there is a problem with mixed content, even though i have the Allow CORS running and i changed security settings. (also the latest version of chrome has removed the option to allow mixed content)

I think the “mixed content” warning is not the issue. If you enabled it in your browser security settings you can ignore the yellow warning. You have two error messages: "net::ERR_CONNECTION_REFUSED” and "TypeError:”. The first is an issue with your server, possibly with the firewall not allowing the connection on the port you want. The second issue looks like a javascript error, I think the javascript code is not quite working yet. I would try to diagnose these issues separately by connection to your server using the command-line or a tool like postman, until you can solve the connection issue. Then you can focus on getting the javascript in bubble to work.

joshlevent commented 8 months ago

Sid just tested your server and it looks like the docker is crashing. You’ll need to fix something in the docker.

Here is the error message. The last part indicates that the output from the hugging face model is not a list which is not being handled well. Actually it sort of doesn’t matter, because as long as you didn’t change the docker code, there is something wrong with the way the docker is deployed. You may need to try deploying the docker from scratch.

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1478, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1458, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1455, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 869, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 867, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 852, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/app/main.py", line 33, in call_huggingface_chat_model
    output = jsonify({"ack": data[0]["generated_text"]})
KeyError: 0

When you deploy your docker again, test it first using curl, before attempting to connect to it from the front-end.