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 , Sequence , Type , Union
17+
18+ from pydantic import BaseModel
19+
20+ from camel .configs .base_config import BaseConfig
21+
22+
23+ class AihubMixConfig (BaseConfig ):
24+ r"""Defines the parameters for generating chat completions using the
25+ AihubMix API.
26+
27+ Args:
28+ temperature (float, optional): Sampling temperature to use, between
29+ :obj:`0` and :obj:`2`. Higher values make the output more random,
30+ while lower values make it more focused and deterministic.
31+ (default: :obj:`0.8`)
32+ max_tokens (int, optional): The maximum number of tokens to generate
33+ in the chat completion. The total length of input tokens and
34+ generated tokens is limited by the model's context length.
35+ (default: :obj:`1024`)
36+ top_p (float, optional): An alternative to sampling with temperature,
37+ called nucleus sampling, where the model considers the results of
38+ the tokens with top_p probability mass. So :obj:`0.1` means only
39+ the tokens comprising the top 10% probability mass are considered.
40+ (default: :obj:`1`)
41+ frequency_penalty (float, optional): Number between :obj:`-2.0` and
42+ :obj:`2.0`. Positive values penalize new tokens based on their
43+ existing frequency in the text so far, decreasing the model's
44+ likelihood to repeat the same line verbatim.
45+ (default: :obj:`0`)
46+ presence_penalty (float, optional): Number between :obj:`-2.0` and
47+ :obj:`2.0`. Positive values penalize new tokens based on whether
48+ they appear in the text so far, increasing the model's likelihood
49+ to talk about new topics.
50+ (default: :obj:`0`)
51+ stream (bool, optional): If True, partial message deltas will be sent
52+ as data-only server-sent events as they become available.
53+ (default: :obj:`False`)
54+ web_search_options (dict, optional): Search model's web search options,
55+ only supported by specific search models.
56+ (default: :obj:`None`)
57+ tools (list[FunctionTool], optional): A list of tools the model may
58+ call. Currently, only functions are supported as a tool. Use this
59+ to provide a list of functions the model may generate JSON inputs
60+ for. A max of 128 functions are supported.
61+ tool_choice (Union[dict[str, str], str], optional): Controls which (if
62+ any) tool is called by the model. :obj:`"none"` means the model
63+ will not call any tool and instead generates a message.
64+ :obj:`"auto"` means the model can pick between generating a
65+ message or calling one or more tools. :obj:`"required"` means the
66+ model must call one or more tools. Specifying a particular tool
67+ via {"type": "function", "function": {"name": "my_function"}}
68+ forces the model to call that tool. :obj:`"none"` is the default
69+ when no tools are present. :obj:`"auto"` is the default if tools
70+ are present.
71+ parallel_tool_calls (bool, optional): A parameter specifying whether
72+ the model should call tools in parallel or not.
73+ (default: :obj:`None`)
74+ extra_headers: Optional[Dict[str, str]]: Extra headers to use for the
75+ model. (default: :obj:`None`)
76+ """
77+
78+ temperature : Optional [float ] = 0.8
79+ max_tokens : Optional [int ] = 1024
80+ top_p : Optional [float ] = 1.0
81+ frequency_penalty : Optional [float ] = 0.0
82+ presence_penalty : Optional [float ] = 0.0
83+ stream : Optional [bool ] = False
84+ web_search_options : Optional [Dict ] = None
85+ tool_choice : Optional [Union [Dict [str , str ], str ]] = None
86+ parallel_tool_calls : Optional [bool ] = None
87+ extra_headers : Optional [Dict [str , str ]] = None
88+
89+
90+ AIHUBMIX_API_PARAMS = {param for param in AihubMixConfig .model_fields .keys ()}
0 commit comments