File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed 
lib/ruby_llm/providers/openai Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,16 @@ def format_tool_calls(tool_calls)
4444          end 
4545        end 
4646
47+         def  parse_tool_call_arguments ( tool_call ) 
48+           arguments  =  tool_call . dig ( 'function' ,  'arguments' ) 
49+ 
50+           if  arguments . nil?  || arguments . empty? 
51+             { } 
52+           else 
53+             JSON . parse ( arguments ) 
54+           end 
55+         end 
56+ 
4757        def  parse_tool_calls ( tool_calls ,  parse_arguments : true ) 
4858          return  nil  unless  tool_calls &.any? 
4959
@@ -54,12 +64,7 @@ def parse_tool_calls(tool_calls, parse_arguments: true)
5464                id : tc [ 'id' ] , 
5565                name : tc . dig ( 'function' ,  'name' ) , 
5666                arguments : if  parse_arguments 
57-                              if  tc . dig ( 'function' ,  'arguments' ) . empty? 
58-                                { } 
59-                              else 
60-                                JSON . parse ( tc . dig ( 'function' , 
61-                                                  'arguments' ) ) 
62-                              end 
67+                              parse_tool_call_arguments ( tc ) 
6368                           else 
6469                             tc . dig ( 'function' ,  'arguments' ) 
6570                           end 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments