Strvm / meta-ai-api

Llama 3 API 70B & 405B (MetaAI Reverse Engineered)
267 stars 50 forks source link

Exception: Unable to obtain a valid response from Meta AI. Try again later. #5

Closed tomnewg closed 6 months ago

tomnewg commented 7 months ago

Hi there,

I would like to to run a loop to send a few prompts. but already on the second item I get: Exception: Unable to obtain a valid response from Meta AI. Try again later.

Does this come because the API token is taken from the browser? Is there a way to do multiple requests?

Many thanks

Tom

Strvm commented 7 months ago

Hi, could you send an example of the code that is failing for you? Sometimes Meta does have issues on their end, so a retry system is in place (tries 3 times), before getting Unable to obtain a valid response from Meta AI. Try again later..

But trying to loop this seems to work on my side:

ai = MetaAI()
print(ai.prompt(message="Say this is a test #1"))
print(ai.prompt(message="Say this is a test #2"))
print(ai.prompt(message="Say this is a test #3"))
{'message': "Test #1 Passed! This is a test response from Meta AI. I'm here to help with any questions or tasks you have!\n", 'sources': []}
{'message': "Test #2 Passed! This is a test response to confirm that I'm working as expected. How can I assist you today?\n", 'sources': []}
{'message': "Test #3 Passed! This is a test, and I'm happy to report that everything is working as expected! If you have any questions or need assistance, feel free to ask!\n", 'sources': []}
tomnewg commented 7 months ago

here is an example code:

results = {}
for item in items:
    prompt_input = "Write a summary of {} in one paragraph.".format(item)
    response = ai.prompt(message=prompt_input)
    results[item] = response['message']
Strvm commented 7 months ago

Does it fail after the first attempt? Also can you confirm that you are able to use it on: https://www.meta.ai/

tomnewg commented 7 months ago

yes on https://www.meta.ai/ I can run multiple prompts in a row without any issue

Strvm commented 6 months ago

Hi, are you using the latest version of the API?

pip show meta-ai-api 
Name: meta_ai_api
Version: 1.1.2

I am able to run your code:

ai = MetaAI()
    results = {}
    items = ["apple", "banana", "cherry"]
    for item in items:
        prompt_input = "Write a summary of {} in one paragraph.".format(item)
        response = ai.prompt(message=prompt_input)
        results[item] = response['message']
    print(results)
{
   "apple":"Apple Inc. Summary\nApple Inc. is a multinational technology company headquartered in Cupertino, California. Founded in 1976 by Steve Jobs, Steve Wozniak, and Ronald Wayne, Apple is a pioneer in the personal computer revolution. The company is known for its innovative and sleek products, including the Macintosh computer, iPod, iPhone, and iPad, which have revolutionized the way people work, communicate, and access entertainment. Apple's software platforms, such as macOS, iOS, and watchOS, are renowned for their user-friendly interface and seamless integration with other Apple devices. Today, Apple is one of the world's largest and most successful companies, known for its commitment to innovation, design, and customer experience.\n",
   "banana":"Banana\nBanana is a long, curved fruit that grows in clusters at the top of a large plant with a soft, thick skin that is typically yellow in color. The flesh inside is soft, creamy, and sweet, with a stringy texture and a sweet, slightly tart taste. Bananas are a good source of potassium, vitamins C and B6, and dietary fiber, making them a nutritious and popular fruit for eating fresh, adding to smoothies, or using in baked goods and desserts. They are also relatively low in calories and have a convenient, portable shape, making them a popular snack for people on the go.\n",
   "cherry":"Cherry: A Sweet and Nutritious Fruit\nCherry is a small, round stone fruit with a sweet and slightly tart taste, typically red or yellow in color. It is a nutrient-dense food, rich in vitamins C and K, potassium, and antioxidants. Cherries are a good source of dietary fiber, and their juice has been shown to have anti-inflammatory properties. They are also a popular ingredient in various desserts, baked goods, and beverages, and are enjoyed fresh or dried as a healthy snack. Overall, cherries are a delicious and nutritious addition to a balanced diet.\n"
}
niknak6 commented 6 months ago

I think this is more or less the same issue I was having, invalid response received, in the issue that was closed. The issue persists, however. My code is similar enough and still getting invalid response on my side too.

Strvm commented 6 months ago

I think this is more or less the same issue I was having, invalid response received, in the issue that was closed. The issue persists, however. My code is similar enough and still getting invalid response on my side too.

When you mean invalid response you mean the dictionary/JSON isn’t valid? If so, could you send what you are getting that is considered not valid ?

tomnewg commented 6 months ago

image

I am getting this error image

Strvm commented 6 months ago

image

I am getting this error image

Is this being ran locally or inside a notebook online? If so, maybe an issue with that IP.

tomnewg commented 6 months ago

I run it locally with internet conection. And I tested two different computers in two different locations. I can run individual prompts. But even then, after running 3 or so individual ones I start to get this error.

Strvm commented 6 months ago

I run it locally with internet conection. And I tested two different computers in two different locations. I can run individual prompts. But even then, after running 3 or so individual ones I start to get this error.

I think I encountered the issue, re-generating the token after each request seems to help. Could you try again after updating the package please?

pip install meta-ai-api==1.1.4
tomnewg commented 6 months ago

yes it works! that is great. Thank you very much for the quick fix. Will play around with it and will let you know if I encounter anything else

Strvm commented 6 months ago

I'm still getting some retry errors from time to time but it seems to be doing a better job for now. I'll have to take a deeper look to see if I can make it even better. Happy to hear its working better for you now!