Skip to content

Commit b43917c

Browse files
committed
Add functions parameters
1 parent 57db1f9 commit b43917c

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

llama_cpp/llama.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,8 @@ def _convert_text_completion_chunks_to_chat(
14351435
def create_chat_completion(
14361436
self,
14371437
messages: List[ChatCompletionMessage],
1438+
functions: Optional[List[ChatCompletionFunction]] = None,
1439+
function_call: Optional[Union[str, ChatCompletionFunctionCall]] = None,
14381440
temperature: float = 0.2,
14391441
top_p: float = 0.95,
14401442
top_k: int = 40,

llama_cpp/llama_types.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ class ChatCompletionMessage(TypedDict):
6363
user: NotRequired[str]
6464

6565

66+
class ChatCompletionFunction(TypedDict):
67+
name: str
68+
description: NotRequired[str]
69+
parameters: Dict[str, Any] # TODO: make this more specific
70+
71+
72+
class ChatCompletionFunctionCall(TypedDict):
73+
name: str
74+
75+
6676
class ChatCompletionChoice(TypedDict):
6777
index: int
6878
message: ChatCompletionMessage

llama_cpp/server/app.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,14 @@ class CreateChatCompletionRequest(BaseModel):
446446
messages: List[ChatCompletionRequestMessage] = Field(
447447
default=[], description="A list of messages to generate completions for."
448448
)
449+
functions: Optional[List[llama_cpp.ChatCompletionFunction]] = Field(
450+
default=None,
451+
description="A list of functions to apply to the generated completions.",
452+
)
453+
function_call: Optional[Union[str, llama_cpp.ChatCompletionFunctionCall]] = Field(
454+
default=None,
455+
description="A function to apply to the generated completions.",
456+
)
449457
max_tokens: int = max_tokens_field
450458
temperature: float = temperature_field
451459
top_p: float = top_p_field

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy