Skip to content

Commit 4aa349d

Browse files
committed
Add docstring for create_chat_completion
1 parent 4615f1e commit 4aa349d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

llama_cpp/llama.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,21 @@ def create_chat_completion(
586586
max_tokens: int = 128,
587587
repeat_penalty: float = 1.1,
588588
) -> Union[ChatCompletion, Iterator[ChatCompletionChunk]]:
589+
"""Generate a chat completion from a list of messages.
590+
591+
Args:
592+
messages: A list of messages to generate a response for.
593+
temperature: The temperature to use for sampling.
594+
top_p: The top-p value to use for sampling.
595+
top_k: The top-k value to use for sampling.
596+
stream: Whether to stream the results.
597+
stop: A list of strings to stop generation when encountered.
598+
max_tokens: The maximum number of tokens to generate.
599+
repeat_penalty: The penalty to apply to repeated tokens.
600+
601+
Returns:
602+
Generated chat completion or a stream of chat completion chunks.
603+
"""
589604
instructions = """Complete the following chat conversation between the user and the assistant. System messages should be strictly followed as additional instructions."""
590605
chat_history = "\n".join(
591606
f'{message["role"]} {message.get("user", "")}: {message["content"]}'

0 commit comments

Comments
 (0)