This commit is contained in:
Daniël de Kok 2025-08-28 14:14:35 +00:00
parent db187caf6b
commit 8834aaf46d
10 changed files with 22 additions and 12 deletions

View File

@ -43,7 +43,10 @@ async def test_grammar_response_format_llama_json(llama_grammar, response_snapsh
], ],
"seed": 42, "seed": 42,
"max_tokens": 500, "max_tokens": 500,
"response_format": {"type": "json_object", "value": Weather.model_json_schema()}, "response_format": {
"type": "json_object",
"value": Weather.model_json_schema(),
},
} }
# send the request # send the request
response = requests.post( response = requests.post(
@ -75,7 +78,11 @@ async def test_grammar_response_format_llama_json(llama_grammar, response_snapsh
json_payload["response_format"] = { json_payload["response_format"] = {
"type": "json_schema", "type": "json_schema",
"value": {"name": "weather", "strict": True, "schema": Weather.model_json_schema()}, "value": {
"name": "weather",
"strict": True,
"schema": Weather.model_json_schema(),
},
} }
response = requests.post( response = requests.post(
f"{llama_grammar.base_url}/v1/chat/completions", f"{llama_grammar.base_url}/v1/chat/completions",
@ -119,7 +126,10 @@ async def test_grammar_response_format_llama_error_if_tools_not_installed(
"seed": 42, "seed": 42,
"max_tokens": 500, "max_tokens": 500,
"tools": [], "tools": [],
"response_format": {"type": "json_object", "value": Weather.model_json_schema()}, "response_format": {
"type": "json_object",
"value": Weather.model_json_schema(),
},
}, },
) )

View File

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" PyTorch Idefics2 model.""" """PyTorch Idefics2 model."""
from typing import List, Optional, Tuple from typing import List, Optional, Tuple

View File

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" PyTorch Idefics3 model.""" """PyTorch Idefics3 model."""
from typing import List, Optional, Tuple from typing import List, Optional, Tuple

View File

@ -17,7 +17,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" Idefics model configuration""" """Idefics model configuration"""
import copy import copy
from transformers import PretrainedConfig from transformers import PretrainedConfig

View File

@ -17,7 +17,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" PyTorch Idefics model.""" """PyTorch Idefics model."""
from typing import List, Optional, Tuple, Union from typing import List, Optional, Tuple, Union
import torch import torch

View File

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" PyTorch IdeficsVision model: a copy of CLIPVisionModel using a simpler config object""" """PyTorch IdeficsVision model: a copy of CLIPVisionModel using a simpler config object"""
from dataclasses import dataclass from dataclasses import dataclass

View File

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" PyTorch Llava-NeXT model.""" """PyTorch Llava-NeXT model."""
from typing import List, Optional, Tuple from typing import List, Optional, Tuple

View File

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" PyTorch GPTNeoX model.""" """PyTorch GPTNeoX model."""
from typing import Optional, Tuple, Union from typing import Optional, Tuple, Union

View File

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" PyTorch T5 model.""" """PyTorch T5 model."""
import copy import copy
import math import math

View File

@ -9,7 +9,7 @@ import numpy as np
def find_segments( def find_segments(
adapter_indices: Union[torch.Tensor, List[int]] adapter_indices: Union[torch.Tensor, List[int]],
) -> Tuple[List[int], List[int]]: ) -> Tuple[List[int], List[int]]:
if isinstance(adapter_indices, torch.Tensor): if isinstance(adapter_indices, torch.Tensor):
adapter_indices = adapter_indices.cpu().numpy() adapter_indices = adapter_indices.cpu().numpy()