|
| 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, List, Optional, Union |
| 17 | + |
| 18 | +from pydantic import Field |
| 19 | + |
| 20 | +from camel.configs.base_config import BaseConfig |
| 21 | +from camel.types import NotGiven |
| 22 | + |
| 23 | + |
| 24 | +class NetmindConfig(BaseConfig): |
| 25 | + r"""Defines the parameters for generating chat completions using OpenAI |
| 26 | + compatibility. |
| 27 | +
|
| 28 | + Reference: https://netmind-power.gitbook.io/netmind-power-documentation/ |
| 29 | + api/inference/chat |
| 30 | +
|
| 31 | + Args: |
| 32 | + presence_penalty (float, optional): Number between :obj:`-2.0` and |
| 33 | + :obj:`2.0`. Positive values penalize new tokens based on whether |
| 34 | + they appear in the text so far, increasing the model's likelihood |
| 35 | + to talk about new topics. See more information about frequency and |
| 36 | + presence penalties. (default: :obj:`None`) |
| 37 | + frequency_penalty (float, optional): Number between :obj:`-2.0` and |
| 38 | + :obj:`2.0`. Positive values penalize new tokens based on their |
| 39 | + existing frequency in the text so far, decreasing the model's |
| 40 | + likelihood to repeat the same line verbatim. See more information |
| 41 | + about frequency and presence penalties. (default: :obj:`None`) |
| 42 | + repetition_penalty (float, optional): Penalizes new tokens based on |
| 43 | + their appearance in the prompt and generated text. |
| 44 | + (default: :obj:`None`) |
| 45 | + stream (bool, optional): Whether to stream the response. |
| 46 | + (default: :obj:`None`) |
| 47 | + temperature (float, optional): Controls randomness in the response. |
| 48 | + Higher values make output more random, lower values make it more |
| 49 | + deterministic. Range: [0.0, 2.0]. (default: :obj:`None`) |
| 50 | + top_p (float, optional): Controls diversity via nucleus sampling. |
| 51 | + Range: [0.0, 1.0]. (default: :obj:`None`) |
| 52 | + logit_bias (dict, optional): Modify the likelihood of specified tokens |
| 53 | + appearing in the completion. Accepts a json object that maps tokens |
| 54 | + (specified by their token ID in the tokenizer) to an associated |
| 55 | + bias value from :obj:`-100` to :obj:`100`. Mathematically, the bias |
| 56 | + is added to the logits generated by the model prior to sampling. |
| 57 | + The exact effect will vary per model, but values between:obj:` -1` |
| 58 | + and :obj:`1` should decrease or increase likelihood of selection; |
| 59 | + values like :obj:`-100` or :obj:`100` should result in a ban or |
| 60 | + exclusive selection of the relevant token. (default: :obj:`None`) |
| 61 | + max_tokens (Union[int, NotGiven], optional): Maximum number of tokens |
| 62 | + to generate. If not provided, model will use its default maximum. |
| 63 | + (default: :obj:`None`) |
| 64 | + stop (Optional[List[str]], optional): List of stop sequences. |
| 65 | + (default: :obj:`None`) |
| 66 | + n (Optional[int], optional): Number of chat completion choices to |
| 67 | + generate for each input message. (default: :obj:`None`) |
| 68 | + """ |
| 69 | + |
| 70 | + stream: Optional[bool] = Field(default=None) |
| 71 | + temperature: Optional[float] = Field(default=None) |
| 72 | + top_p: Optional[float] = Field(default=None) |
| 73 | + presence_penalty: Optional[float] = Field(default=None) |
| 74 | + frequency_penalty: Optional[float] = Field(default=None) |
| 75 | + repetition_penalty: Optional[float] = Field(default=None) |
| 76 | + max_tokens: Optional[Union[int, NotGiven]] = Field(default=None) |
| 77 | + stop: Optional[List[str]] = Field(default=None) |
| 78 | + n: Optional[int] = Field(default=None) |
| 79 | + logit_bias: Optional[Dict[str, float]] = Field(default=None) |
| 80 | + |
| 81 | + |
| 82 | +NETMIND_API_PARAMS = {param for param in NetmindConfig.model_fields.keys()} |
0 commit comments