@@ -123,37 +123,38 @@ def proxy():
123123
124124
125125 logger .info (f'Using approach { approach } , with { model } ' )
126+ completion_tokens = 0
126127
127128 try :
128129 if approach == 'mcts' :
129- final_response = chat_with_mcts (system_prompt , initial_query , client , model , server_config ['mcts_simulations' ],
130+ final_response , completion_tokens = chat_with_mcts (system_prompt , initial_query , client , model , server_config ['mcts_simulations' ],
130131 server_config ['mcts_exploration' ], server_config ['mcts_depth' ])
131132 elif approach == 'bon' :
132- final_response = best_of_n_sampling (system_prompt , initial_query , client , model , server_config ['best_of_n' ])
133+ final_response , completion_tokens = best_of_n_sampling (system_prompt , initial_query , client , model , server_config ['best_of_n' ])
133134 elif approach == 'moa' :
134- final_response = mixture_of_agents (system_prompt , initial_query , client , model )
135+ final_response , completion_tokens = mixture_of_agents (system_prompt , initial_query , client , model )
135136 elif approach == 'rto' :
136- final_response = round_trip_optimization (system_prompt , initial_query , client , model )
137+ final_response , completion_tokens = round_trip_optimization (system_prompt , initial_query , client , model )
137138 elif approach == 'z3' :
138139 z3_solver = Z3SolverSystem (system_prompt , client , model )
139- final_response = z3_solver .process_query (initial_query )
140+ final_response , completion_tokens = z3_solver .process_query (initial_query )
140141 elif approach == "self_consistency" :
141- final_response = advanced_self_consistency_approach (system_prompt , initial_query , client , model )
142+ final_response , completion_tokens = advanced_self_consistency_approach (system_prompt , initial_query , client , model )
142143 elif approach == "pvg" :
143- final_response = inference_time_pv_game (system_prompt , initial_query , client , model )
144+ final_response , completion_tokens = inference_time_pv_game (system_prompt , initial_query , client , model )
144145 elif approach == "rstar" :
145146 rstar = RStar (system_prompt , client , model ,
146147 max_depth = server_config ['rstar_max_depth' ], num_rollouts = server_config ['rstar_num_rollouts' ],
147148 c = server_config ['rstar_c' ])
148- final_response = rstar .solve (initial_query )
149+ final_response , completion_tokens = rstar .solve (initial_query )
149150 elif approach == "cot_reflection" :
150- final_response = cot_reflection (system_prompt , initial_query , client , model , return_full_response = server_config ['return_full_response' ])
151+ final_response , completion_tokens = cot_reflection (system_prompt , initial_query , client , model , return_full_response = server_config ['return_full_response' ])
151152 elif approach == 'plansearch' :
152- final_response = plansearch (system_prompt , initial_query , client , model , n = n )
153+ final_response , completion_tokens = plansearch (system_prompt , initial_query , client , model , n = n )
153154 elif approach == 'leap' :
154- final_response = leap (system_prompt , initial_query , client , model )
155+ final_response , completion_tokens = leap (system_prompt , initial_query , client , model )
155156 elif approach == 're2' :
156- final_response = re2_approach (system_prompt , initial_query , client , model , n = n )
157+ final_response , completion_tokens = re2_approach (system_prompt , initial_query , client , model , n = n )
157158 else :
158159 raise ValueError (f"Unknown approach: { approach } " )
159160 except Exception as e :
@@ -162,7 +163,10 @@ def proxy():
162163
163164 response_data = {
164165 'model' : model ,
165- 'choices' : []
166+ 'choices' : [],
167+ 'usage' : {
168+ 'completion_tokens' : completion_tokens ,
169+ }
166170 }
167171
168172 if isinstance (final_response , list ):
0 commit comments