Skip to content

Commit 6c86a66

Browse files
committed
fix
1 parent 87fdc2c commit 6c86a66

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

eval_protocol/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
from .pytest import evaluation_test, SingleTurnRolloutProcessor
4242
from .pytest.parameterize import DefaultParameterIdGenerator
4343

44-
from .adapters import OpenAIResponsesAdapter
44+
try:
45+
from .adapters import OpenAIResponsesAdapter
46+
except ImportError:
47+
OpenAIResponsesAdapter = None
4548

4649
try:
4750
from .adapters import LangfuseAdapter, create_langfuse_adapter

eval_protocol/adapters/openai_responses.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
from typing_extensions import Any
1111

1212
from openai.pagination import SyncCursorPage
13-
from openai.types.chat.chat_completion_function_tool_param import ChatCompletionFunctionToolParam
13+
from openai.types.chat.chat_completion_tool_param import ChatCompletionToolParam
1414
from openai.types.chat.chat_completion_message import FunctionCall
1515
from openai.types.responses import Response
1616
from openai.types.responses.response_item import ResponseItem
17-
from openai.types.chat.chat_completion_message_function_tool_call import (
18-
ChatCompletionMessageFunctionToolCall,
17+
from openai.types.chat.chat_completion_message_tool_call import (
18+
ChatCompletionMessageToolCall,
1919
Function,
2020
)
2121
from openai.types.responses.tool import Tool
@@ -116,9 +116,9 @@ def _create_evaluation_row(self, input_items: SyncCursorPage[ResponseItem], resp
116116

117117
def _responses_tools_to_chat_completion_tools(
118118
self, tools: List[Tool]
119-
) -> Sequence[ChatCompletionFunctionToolParam]:
119+
) -> Sequence[ChatCompletionToolParam]:
120120
"""Convert OpenAI Responses API tools to chat completion message function tool calls."""
121-
chat_completion_tools: List[ChatCompletionFunctionToolParam] = []
121+
chat_completion_tools: List[ChatCompletionToolParam] = []
122122
for tool in tools:
123123
if tool.type == "function":
124124
chat_completion_tools.append(
@@ -146,7 +146,7 @@ def _create_messages(self, input_items: SyncCursorPage[ResponseItem]) -> Iterabl
146146
be added before the assistant message with tool calls.
147147
"""
148148
messages: list[Message] = []
149-
current_tool_calls: list[ChatCompletionMessageFunctionToolCall] = []
149+
current_tool_calls: list[ChatCompletionMessageToolCall] = []
150150
tool_call_outputs: list[Message] = []
151151

152152
for item in input_items:
@@ -173,7 +173,7 @@ def _create_messages(self, input_items: SyncCursorPage[ResponseItem]) -> Iterabl
173173
# Collect tool call outputs to add before assistant message
174174
tool_call_outputs.append(Message(role="tool", content=item.output, tool_call_id=item.call_id))
175175
elif item.type == "function_call":
176-
tool_call = ChatCompletionMessageFunctionToolCall(
176+
tool_call = ChatCompletionMessageToolCall(
177177
id=item.call_id, type="function", function=Function(name=item.name, arguments=item.arguments)
178178
)
179179
current_tool_calls.append(tool_call)

0 commit comments

Comments
 (0)