AnyLlmClearConvo

Clears the current workspace conversation buffer stored in an XSOAR field and deletes the LLM's workspace conversation thread. The next question starts a new conversation thread with empty LLM context.

python · Anything LLM

Details

IDAnyLlmClearConvo
Languagepython
From Version6.10.0
Docker Imagedemisto/python3:3.12.8.3296088

README

Clears the current workspace conversation buffer stored in an XSOAR field and deletes the LLM’s workspace conversation thread. The next question starts a new conversation thread with empty LLM context.

Script Data


Name Description
Script Type python3

Inputs


There are no inputs for this script.

Outputs


There are no outputs for this script.

import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401


def main():
    try:
        inci = demisto.incident()["CustomFields"]
        t = inci.get("anythingllmcurthread", "")
        if t == "":
            threads = {}
        else:
            threads = json.loads(t)
        workspace = inci.get("anythingllmworkspace", "")
        thread = threads.get(workspace, "")
        if workspace != "" and thread != "":
            execute_command("anyllm-workspace-thread-delete", {"workspace": workspace, "thread": thread})
            threads[workspace] = ""
            execute_command(
                "setIncident", {"customFields": {"anythingllmconversation": "", "anythingllmcurthread": json.dumps(threads)}}
            )
    except Exception as ex:
        demisto.error(traceback.format_exc())
        return_error(f"AnyLlmClearConvo: error is - {ex}")


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()