MCPcopy
hub / github.com/algorithmicsuperintelligence/optillm / execute_single_approach

Function execute_single_approach

optillm/server.py:396–484  ·  view source on GitHub ↗
(approach, system_prompt, initial_query, client, model, request_config: dict = None, request_id: str = None)

Source from the content-addressed store, hash-verified

394 return operation, approaches, actual_model
395
396def execute_single_approach(approach, system_prompt, initial_query, client, model, request_config: dict = None, request_id: str = None):
397 if approach in known_approaches:
398 if approach == 'none':
399 # Use the request_config that was already prepared and passed to this function
400 kwargs = request_config.copy() if request_config else {}
401
402 # Remove items that are handled separately by the framework
403 # Note: 'n' is NOT removed - the none_approach passes it to the client which handles multiple completions
404 kwargs.pop('stream', None) # stream is handled by proxy()
405
406 # Reconstruct original messages from system_prompt and initial_query
407 messages = []
408 if system_prompt:
409 messages.append({"role": "system", "content": system_prompt})
410 if initial_query:
411 messages.append({"role": "user", "content": initial_query})
412
413 logger.debug(f"none_approach kwargs: {kwargs}")
414 response = none_approach(original_messages=messages, client=client, model=model, request_id=request_id, **kwargs)
415 # For none approach, we return the response and a token count of 0
416 # since the full token count is already in the response
417 return response, 0
418 elif approach == 'mcts':
419 return chat_with_mcts(system_prompt, initial_query, client, model, server_config['mcts_simulations'],
420 server_config['mcts_exploration'], server_config['mcts_depth'], request_config, request_id)
421 elif approach == 'bon':
422 return best_of_n_sampling(system_prompt, initial_query, client, model, server_config['best_of_n'], request_config, request_id)
423 elif approach == 'moa':
424 return mixture_of_agents(system_prompt, initial_query, client, model, request_config, request_id)
425 elif approach == 'rto':
426 return round_trip_optimization(system_prompt, initial_query, client, model, request_config, request_id)
427 elif approach == 'z3':
428 z3_solver = Z3SymPySolverSystem(system_prompt, client, model, request_config=request_config, request_id=request_id)
429 return z3_solver.process_query(initial_query)
430 elif approach == "self_consistency":
431 return advanced_self_consistency_approach(system_prompt, initial_query, client, model, request_config, request_id)
432 elif approach == "pvg":
433 return inference_time_pv_game(system_prompt, initial_query, client, model, request_config=request_config, request_id=request_id)
434 elif approach == "rstar":
435 rstar = RStar(system_prompt, client, model,
436 max_depth=server_config['rstar_max_depth'], num_rollouts=server_config['rstar_num_rollouts'],
437 c=server_config['rstar_c'], request_config=request_config, request_id=request_id)
438 return rstar.solve(initial_query)
439 elif approach == "cot_reflection":
440 return cot_reflection(system_prompt, initial_query, client, model, return_full_response=server_config['return_full_response'], request_config=request_config, request_id=request_id)
441 elif approach == 'plansearch':
442 return plansearch(system_prompt, initial_query, client, model, n=server_config['n'], request_config=request_config, request_id=request_id)
443 elif approach == 'leap':
444 return leap(system_prompt, initial_query, client, model, request_config, request_id)
445 elif approach == 're2':
446 return re2_approach(system_prompt, initial_query, client, model, n=server_config['n'], request_config=request_config, request_id=request_id)
447 elif approach == 'cepo':
448 return cepo(system_prompt, initial_query, client, model, cepo_config, request_id)
449 elif approach == 'mars':
450 return multi_agent_reasoning_system(system_prompt, initial_query, client, model, request_config=request_config, request_id=request_id)
451 elif approach in plugin_approaches:
452 # Check if the plugin accepts request_config
453 plugin_func = plugin_approaches[approach]

Callers 4

execute_n_timesFunction · 0.85
proxyFunction · 0.85
process_batch_requestsFunction · 0.85

Calls 15

process_queryMethod · 0.95
solveMethod · 0.95
chat_with_mctsFunction · 0.90
best_of_n_samplingFunction · 0.90
mixture_of_agentsFunction · 0.90
round_trip_optimizationFunction · 0.90
Z3SymPySolverSystemClass · 0.90
inference_time_pv_gameFunction · 0.90
RStarClass · 0.90
cot_reflectionFunction · 0.90
plansearchFunction · 0.90

Tested by

no test coverage detected