Skip to content

Commit 6e505c1

Browse files
committed
add
1 parent 90063c7 commit 6e505c1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

eval_protocol/models.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
from datetime import datetime
33
from enum import Enum
4+
from re import A
45
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
56

67
JSONType = Union[Dict[str, Any], List[Any], str, int, float, bool, None]
@@ -256,7 +257,8 @@ def __iter__(self):
256257

257258
class Message(BaseModel):
258259
"""Chat message model with trajectory evaluation support."""
259-
260+
261+
model_config = ConfigDict(extra="allow")
260262
role: str # assistant, user, system, tool
261263
content: Optional[Union[str, List[ChatCompletionContentPartTextParam]]] = Field(
262264
default="", description="The content of the message."
@@ -269,11 +271,10 @@ class Message(BaseModel):
269271
tool_calls: Optional[List[ChatCompletionMessageToolCall]] = None
270272
function_call: Optional[FunctionCall] = None
271273
control_plane_step: Optional[Dict[str, Any]] = None
272-
weight: Optional[int] = None
273-
274274
def dump_mdoel_for_chat_completion_request(self):
275275
"""Only keep chat completion accepted fields"""
276-
return self.model_dump(exclude_none=True, exclude={"control_plane_step", "weight", "reasoning_content"})
276+
exclude_fields = {"control_plane_step", "reasoning_content"} | set(self.model_extra.keys()) if self.model_extra else set()
277+
return self.model_dump(exclude_none=True, exclude=exclude_fields)
277278

278279
@classmethod
279280
def model_validate(cls, obj, *args, **kwargs):

0 commit comments

Comments
 (0)