Relative Content

Tag Archive for pythonrequestopenai-apipyscript

Integrating OpenAI API into a Pyscript page – Requests keep timing out

I have a Pyscript page that searches a news archive and returns a list of news summaries. I want to then feed this list of summaries into gpt-4o and get back a brief summary of the material. The problem I’m encountering is that my request keeps timing out before anything can happen. Using the exact same request in a Jupyter notebook produced the desired results, so I’m thinking the problem might have something to do with Pyscript. After reading OpenAI forums, i tried setting timeout, but this had no effect. I suspect that OpenAI’s 600ms default timeout is being applied but I don’t know how to change this when importing the package. Notably, importing openai to my page required also importing ssl, and I think pyscript imports openssl, so maybe there’s a conflict? If you can see what I’m doing wrong or if there’s a better way to do my OpenAI request in Pyscript, I’d love to hear about it. Here’s the function doing the request: