Add session_id_generator and compute_dict_hash
functions
This commit is contained in:
parent
1c27cd484b
commit
1a302fbba9
1 changed files with 12 additions and 0 deletions
|
|
@ -1,6 +1,18 @@
|
|||
import hashlib
|
||||
import random
|
||||
import string
|
||||
|
||||
from langflow.services.cache.utils import filter_json
|
||||
from langflow.services.database.models.base import orjson_dumps
|
||||
|
||||
|
||||
def session_id_generator(size=6):
|
||||
return "".join(random.SystemRandom().choices(string.ascii_uppercase + string.digits, k=size))
|
||||
|
||||
|
||||
def compute_dict_hash(graph_data):
|
||||
graph_data = filter_json(graph_data)
|
||||
|
||||
cleaned_graph_json = orjson_dumps(graph_data, sort_keys=True)
|
||||
|
||||
return hashlib.sha256(cleaned_graph_json.encode("utf-8")).hexdigest()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue