Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify logic for deleting / archiving working copy of assistants #990

Open
snopoke opened this issue Dec 13, 2024 · 1 comment
Open

Clarify logic for deleting / archiving working copy of assistants #990

snopoke opened this issue Dec 13, 2024 · 1 comment

Comments

@snopoke
Copy link
Collaborator

snopoke commented Dec 13, 2024

I think the logic and conditions for deleting / archiving assistants needs to be revised / reviewed. I think there are cases where we should be cleaning up on openai where we aren't and perhaps visa version.

Initial thoughts:

  • don't delete if there are other usages (other experiments / pipeline nodes)

Local delete (archive)

  • archive self
  • archive versions
  • delete openai assistant for all versions

Hard delete:

  • Same as above but also delete working version from openai

See code:

  • class DeleteOpenAiAssistant(LoginAndTeamRequiredMixin, View, PermissionRequiredMixin):
    permission_required = "assistants.delete_openaiassistant"
    @transaction.atomic()
    def delete(self, request, team_slug: str, pk: int):
    assistant = get_object_or_404(OpenAiAssistant, team=request.team, pk=pk)
    if assistant.working_version_id is None and not assistant.is_archived:
    messages.warning(request, "Cannot delete a versioned assistant without first archiving.")
    return HttpResponse(status=400)
    try:
    delete_openai_assistant(assistant)
    except OpenAiSyncError as e:
    messages.error(request, f"Error deleting assistant from OpenAI: {e}")
    return HttpResponse(status=500)
    assistant.delete()
    messages.success(request, "Assistant Deleted")
    return HttpResponse()
    class LocalDeleteOpenAiAssistant(LoginAndTeamRequiredMixin, View, PermissionRequiredMixin):
    permission_required = "assistants.delete_openaiassistant"
    @transaction.atomic()
    def delete(self, request, team_slug: str, pk: int):
    assistant = get_object_or_404(OpenAiAssistant, team=request.team, pk=pk)
    assistant.archive()
    messages.success(request, "Assistant Archived")
    return HttpResponse()
  • better checks for when to delete assistant from openai #989
@snopoke snopoke converted this from a draft issue Dec 13, 2024
@snopoke
Copy link
Collaborator Author

snopoke commented Dec 13, 2024

I also noticed that if you try to delete an assistant is says you must archive it first (but there's no archive button - only a delete button which actually does archive).

If you archive it, then it is removed from the table and you can't access it again to delete it.

Edit: made some small fixes here: #991

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔖 Ready
Development

No branches or pull requests

1 participant