|
|
|
|
@ -55,7 +55,8 @@ class PipelineGenerator(BaseAppGenerator):
|
|
|
|
|
streaming: Literal[True],
|
|
|
|
|
call_depth: int,
|
|
|
|
|
workflow_thread_pool_id: Optional[str],
|
|
|
|
|
) -> Mapping[str, Any] | Generator[Mapping | str, None, None] | None: ...
|
|
|
|
|
) -> Mapping[str, Any] | Generator[Mapping | str, None, None] | None:
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
@overload
|
|
|
|
|
def generate(
|
|
|
|
|
@ -69,7 +70,8 @@ class PipelineGenerator(BaseAppGenerator):
|
|
|
|
|
streaming: Literal[False],
|
|
|
|
|
call_depth: int,
|
|
|
|
|
workflow_thread_pool_id: Optional[str],
|
|
|
|
|
) -> Mapping[str, Any]: ...
|
|
|
|
|
) -> Mapping[str, Any]:
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
@overload
|
|
|
|
|
def generate(
|
|
|
|
|
@ -83,7 +85,8 @@ class PipelineGenerator(BaseAppGenerator):
|
|
|
|
|
streaming: bool,
|
|
|
|
|
call_depth: int,
|
|
|
|
|
workflow_thread_pool_id: Optional[str],
|
|
|
|
|
) -> Union[Mapping[str, Any], Generator[Mapping | str, None, None]]: ...
|
|
|
|
|
) -> Union[Mapping[str, Any], Generator[Mapping | str, None, None]]:
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
def generate(
|
|
|
|
|
self,
|
|
|
|
|
@ -199,6 +202,7 @@ class PipelineGenerator(BaseAppGenerator):
|
|
|
|
|
else:
|
|
|
|
|
# run in child thread
|
|
|
|
|
context = contextvars.copy_context()
|
|
|
|
|
|
|
|
|
|
@copy_current_request_context
|
|
|
|
|
def worker_with_context():
|
|
|
|
|
# Run the worker within the copied context
|
|
|
|
|
@ -240,6 +244,7 @@ class PipelineGenerator(BaseAppGenerator):
|
|
|
|
|
).model_dump() for document in documents
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def _generate(
|
|
|
|
|
self,
|
|
|
|
|
*,
|
|
|
|
|
@ -268,6 +273,7 @@ class PipelineGenerator(BaseAppGenerator):
|
|
|
|
|
:param streaming: is stream
|
|
|
|
|
:param workflow_thread_pool_id: workflow thread pool id
|
|
|
|
|
"""
|
|
|
|
|
print("jin ru la 1")
|
|
|
|
|
for var, val in context.items():
|
|
|
|
|
var.set(val)
|
|
|
|
|
|
|
|
|
|
@ -279,6 +285,7 @@ class PipelineGenerator(BaseAppGenerator):
|
|
|
|
|
saved_user = g._login_user
|
|
|
|
|
with flask_app.app_context():
|
|
|
|
|
# Restore user in new app context
|
|
|
|
|
print("jin ru la 2")
|
|
|
|
|
if saved_user is not None:
|
|
|
|
|
from flask import g
|
|
|
|
|
|
|
|
|
|
@ -306,6 +313,7 @@ class PipelineGenerator(BaseAppGenerator):
|
|
|
|
|
application_generate_entity=application_generate_entity,
|
|
|
|
|
workflow_thread_pool_id=workflow_thread_pool_id,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# new thread
|
|
|
|
|
worker_thread = threading.Thread(
|
|
|
|
|
target=worker_with_context
|
|
|
|
|
@ -506,6 +514,7 @@ class PipelineGenerator(BaseAppGenerator):
|
|
|
|
|
:param workflow_thread_pool_id: workflow thread pool id
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
print("jin ru la 3")
|
|
|
|
|
for var, val in context.items():
|
|
|
|
|
var.set(val)
|
|
|
|
|
from flask import g
|
|
|
|
|
|