Skip to content

Commit d161d30

Browse files
committed
updating single turn processor
1 parent 4511dd1 commit d161d30

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

eval_protocol/pytest/default_single_turn_rollout_process.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import List
33

44
from litellm import acompletion
5+
from openai.types.chat.chat_completion_message import ChatCompletionMessageToolCall
56

67
from eval_protocol.models import EvaluationRow, Message
78
from eval_protocol.pytest.types import RolloutProcessorConfig
@@ -28,11 +29,26 @@ async def process_row(row: EvaluationRow) -> EvaluationRow:
2829

2930
assistant_content = response.choices[0].message.content or ""
3031
tool_calls = response.choices[0].message.tool_calls if response.choices[0].message.tool_calls else None
32+
33+
converted_tool_calls = None
34+
if tool_calls:
35+
converted_tool_calls = [
36+
ChatCompletionMessageToolCall(
37+
id=tool_call.id,
38+
type=tool_call.type,
39+
function={
40+
"name": tool_call.function.name,
41+
"arguments": tool_call.function.arguments,
42+
},
43+
)
44+
for tool_call in tool_calls
45+
]
46+
3147
messages = list(row.messages) + [
3248
Message(
3349
role="assistant",
3450
content=assistant_content,
35-
tool_calls=tool_calls,
51+
tool_calls=converted_tool_calls,
3652
)
3753
]
3854

0 commit comments

Comments
 (0)