Moved ToolPromptFormat and jinja templates to llama_models.llama3.api

This commit is contained in:
Hardik Shah 2024-08-23 14:58:52 -07:00
parent ab8193c88c
commit 5655266d58
13 changed files with 21 additions and 388 deletions

View file

@ -15,41 +15,6 @@ from typing_extensions import Annotated
from llama_models.llama3.api.datatypes import * # noqa: F403
@json_schema_type
class ToolChoice(Enum):
auto = "auto"
required = "required"
@json_schema_type
class ToolPromptFormat(Enum):
"""This Enum refers to the prompt format for calling zero shot tools
`json` --
Refers to the json format for calling tools.
The json format takes the form like
{
"type": "function",
"function" : {
"name": "function_name",
"description": "function_description",
"parameters": {...}
}
}
`function_tag` --
This is an example of how you could define
your own user defined format for making tool calls.
The function_tag format looks like this,
<function=function_name>(parameters)</function>
The detailed prompts for each of these formats are defined in `system_prompt.py`
"""
json = "json"
function_tag = "function_tag"
class LogProbConfig(BaseModel):
top_k: Optional[int] = 0

View file

@ -7,7 +7,7 @@
from .datatypes import * # noqa: F403
from typing import Optional, Protocol
from llama_models.llama3.api.datatypes import ToolDefinition
from llama_models.llama3.api.datatypes import ToolDefinition, ToolPromptFormat
# this dependency is annoying and we need a forked up version anyway
from llama_models.schema_utils import webmethod
@ -16,7 +16,7 @@ from llama_models.schema_utils import webmethod
@json_schema_type
class CompletionRequest(BaseModel):
model: str
content: InterleavedTextAttachment
content: InterleavedTextMedia
sampling_params: Optional[SamplingParams] = SamplingParams()
stream: Optional[bool] = False
@ -41,7 +41,7 @@ class CompletionResponseStreamChunk(BaseModel):
@json_schema_type
class BatchCompletionRequest(BaseModel):
model: str
content_batch: List[InterleavedTextAttachment]
content_batch: List[InterleavedTextMedia]
sampling_params: Optional[SamplingParams] = SamplingParams()
logprobs: Optional[LogProbConfig] = None