Aassistants Bug | Automatically Creating Multiple

I’m not sure what happened with my account.

Aassistants are automatically creating multiple entries per minute.

How can I delete them? I can’t delete them manually.

You need to immediately stop any processes you are running with Assistants and re-evaluate the code.

It seems like you are creating an assistant on each message instead of using the existing one.

2 Likes

Thank you for your comment.

I have stopped everything I suspected. In fact, I am just getting familiar with Assistants and currently have almost no active processes.

Could you share your code? Maybe we can spot something going on here

I don’t have any code
I’m just getting started with Assistants.

As you mentioned, it seems that I mistakenly set it to create an Assistant on each message. Right now, I’m trying to delete it, but there are too many to delete.

You can use this code to delete all your assistants.

from openai import OpenAI
client = OpenAI()

while True:
    assistants = client.beta.assistants.list(
        limit=100
    ).data

    if len(assistants) == 0:
        break
    
    for assistant in assistants:
        print(f"Deleting assistant {assistant.id}")
        res = client.beta.assistants.delete(assistant.id)
        if not res["deleted"]:
            raise Exception("Failed to delete assistant")
            
print("All assistants deleted!")

In the case you want to keep a number of assistant you can use this code and add the IDs to saved_ids.

from openai import OpenAI
client = OpenAI()

saved_ids = ["asst_blahblahblah"]

while True:
    assistants = client.beta.assistants.list(
        limit=100
    ).data

    if len(assistants) <= len(saved_ids):
        break
    
    for assistant in assistants:
        if assistant.id in saved_ids:
            print(f"Skipping assistant {assistant.id}")
            continue
        print(f"Deleting assistant {assistant.id}")
        res = client.beta.assistants.delete(assistant.id)
        if not res["deleted"]:
            raise Exception("Failed to delete assistant")
            
print("All assistants deleted!")

If you run into any errors regarding the API key please follow this guide to getting started:

https://platform.openai.com/docs/quickstart

2 Likes

Thank you so much. I will try it.

Currently, I can’t log in to platform .openai.com

My account appears to be temporarily locked :slightly_frowning_face:

Yikes. What makes you say that? Does it say that your account is locked? Or is the page just not loading?

You are my hero.
The code worked exceptionally well.
Based on that code, I was also able to delete the file in the ‘Vector stores’.
Thank you so muchhhh

1 Like