Generate a chat completion from a list of messages. Args: messages: A list of messages to generate a response for. functions: A list of functions to use for the chat completion. function_call: A function call to use for the chat completion. to
(
self,
messages: List[ChatCompletionRequestMessage],
functions: Optional[List[ChatCompletionFunction]] = None,
function_call: Optional[ChatCompletionRequestFunctionCall] = None,
tools: Optional[List[ChatCompletionTool]] = None,
tool_choice: Optional[ChatCompletionToolChoiceOption] = None,
temperature: float = 0.2,
top_p: float = 0.95,
top_k: int = 40,
min_p: float = 0.05,
typical_p: float = 1.0,
stream: bool = False,
stop: Optional[Union[str, List[str]]] = [],
seed: Optional[int] = None,
response_format: Optional[ChatCompletionRequestResponseFormat] = None,
max_tokens: Optional[int] = None,
presence_penalty: float = 0.0,
frequency_penalty: float = 0.0,
repeat_penalty: float = 1.0,
tfs_z: float = 1.0,
mirostat_mode: int = 0,
mirostat_tau: float = 5.0,
mirostat_eta: float = 0.1,
model: Optional[str] = None,
logits_processor: Optional[LogitsProcessorList] = None,
grammar: Optional[LlamaGrammar] = None,
logit_bias: Optional[Dict[int, float]] = None,
logprobs: Optional[bool] = None,
top_logprobs: Optional[int] = None,
)
| 1995 | ) |
| 1996 | |
| 1997 | def create_chat_completion( |
| 1998 | self, |
| 1999 | messages: List[ChatCompletionRequestMessage], |
| 2000 | functions: Optional[List[ChatCompletionFunction]] = None, |
| 2001 | function_call: Optional[ChatCompletionRequestFunctionCall] = None, |
| 2002 | tools: Optional[List[ChatCompletionTool]] = None, |
| 2003 | tool_choice: Optional[ChatCompletionToolChoiceOption] = None, |
| 2004 | temperature: float = 0.2, |
| 2005 | top_p: float = 0.95, |
| 2006 | top_k: int = 40, |
| 2007 | min_p: float = 0.05, |
| 2008 | typical_p: float = 1.0, |
| 2009 | stream: bool = False, |
| 2010 | stop: Optional[Union[str, List[str]]] = [], |
| 2011 | seed: Optional[int] = None, |
| 2012 | response_format: Optional[ChatCompletionRequestResponseFormat] = None, |
| 2013 | max_tokens: Optional[int] = None, |
| 2014 | presence_penalty: float = 0.0, |
| 2015 | frequency_penalty: float = 0.0, |
| 2016 | repeat_penalty: float = 1.0, |
| 2017 | tfs_z: float = 1.0, |
| 2018 | mirostat_mode: int = 0, |
| 2019 | mirostat_tau: float = 5.0, |
| 2020 | mirostat_eta: float = 0.1, |
| 2021 | model: Optional[str] = None, |
| 2022 | logits_processor: Optional[LogitsProcessorList] = None, |
| 2023 | grammar: Optional[LlamaGrammar] = None, |
| 2024 | logit_bias: Optional[Dict[int, float]] = None, |
| 2025 | logprobs: Optional[bool] = None, |
| 2026 | top_logprobs: Optional[int] = None, |
| 2027 | ) -> Union[ |
| 2028 | CreateChatCompletionResponse, Iterator[CreateChatCompletionStreamResponse] |
| 2029 | ]: |
| 2030 | """Generate a chat completion from a list of messages. |
| 2031 | |
| 2032 | Args: |
| 2033 | messages: A list of messages to generate a response for. |
| 2034 | functions: A list of functions to use for the chat completion. |
| 2035 | function_call: A function call to use for the chat completion. |
| 2036 | tools: A list of tools to use for the chat completion. |
| 2037 | tool_choice: A tool choice to use for the chat completion. |
| 2038 | temperature: The temperature to use for sampling. |
| 2039 | top_p: The top-p value to use for nucleus sampling. Nucleus sampling described in academic paper "The Curious Case of Neural Text Degeneration" https://arxiv.org/abs/1904.09751 |
| 2040 | top_k: The top-k value to use for sampling. Top-K sampling described in academic paper "The Curious Case of Neural Text Degeneration" https://arxiv.org/abs/1904.09751 |
| 2041 | min_p: The min-p value to use for minimum p sampling. Minimum P sampling as described in https://github.com/ggerganov/llama.cpp/pull/3841 |
| 2042 | typical_p: The typical-p value to use for sampling. Locally Typical Sampling implementation described in the paper https://arxiv.org/abs/2202.00666. |
| 2043 | stream: Whether to stream the results. |
| 2044 | stop: A list of strings to stop generation when encountered. |
| 2045 | seed: The seed to use for sampling. |
| 2046 | response_format: The response format to use for the chat completion. Use { "type": "json_object" } to contstrain output to only valid json. |
| 2047 | max_tokens: The maximum number of tokens to generate. If max_tokens <= 0 or None, the maximum number of tokens to generate is unlimited and depends on n_ctx. |
| 2048 | presence_penalty: The penalty to apply to tokens based on their presence in the prompt. |
| 2049 | frequency_penalty: The penalty to apply to tokens based on their frequency in the prompt. |
| 2050 | repeat_penalty: The penalty to apply to repeated tokens. |
| 2051 | tfs_z: The tail-free sampling parameter. |
| 2052 | mirostat_mode: The mirostat sampling mode. |
| 2053 | mirostat_tau: The mirostat sampling tau parameter. |
| 2054 | mirostat_eta: The mirostat sampling eta parameter. |
no outgoing calls
no test coverage detected