@@ -248,7 +248,7 @@ def _convert_from_v1_to_chat_completions(message: AIMessage) -> AIMessage:
248248 if block_type == "text" :
249249 # Strip annotations
250250 new_content .append ({"type" : "text" , "text" : block ["text" ]})
251- elif block_type in ( "reasoning" , "tool_call" ) :
251+ elif block_type in { "reasoning" , "tool_call" } :
252252 pass
253253 else :
254254 new_content .append (block )
@@ -706,8 +706,6 @@ def _iter_blocks() -> Iterable[types.ContentBlock]:
706706 if invalid_tool_call .get ("id" ) == call_id :
707707 tool_call_block = invalid_tool_call .copy ()
708708 break
709- else :
710- pass
711709 if tool_call_block :
712710 if "id" in block :
713711 if "extras" not in tool_call_block :
@@ -735,7 +733,7 @@ def _iter_blocks() -> Iterable[types.ContentBlock]:
735733 k : v for k , v in block ["action" ].items () if k != "sources"
736734 }
737735 for key in block :
738- if key not in ( "type" , "id" , "action" , "status" , "index" ) :
736+ if key not in { "type" , "id" , "action" , "status" , "index" } :
739737 web_search_call [key ] = block [key ]
740738
741739 yield cast ("types.ServerToolCall" , web_search_call )
@@ -761,8 +759,6 @@ def _iter_blocks() -> Iterable[types.ContentBlock]:
761759 web_search_result ["status" ] = "success"
762760 elif status :
763761 web_search_result ["extras" ] = {"status" : status }
764- else :
765- pass
766762 if "index" in block and isinstance (block ["index" ], int ):
767763 web_search_result ["index" ] = f"lc_wsr_{ block ['index' ] + 1 } "
768764 yield cast ("types.ServerToolResult" , web_search_result )
@@ -778,14 +774,14 @@ def _iter_blocks() -> Iterable[types.ContentBlock]:
778774 file_search_call ["index" ] = f"lc_fsc_{ block ['index' ]} "
779775
780776 for key in block :
781- if key not in (
777+ if key not in {
782778 "type" ,
783779 "id" ,
784780 "queries" ,
785781 "results" ,
786782 "status" ,
787783 "index" ,
788- ) :
784+ } :
789785 file_search_call [key ] = block [key ]
790786
791787 yield cast ("types.ServerToolCall" , file_search_call )
@@ -804,8 +800,6 @@ def _iter_blocks() -> Iterable[types.ContentBlock]:
804800 file_search_result ["status" ] = "success"
805801 elif status :
806802 file_search_result ["extras" ] = {"status" : status }
807- else :
808- pass
809803 if "index" in block and isinstance (block ["index" ], int ):
810804 file_search_result ["index" ] = f"lc_fsr_{ block ['index' ] + 1 } "
811805 yield cast ("types.ServerToolResult" , file_search_result )
@@ -849,8 +843,6 @@ def _iter_blocks() -> Iterable[types.ContentBlock]:
849843 code_interpreter_result ["status" ] = "success"
850844 elif status :
851845 code_interpreter_result ["extras" ] = {"status" : status }
852- else :
853- pass
854846 if "index" in block and isinstance (block ["index" ], int ):
855847 code_interpreter_result ["index" ] = f"lc_cir_{ block ['index' ] + 1 } "
856848
0 commit comments