File size: 4,686 Bytes
b9d9271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
from __future__ import annotations

from typing import List, Optional, Union

from camel.configs.base_config import BaseConfig


class LiteLLMConfig(BaseConfig):
    r"""Defines the parameters for generating chat completions using the
    LiteLLM API.

    Args:
        timeout (Optional[Union[float, str]], optional): Request timeout.
            (default: None)
        temperature (Optional[float], optional): Temperature parameter for
            controlling randomness. (default: None)
        top_p (Optional[float], optional): Top-p parameter for nucleus
            sampling. (default: None)
        n (Optional[int], optional): Number of completions to generate.
            (default: None)
        stream (Optional[bool], optional): Whether to return a streaming
            response. (default: None)
        stream_options (Optional[dict], optional): Options for the streaming
            response. (default: None)
        stop (Optional[Union[str, List[str]]], optional): Sequences where the
            API will stop generating further tokens. (default: None)
        max_tokens (Optional[int], optional): Maximum number of tokens to
            generate. (default: None)
        presence_penalty (Optional[float], optional): Penalize new tokens
            based on their existence in the text so far. (default: None)
        frequency_penalty (Optional[float], optional): Penalize new tokens
            based on their frequency in the text so far. (default: None)
        logit_bias (Optional[dict], optional): Modify the probability of
            specific tokens appearing in the completion. (default: None)
        user (Optional[str], optional): A unique identifier representing the
            end-user. (default: None)
        response_format (Optional[dict], optional): Response format
            parameters. (default: None)
        seed (Optional[int], optional): Random seed. (default: None)
        tools (Optional[List], optional): List of tools. (default: None)
        tool_choice (Optional[Union[str, dict]], optional): Tool choice
            parameters. (default: None)
        logprobs (Optional[bool], optional): Whether to return log
            probabilities of the output tokens. (default: None)
        top_logprobs (Optional[int], optional): Number of most likely tokens
            to return at each token position. (default: None)
        deployment_id (Optional[str], optional): Deployment ID. (default: None)
        extra_headers (Optional[dict], optional): Additional headers for the
            request. (default: None)
        api_version (Optional[str], optional): API version. (default: None)
        mock_response (Optional[str], optional): Mock completion response for
            testing or debugging. (default: None)
        custom_llm_provider (Optional[str], optional): Non-OpenAI LLM
            provider. (default: None)
        max_retries (Optional[int], optional): Maximum number of retries.
            (default: None)
    """

    timeout: Optional[Union[float, str]] = None
    temperature: Optional[float] = None
    top_p: Optional[float] = None
    n: Optional[int] = None
    stream: Optional[bool] = None
    stream_options: Optional[dict] = None
    stop: Optional[Union[str, List[str]]] = None
    max_tokens: Optional[int] = None
    presence_penalty: Optional[float] = None
    frequency_penalty: Optional[float] = None
    logit_bias: Optional[dict] = None
    user: Optional[str] = None
    response_format: Optional[dict] = None
    seed: Optional[int] = None
    tool_choice: Optional[Union[str, dict]] = None
    logprobs: Optional[bool] = None
    top_logprobs: Optional[int] = None
    deployment_id: Optional[str] = None
    extra_headers: Optional[dict] = None
    api_version: Optional[str] = None
    mock_response: Optional[str] = None
    custom_llm_provider: Optional[str] = None
    max_retries: Optional[int] = None


LITELLM_API_PARAMS = {param for param in LiteLLMConfig.model_fields.keys()}