Add Optional parameter to load_session method
This commit is contained in:
parent
2a69254eda
commit
be83ffb0e7
1 changed files with 4 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
from langflow.interface.run import build_sorted_vertices
|
from langflow.interface.run import build_sorted_vertices
|
||||||
from langflow.services.base import Service
|
from langflow.services.base import Service
|
||||||
|
|
@ -14,14 +14,15 @@ class SessionService(Service):
|
||||||
def __init__(self, cache_service):
|
def __init__(self, cache_service):
|
||||||
self.cache_service: "BaseCacheService" = cache_service
|
self.cache_service: "BaseCacheService" = cache_service
|
||||||
|
|
||||||
async def load_session(self, key, data_graph):
|
async def load_session(self, key, data_graph: Optional[dict] = None):
|
||||||
# Check if the data is cached
|
# Check if the data is cached
|
||||||
if key in self.cache_service:
|
if key in self.cache_service:
|
||||||
return self.cache_service.get(key)
|
return self.cache_service.get(key)
|
||||||
|
|
||||||
if key is None:
|
if key is None:
|
||||||
key = self.generate_key(session_id=None, data_graph=data_graph)
|
key = self.generate_key(session_id=None, data_graph=data_graph)
|
||||||
|
if data_graph is None:
|
||||||
|
return (None, None)
|
||||||
# If not cached, build the graph and cache it
|
# If not cached, build the graph and cache it
|
||||||
graph, artifacts = await build_sorted_vertices(data_graph)
|
graph, artifacts = await build_sorted_vertices(data_graph)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue