|
12 | 12 | # limitations under the License. |
13 | 13 | # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. =========== |
14 | 14 | import os |
| 15 | +import warnings |
15 | 16 | from typing import Any, Dict, List, Optional, Union |
16 | 17 |
|
17 | 18 | from openai import OpenAI, Stream |
@@ -96,13 +97,23 @@ def run( |
96 | 97 | # o1-preview and o1-mini have Beta limitations |
97 | 98 | # reference: https://platform.openai.com/docs/guides/reasoning |
98 | 99 | if self.model_type in [ModelType.O1_MINI, ModelType.O1_PREVIEW]: |
| 100 | + warnings.warn( |
| 101 | + "Warning: You are using an O1 model (O1_MINI or O1_PREVIEW), " |
| 102 | + "which has certain limitations, reference: " |
| 103 | + "`https://platform.openai.com/docs/guides/reasoning`.", |
| 104 | + UserWarning, |
| 105 | + ) |
| 106 | + |
99 | 107 | # Remove system message that is not supported in o1 model. |
100 | 108 | messages = [msg for msg in messages if msg.get("role") != "system"] |
101 | 109 |
|
102 | | - # Remove unsupported parameters and reset the fixed parameters |
103 | | - del self.model_config_dict["stream"] |
104 | | - del self.model_config_dict["tools"] |
105 | | - del self.model_config_dict["tool_choice"] |
| 110 | + # Check and remove unsupported parameters and reset the fixed |
| 111 | + # parameters |
| 112 | + unsupported_keys = ["stream", "tools", "tool_choice"] |
| 113 | + for key in unsupported_keys: |
| 114 | + if key in self.model_config_dict: |
| 115 | + del self.model_config_dict[key] |
| 116 | + |
106 | 117 | self.model_config_dict["temperature"] = 1.0 |
107 | 118 | self.model_config_dict["top_p"] = 1.0 |
108 | 119 | self.model_config_dict["n"] = 1.0 |
|
0 commit comments