39
39
PIPELINE_MODULES = {}
40
40
PIPELINE_NAMES = {}
41
41
42
- #Add GLOBAL_LOG_LEVEL for Pipeplines
43
- log_level = os .getenv (' GLOBAL_LOG_LEVEL' , ' INFO' ).upper ()
42
+ # Add GLOBAL_LOG_LEVEL for Pipeplines
43
+ log_level = os .getenv (" GLOBAL_LOG_LEVEL" , " INFO" ).upper ()
44
44
logging .basicConfig (level = LOG_LEVELS [log_level ])
45
45
46
46
@@ -694,7 +694,6 @@ def stream_content():
694
694
messages = messages ,
695
695
body = form_data .model_dump (),
696
696
)
697
-
698
697
logging .info (f"stream:true:{ res } " )
699
698
700
699
if isinstance (res , str ):
@@ -708,18 +707,22 @@ def stream_content():
708
707
line = line .model_dump_json ()
709
708
line = f"data: { line } "
710
709
710
+ elif isinstance (line , dict ):
711
+ line = json .dumps (line )
712
+ line = f"data: { line } "
713
+
711
714
try :
712
715
line = line .decode ("utf-8" )
713
- except :
714
- pass
716
+ logging .info (f"stream_content:Generator:{ line } " )
715
717
716
- logging .info (f"stream_content:Generator:{ line } " )
718
+ if line .startswith ("data:" ):
719
+ yield f"{ line } \n \n "
720
+ else :
721
+ line = stream_message_template (form_data .model , line )
722
+ yield f"data: { json .dumps (line )} \n \n "
717
723
718
- if line .startswith ("data:" ):
719
- yield f"{ line } \n \n "
720
- else :
721
- line = stream_message_template (form_data .model , line )
722
- yield f"data: { json .dumps (line )} \n \n "
724
+ except :
725
+ pass
723
726
724
727
if isinstance (res , str ) or isinstance (res , Generator ):
725
728
finish_message = {
0 commit comments