Getting KeyError: 'PORT1' Lecture 2 notebook

While running cell as a local notebook

import gradio as gr
def summarize(input):
output = get_completion(input)
return output[0][‘summary_text’]

gr.close_all()
demo = gr.Interface(fn=summarize, inputs=“text”, outputs=“text”)
demo.launch(share=True, server_port=int(os.environ[‘PORT1’]))

Please help

Hi @bolt

Welcome to the community.

If you are running locally, you have to download all the files attached on the course platform in order to get it work.

Hi @nshivani

If you are running locally you have to download all the files attached on the course platform to get it work.

You can do that by following:

Click on the jupyter logo at the top

Choose the file:

Then, on the new tab, click on “Files” and “Download”
image

The screenshots above is from another course. So, take it just as reference.

Another important thing to notice is that you have to install all the packages related by your own.

Best regards
elirod

1 Like

Thank you for your prompt response. There was no other file to download.

Question was related to notebook “L1_NLP_tasks_with_a_simple_interface” under Lecture 2 of “Building Generative AI Applications with Gradio”.

I found using commenting out server_port makes it work:

demo.launch(share=True) # , server_port=int(os.environ[‘PORT1’]))

It picks up Port on its own.

However, getting public url to share is a problem from local but not if run from colab.

Please help join these missing links together. It looks like colab is a good place to run this notebook rather than at local.

Also please advise any speed up possible for inferencing if GPU is used. In which case any different code to run?

Help put these pieces together.
Thank you

So sorry, didn’t get it. What are you mean about? “getting public url to share is a problem from local but not if run from colab”

I could get url that gradio provides to share for 3 days while running it at colab by setting share_url=True

But can’t get the link while running from local. Get this message:

Running on local URL: http://127.0.0.1:xxxx Could not create share link. Please check your internet connection or our status page: https://status.gradio.app.

Cannot open status.gradio.app either. Get this error from browser:

This site can’t provide a secure connection

status.gradio.app. sent an invalid response.

  • [Try running Windows Network Diagnostics](javascript:diagnoseErrors()).

ERR_SSL_PROTOCOL_ERROR

Hope it clarifies

Thanks! I got it now.

What version of gradio are you using?

Version: 3.43.2

Also I think the notebook has some security features that does not allow easy download like other notebooks. And when logging out at local it gives ‘forbidden’ message and I cannot access the root directory at notebook server. I have to start it on another browser window.

Don’t know if it is relevant. Just observations I had

Thank you for your time

1 Like

i found a issue regards this error on the gradio repository. Not really sure if it is a problem with your version.

Never the less, try to install gevent by running pip install gevent==22.10.2 and let me know the results.

OK. Thank you.
Will do

1 Like

I might be a firewall problem as well.

You can try this if you are using a windows 11 OS:

1 Like