mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-05 10:13:05 +00:00
revert some unintentional changes by copying source of truth to llama-models
This commit is contained in:
parent
53a8086e37
commit
cfaf9e0e8b
9 changed files with 133 additions and 113 deletions
132
docs/_static/llama-stack-spec.html
vendored
132
docs/_static/llama-stack-spec.html
vendored
|
@ -4163,70 +4163,80 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"type": "object",
|
"oneOf": [
|
||||||
"additionalProperties": {
|
{
|
||||||
"oneOf": [
|
"type": "string"
|
||||||
{
|
},
|
||||||
"type": "string"
|
{
|
||||||
},
|
"type": "object",
|
||||||
{
|
"additionalProperties": {
|
||||||
"type": "integer"
|
"oneOf": [
|
||||||
},
|
{
|
||||||
{
|
"type": "string"
|
||||||
"type": "number"
|
},
|
||||||
},
|
{
|
||||||
{
|
"type": "integer"
|
||||||
"type": "boolean"
|
},
|
||||||
},
|
{
|
||||||
{
|
"type": "number"
|
||||||
"type": "null"
|
},
|
||||||
},
|
{
|
||||||
{
|
"type": "boolean"
|
||||||
"type": "array",
|
},
|
||||||
"items": {
|
{
|
||||||
"oneOf": [
|
"type": "null"
|
||||||
{
|
},
|
||||||
"type": "string"
|
{
|
||||||
},
|
"type": "array",
|
||||||
{
|
"items": {
|
||||||
"type": "integer"
|
"oneOf": [
|
||||||
},
|
{
|
||||||
{
|
"type": "string"
|
||||||
"type": "number"
|
},
|
||||||
},
|
{
|
||||||
{
|
"type": "integer"
|
||||||
"type": "boolean"
|
},
|
||||||
},
|
{
|
||||||
{
|
"type": "number"
|
||||||
"type": "null"
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
}
|
{
|
||||||
},
|
"type": "object",
|
||||||
{
|
"additionalProperties": {
|
||||||
"type": "object",
|
"oneOf": [
|
||||||
"additionalProperties": {
|
{
|
||||||
"oneOf": [
|
"type": "string"
|
||||||
{
|
},
|
||||||
"type": "string"
|
{
|
||||||
},
|
"type": "integer"
|
||||||
{
|
},
|
||||||
"type": "integer"
|
{
|
||||||
},
|
"type": "number"
|
||||||
{
|
},
|
||||||
"type": "number"
|
{
|
||||||
},
|
"type": "boolean"
|
||||||
{
|
},
|
||||||
"type": "boolean"
|
{
|
||||||
},
|
"type": "null"
|
||||||
{
|
}
|
||||||
"type": "null"
|
]
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
|
},
|
||||||
|
"arguments_json": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|
52
docs/_static/llama-stack-spec.yaml
vendored
52
docs/_static/llama-stack-spec.yaml
vendored
|
@ -2890,30 +2890,34 @@ components:
|
||||||
title: BuiltinTool
|
title: BuiltinTool
|
||||||
- type: string
|
- type: string
|
||||||
arguments:
|
arguments:
|
||||||
type: object
|
oneOf:
|
||||||
additionalProperties:
|
- type: string
|
||||||
oneOf:
|
- type: object
|
||||||
- type: string
|
additionalProperties:
|
||||||
- type: integer
|
oneOf:
|
||||||
- type: number
|
- type: string
|
||||||
- type: boolean
|
- type: integer
|
||||||
- type: 'null'
|
- type: number
|
||||||
- type: array
|
- type: boolean
|
||||||
items:
|
- type: 'null'
|
||||||
oneOf:
|
- type: array
|
||||||
- type: string
|
items:
|
||||||
- type: integer
|
oneOf:
|
||||||
- type: number
|
- type: string
|
||||||
- type: boolean
|
- type: integer
|
||||||
- type: 'null'
|
- type: number
|
||||||
- type: object
|
- type: boolean
|
||||||
additionalProperties:
|
- type: 'null'
|
||||||
oneOf:
|
- type: object
|
||||||
- type: string
|
additionalProperties:
|
||||||
- type: integer
|
oneOf:
|
||||||
- type: number
|
- type: string
|
||||||
- type: boolean
|
- type: integer
|
||||||
- type: 'null'
|
- type: number
|
||||||
|
- type: boolean
|
||||||
|
- type: 'null'
|
||||||
|
arguments_json:
|
||||||
|
type: string
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- call_id
|
- call_id
|
||||||
|
|
|
@ -38,7 +38,14 @@ RecursiveType = Union[Primitive, List[Primitive], Dict[str, Primitive]]
|
||||||
class ToolCall(BaseModel):
|
class ToolCall(BaseModel):
|
||||||
call_id: str
|
call_id: str
|
||||||
tool_name: Union[BuiltinTool, str]
|
tool_name: Union[BuiltinTool, str]
|
||||||
arguments: Dict[str, RecursiveType]
|
# Plan is to deprecate the Dict in favor of a JSON string
|
||||||
|
# that is parsed on the client side instead of trying to manage
|
||||||
|
# the recursive type here.
|
||||||
|
# Making this a union so that client side can start prepping for this change.
|
||||||
|
# Eventually, we will remove both the Dict and arguments_json field,
|
||||||
|
# and arguments will just be a str
|
||||||
|
arguments: Union[str, Dict[str, RecursiveType]]
|
||||||
|
arguments_json: Optional[str] = None
|
||||||
|
|
||||||
@field_validator("tool_name", mode="before")
|
@field_validator("tool_name", mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
5
llama_stack/models/llama/llama3/quantization/__init__.py
Normal file
5
llama_stack/models/llama/llama3/quantization/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
|
# the root directory of this source tree.
|
|
@ -210,9 +210,12 @@ class ChatFormat:
|
||||||
content = ToolUtils.encode_tool_call(t, tool_prompt_format)
|
content = ToolUtils.encode_tool_call(t, tool_prompt_format)
|
||||||
_process_content(content)
|
_process_content(content)
|
||||||
|
|
||||||
|
# Tool calls and Tool Response messages should be eom
|
||||||
eom = False
|
eom = False
|
||||||
if message.role == "assistant":
|
if message.role == "assistant":
|
||||||
eom = message.stop_reason == StopReason.end_of_message
|
eom = message.stop_reason == StopReason.end_of_message or message.tool_calls
|
||||||
|
elif message.role == "tool":
|
||||||
|
eom = True
|
||||||
|
|
||||||
tokens.append(self.tokenizer.special_tokens["<|eom|>" if eom else "<|eot|>"])
|
tokens.append(self.tokenizer.special_tokens["<|eom|>" if eom else "<|eot|>"])
|
||||||
return tokens, images
|
return tokens, images
|
||||||
|
@ -247,6 +250,11 @@ class ChatFormat:
|
||||||
if content.startswith(header_str):
|
if content.startswith(header_str):
|
||||||
content = content[len(header_str) :]
|
content = content[len(header_str) :]
|
||||||
|
|
||||||
|
ipython = content.startswith("<|python_start|>")
|
||||||
|
if ipython:
|
||||||
|
content = content[len("<|python_start|>") :]
|
||||||
|
content = content.replace("<|python_end|>", "")
|
||||||
|
|
||||||
if content.endswith("<|eot|>"):
|
if content.endswith("<|eot|>"):
|
||||||
content = content[: -len("<|eot|>")]
|
content = content[: -len("<|eot|>")]
|
||||||
stop_reason = StopReason.end_of_turn
|
stop_reason = StopReason.end_of_turn
|
||||||
|
@ -277,6 +285,11 @@ class ChatFormat:
|
||||||
}
|
}
|
||||||
if tool_name in BuiltinTool.__members__:
|
if tool_name in BuiltinTool.__members__:
|
||||||
tool_name = BuiltinTool[tool_name]
|
tool_name = BuiltinTool[tool_name]
|
||||||
|
elif ipython:
|
||||||
|
tool_name = BuiltinTool.code_interpreter
|
||||||
|
tool_arguments = {
|
||||||
|
"code": content,
|
||||||
|
}
|
||||||
|
|
||||||
tool_calls = []
|
tool_calls = []
|
||||||
if tool_name is not None and tool_arguments is not None:
|
if tool_name is not None and tool_arguments is not None:
|
||||||
|
|
|
@ -4,22 +4,6 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
|
||||||
# top-level folder for each specific model found within the models/ directory at
|
|
||||||
# the top-level of this source tree.
|
|
||||||
|
|
||||||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
|
||||||
# the root directory of this source tree.
|
|
||||||
|
|
||||||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
||||||
# This software may be used and distributed in accordance with the terms of the Llama 3 Community License Agreement.
|
|
||||||
|
|
||||||
import codecs
|
import codecs
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
|
|
5
llama_stack/models/llama/llama4/quantization/__init__.py
Normal file
5
llama_stack/models/llama/llama4/quantization/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
|
# the root directory of this source tree.
|
|
@ -4,16 +4,6 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
|
||||||
# top-level folder for each specific model found within the models/ directory at
|
|
||||||
# the top-level of this source tree.
|
|
||||||
|
|
||||||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
||||||
# This software may be used and distributed in accordance with the terms of the Llama 3 Community License Agreement.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
|
@ -96,6 +96,7 @@ def _convert_to_vllm_tool_calls_in_response(
|
||||||
call_id=call.id,
|
call_id=call.id,
|
||||||
tool_name=call.function.name,
|
tool_name=call.function.name,
|
||||||
arguments=json.loads(call.function.arguments),
|
arguments=json.loads(call.function.arguments),
|
||||||
|
arguments_json=call.function.arguments,
|
||||||
)
|
)
|
||||||
for call in tool_calls
|
for call in tool_calls
|
||||||
]
|
]
|
||||||
|
@ -175,6 +176,7 @@ async def _process_vllm_chat_completion_stream_response(
|
||||||
call_id=tool_call_buf.call_id,
|
call_id=tool_call_buf.call_id,
|
||||||
tool_name=tool_call_buf.tool_name,
|
tool_name=tool_call_buf.tool_name,
|
||||||
arguments=args,
|
arguments=args,
|
||||||
|
arguments_json=args_str,
|
||||||
),
|
),
|
||||||
parse_status=ToolCallParseStatus.succeeded,
|
parse_status=ToolCallParseStatus.succeeded,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue