shuttleai / shuttleai-python

The official Python library for the ShuttleAI API
https://pypi.org/project/shuttleai/
MIT License
5 stars 2 forks source link

[BUG] #9

Closed phamxtien closed 4 months ago

phamxtien commented 4 months ago

On OS: Ubuntu 24.04 LST, Python3.12

I got error with below code:

from shuttleai import ShuttleAI

api_key = 'my api key'
base_url = 'https://api.shuttleai.app/v1'
model = 'my model'

def shuttleaiChat(prompt='hi', id=''):
    try:
        client = ShuttleAI(api_key=api_key, base_url=base_url)
        messages = [{"role": "user", "content": prompt}]        
        chat_completion = client.chat.completions.create(messages=messages, model=model)
        response = chat_completion.choices[0].message.content
        return response
    except Exception as e:
        return str(e)

It returns:

Status: 524. Message: <!DOCTYPE html>\n\n\n\n \n\n\n\napi.shuttleai.app | 524: A timeout occurred\n\n\n\n\n\n\n\n\n\n\n

\n
\n
\n

\n A timeout occurred\n Error code 524\n

\n
\n Visit cloudflare.com for more information.\n
\n
2024-06-29 12:50:09 UTC
\n
\n
\n
\n
\n \n
\n
\n \n \n \n \n
\n You\n

\n \n Browser\n \n

\n Working\n
\n\n
\n
\n \n \n \n \n
\n Hong Kong\n

\n \n Cloudflare\n \n

\n Working\n
\n\n
\n
\n \n \n \n \n
\n api.shuttleai.app\n

\n \n Host\n \n

\n Error\n
\n\n
\n
\n
\n\n
\n
\n
\n

What happened?

\n

The origin web server timed out responding to this request.

\n
\n
\n

What can I do?

\n

If you\'re a visitor of this website:

\n

Please try again in a few minutes.

\n\n

If you\'re the owner of this website:

\n

The connection to the origin web server was made, but the origin web server timed out before responding. The likely cause is an overloaded background task, database or application, stressing the resources on your web server. To resolve, please work with your hosting provider or web development team to free up resources for your database or overloaded application. Additional troubleshooting information here.

\n
\n
\n
\n\n \n\n\n
\n
\n\n\n

herumes commented 4 months ago

Hello, thank you for reporting the issue you encountered.

This seems to have been temporary and resolved.

Additionally, you may increase the timeout by passing "timeout=your new timeout here" when constructing the ShuttleAI client.

Let me know if there's any other issues or you have any questions, thank you for using ShuttleAI! 💙

(P.S be careful sending cloudflare errors in full like this, it typically contains your home network IP address that may be used maliciously by attackers! I have done you the favor of redacting the IP address in the error you provided.)

(P.P.S it is not recommended to create a new client on every request, although typically fine, you will receive great performance benefits by initiating a single ShuttleAI client and using that in your functions)

phamxtien commented 4 months ago

It seams the API can not pass cloudflare, it still returns 524 error code with timeout=2000

herumes commented 4 months ago

I am saddened to hear your experience. The API is working perfectly fine for me, please join our discord @ https://discord.gg/shuttleai for more support and assistance. We can discuss further there, my tag is @3thoth. I will be closing this issue as it is unrelated to the lib 💙