| """ |
| Demonstration of fixed OpenAI model parameter handling |
| """ |
|
|
|
|
| def demo_model_parameter_selection(): |
| """Demonstrate how different models get different parameters""" |
|
|
| |
| OPENAI_REASONING_MODEL_PREFIXES = ( |
| |
| "o1-", |
| "o1", |
| "o3-", |
| "o3", |
| "o4-", |
| |
| "gpt-5-", |
| "gpt-5", |
| ) |
|
|
| def get_params_for_model(model_name, api_base="https://api.openai.com/v1"): |
| """Show what parameters would be used for each model""" |
| model_lower = str(model_name).lower() |
| is_openai_reasoning_model = ( |
| api_base == "https://api.openai.com/v1" |
| and model_lower.startswith(OPENAI_REASONING_MODEL_PREFIXES) |
| ) |
|
|
| if is_openai_reasoning_model: |
| return { |
| "type": "reasoning_model", |
| "uses": "max_completion_tokens", |
| "supports": ["reasoning_effort", "verbosity"], |
| "excludes": ["temperature", "top_p"], |
| } |
| else: |
| return { |
| "type": "standard_model", |
| "uses": "max_tokens", |
| "supports": ["temperature", "top_p"], |
| "excludes": [], |
| } |
|
|
| print("π§ OpenAI Model Parameter Selection Demo") |
| print("=" * 50) |
|
|
| test_models = [ |
| |
| ("o1-mini", "β
Reasoning"), |
| ("o1-preview", "β
Reasoning"), |
| ("o3-mini-2025-01-31", "β
Reasoning (with date)"), |
| ("gpt-5-nano", "β
Reasoning (GPT-5 series)"), |
| |
| ("gpt-4o-mini", "β Standard (not reasoning)"), |
| ("gpt-4o", "β Standard"), |
| ("gpt-4-turbo", "β Standard"), |
| ] |
|
|
| for model, description in test_models: |
| params = get_params_for_model(model) |
| print(f"\nπ Model: {model}") |
| print(f" Type: {description}") |
| print(f" Uses: {params['uses']}") |
| print(f" Supports: {', '.join(params['supports'])}") |
| if params["excludes"]: |
| print(f" Excludes: {', '.join(params['excludes'])}") |
|
|
| print("\n" + "=" * 50) |
| print("β
Fix successful! No more false positives/negatives.") |
|
|
|
|
| if __name__ == "__main__": |
| demo_model_parameter_selection() |
|
|