|
| 1 | +# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. ========= |
| 2 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +# you may not use this file except in compliance with the License. |
| 4 | +# You may obtain a copy of the License at |
| 5 | +# |
| 6 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +# |
| 8 | +# Unless required by applicable law or agreed to in writing, software |
| 9 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +# See the License for the specific language governing permissions and |
| 12 | +# limitations under the License. |
| 13 | +# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. ========= |
| 14 | +from __future__ import annotations |
| 15 | + |
| 16 | +from typing import Dict, Optional, Union |
| 17 | + |
| 18 | +from camel.configs.base_config import BaseConfig |
| 19 | + |
| 20 | + |
| 21 | +class AihubMixConfig(BaseConfig): |
| 22 | + r"""Defines the parameters for generating chat completions using the |
| 23 | + AihubMix API. |
| 24 | +
|
| 25 | + Args: |
| 26 | + temperature (float, optional): Sampling temperature to use, between |
| 27 | + :obj:`0` and :obj:`2`. Higher values make the output more random, |
| 28 | + while lower values make it more focused and deterministic. |
| 29 | + (default: :obj:`0.8`) |
| 30 | + max_tokens (int, optional): The maximum number of tokens to generate |
| 31 | + in the chat completion. The total length of input tokens and |
| 32 | + generated tokens is limited by the model's context length. |
| 33 | + (default: :obj:`1024`) |
| 34 | + top_p (float, optional): An alternative to sampling with temperature, |
| 35 | + called nucleus sampling, where the model considers the results of |
| 36 | + the tokens with top_p probability mass. So :obj:`0.1` means only |
| 37 | + the tokens comprising the top 10% probability mass are considered. |
| 38 | + (default: :obj:`1`) |
| 39 | + frequency_penalty (float, optional): Number between :obj:`-2.0` and |
| 40 | + :obj:`2.0`. Positive values penalize new tokens based on their |
| 41 | + existing frequency in the text so far, decreasing the model's |
| 42 | + likelihood to repeat the same line verbatim. |
| 43 | + (default: :obj:`0`) |
| 44 | + presence_penalty (float, optional): Number between :obj:`-2.0` and |
| 45 | + :obj:`2.0`. Positive values penalize new tokens based on whether |
| 46 | + they appear in the text so far, increasing the model's likelihood |
| 47 | + to talk about new topics. |
| 48 | + (default: :obj:`0`) |
| 49 | + stream (bool, optional): If True, partial message deltas will be sent |
| 50 | + as data-only server-sent events as they become available. |
| 51 | + (default: :obj:`False`) |
| 52 | + web_search_options (dict, optional): Search model's web search options, |
| 53 | + only supported by specific search models. |
| 54 | + (default: :obj:`None`) |
| 55 | + tools (list[FunctionTool], optional): A list of tools the model may |
| 56 | + call. Currently, only functions are supported as a tool. Use this |
| 57 | + to provide a list of functions the model may generate JSON inputs |
| 58 | + for. A max of 128 functions are supported. |
| 59 | + tool_choice (Union[dict[str, str], str], optional): Controls which (if |
| 60 | + any) tool is called by the model. :obj:`"none"` means the model |
| 61 | + will not call any tool and instead generates a message. |
| 62 | + :obj:`"auto"` means the model can pick between generating a |
| 63 | + message or calling one or more tools. :obj:`"required"` means the |
| 64 | + model must call one or more tools. Specifying a particular tool |
| 65 | + via {"type": "function", "function": {"name": "my_function"}} |
| 66 | + forces the model to call that tool. :obj:`"none"` is the default |
| 67 | + when no tools are present. :obj:`"auto"` is the default if tools |
| 68 | + are present. |
| 69 | + parallel_tool_calls (bool, optional): A parameter specifying whether |
| 70 | + the model should call tools in parallel or not. |
| 71 | + (default: :obj:`None`) |
| 72 | + extra_headers: Optional[Dict[str, str]]: Extra headers to use for the |
| 73 | + model. (default: :obj:`None`) |
| 74 | + """ |
| 75 | + |
| 76 | + temperature: Optional[float] = 0.8 |
| 77 | + max_tokens: Optional[int] = 1024 |
| 78 | + top_p: Optional[float] = 1.0 |
| 79 | + frequency_penalty: Optional[float] = 0.0 |
| 80 | + presence_penalty: Optional[float] = 0.0 |
| 81 | + stream: Optional[bool] = False |
| 82 | + web_search_options: Optional[Dict] = None |
| 83 | + tool_choice: Optional[Union[Dict[str, str], str]] = None |
| 84 | + parallel_tool_calls: Optional[bool] = None |
| 85 | + extra_headers: Optional[Dict[str, str]] = None |
| 86 | + |
| 87 | + |
| 88 | +AIHUBMIX_API_PARAMS = {param for param in AihubMixConfig.model_fields.keys()} |
0 commit comments