mirror of
https://github.com/abetlen/llama-cpp-python.git
synced 2023-09-07 17:34:22 +03:00
Fix signature for stop parameter
This commit is contained in:
@@ -323,7 +323,7 @@ class Llama:
|
|||||||
top_p: float = 0.95,
|
top_p: float = 0.95,
|
||||||
logprobs: Optional[int] = None,
|
logprobs: Optional[int] = None,
|
||||||
echo: bool = False,
|
echo: bool = False,
|
||||||
stop: List[str] = [],
|
stop: Optional[List[str]] = [],
|
||||||
repeat_penalty: float = 1.1,
|
repeat_penalty: float = 1.1,
|
||||||
top_k: int = 40,
|
top_k: int = 40,
|
||||||
stream: bool = False,
|
stream: bool = False,
|
||||||
@@ -336,6 +336,7 @@ class Llama:
|
|||||||
prompt_tokens = self.tokenize(b" " + prompt.encode("utf-8"))
|
prompt_tokens = self.tokenize(b" " + prompt.encode("utf-8"))
|
||||||
text = b""
|
text = b""
|
||||||
returned_characters = 0
|
returned_characters = 0
|
||||||
|
stop = stop if not None else []
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
llama_cpp.llama_reset_timings(self.ctx)
|
llama_cpp.llama_reset_timings(self.ctx)
|
||||||
@@ -537,7 +538,7 @@ class Llama:
|
|||||||
top_p: float = 0.95,
|
top_p: float = 0.95,
|
||||||
logprobs: Optional[int] = None,
|
logprobs: Optional[int] = None,
|
||||||
echo: bool = False,
|
echo: bool = False,
|
||||||
stop: List[str] = [],
|
stop: Optional[List[str]] = [],
|
||||||
repeat_penalty: float = 1.1,
|
repeat_penalty: float = 1.1,
|
||||||
top_k: int = 40,
|
top_k: int = 40,
|
||||||
stream: bool = False,
|
stream: bool = False,
|
||||||
@@ -592,7 +593,7 @@ class Llama:
|
|||||||
top_p: float = 0.95,
|
top_p: float = 0.95,
|
||||||
logprobs: Optional[int] = None,
|
logprobs: Optional[int] = None,
|
||||||
echo: bool = False,
|
echo: bool = False,
|
||||||
stop: List[str] = [],
|
stop: Optional[List[str]] = [],
|
||||||
repeat_penalty: float = 1.1,
|
repeat_penalty: float = 1.1,
|
||||||
top_k: int = 40,
|
top_k: int = 40,
|
||||||
stream: bool = False,
|
stream: bool = False,
|
||||||
@@ -698,7 +699,7 @@ class Llama:
|
|||||||
top_p: float = 0.95,
|
top_p: float = 0.95,
|
||||||
top_k: int = 40,
|
top_k: int = 40,
|
||||||
stream: bool = False,
|
stream: bool = False,
|
||||||
stop: List[str] = [],
|
stop: Optional[List[str]] = [],
|
||||||
max_tokens: int = 128,
|
max_tokens: int = 128,
|
||||||
repeat_penalty: float = 1.1,
|
repeat_penalty: float = 1.1,
|
||||||
) -> Union[ChatCompletion, Iterator[ChatCompletionChunk]]:
|
) -> Union[ChatCompletion, Iterator[ChatCompletionChunk]]:
|
||||||
@@ -717,6 +718,7 @@ class Llama:
|
|||||||
Returns:
|
Returns:
|
||||||
Generated chat completion or a stream of chat completion chunks.
|
Generated chat completion or a stream of chat completion chunks.
|
||||||
"""
|
"""
|
||||||
|
stop = stop if not None else []
|
||||||
instructions = """Complete the following chat conversation between the user and the assistant. System messages should be strictly followed as additional instructions."""
|
instructions = """Complete the following chat conversation between the user and the assistant. System messages should be strictly followed as additional instructions."""
|
||||||
chat_history = "\n".join(
|
chat_history = "\n".join(
|
||||||
f'{message["role"]} {message.get("user", "")}: {message["content"]}'
|
f'{message["role"]} {message.get("user", "")}: {message["content"]}'
|
||||||
|
|||||||
Reference in New Issue
Block a user