Main entry point for the Deep Think plugin. Combines SELF-DISCOVER reasoning structure discovery with uncertainty-routed chain-of-thought generation. Args: system_prompt: System prompt for the model initial_query: User's initial query/problem clien
(
system_prompt: str,
initial_query: str,
client,
model: str,
request_config: Dict[str, Any] = None
)
| 15 | logger = logging.getLogger(__name__) |
| 16 | |
| 17 | def run( |
| 18 | system_prompt: str, |
| 19 | initial_query: str, |
| 20 | client, |
| 21 | model: str, |
| 22 | request_config: Dict[str, Any] = None |
| 23 | ) -> Tuple[str, int]: |
| 24 | """ |
| 25 | Main entry point for the Deep Think plugin. |
| 26 | |
| 27 | Combines SELF-DISCOVER reasoning structure discovery with |
| 28 | uncertainty-routed chain-of-thought generation. |
| 29 | |
| 30 | Args: |
| 31 | system_prompt: System prompt for the model |
| 32 | initial_query: User's initial query/problem |
| 33 | client: OpenAI-compatible client instance |
| 34 | model: Model identifier |
| 35 | request_config: Additional configuration parameters |
| 36 | |
| 37 | Returns: |
| 38 | Tuple of (response_text, completion_tokens_used) |
| 39 | """ |
| 40 | logger.info("Starting Deep Think reasoning process") |
| 41 | |
| 42 | # Extract configuration parameters |
| 43 | config = _parse_config(request_config or {}) |
| 44 | |
| 45 | # Initialize components |
| 46 | self_discover = SelfDiscover( |
| 47 | client=client, |
| 48 | model=model, |
| 49 | max_tokens=config["max_tokens"], |
| 50 | request_config=request_config |
| 51 | ) |
| 52 | |
| 53 | uncertainty_cot = UncertaintyRoutedCoT( |
| 54 | client=client, |
| 55 | model=model, |
| 56 | max_tokens=config["max_tokens"], |
| 57 | request_config=request_config |
| 58 | ) |
| 59 | |
| 60 | total_tokens = 0 |
| 61 | |
| 62 | # Stage 1: SELF-DISCOVER reasoning structure (if enabled) |
| 63 | reasoning_structure = None |
| 64 | if config["enable_self_discover"]: |
| 65 | logger.info("Discovering task-specific reasoning structure") |
| 66 | |
| 67 | discovery_result = self_discover.discover_reasoning_structure( |
| 68 | task_description=_extract_task_description(initial_query, system_prompt), |
| 69 | task_examples=None # Could be enhanced to extract examples |
| 70 | ) |
| 71 | |
| 72 | reasoning_structure = discovery_result["reasoning_structure"] |
| 73 | total_tokens += discovery_result["completion_tokens"] |
| 74 |
nothing calls this directly
no test coverage detected