Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion eval_protocol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
from .pytest import evaluation_test, SingleTurnRolloutProcessor
from .pytest.parameterize import DefaultParameterIdGenerator

from .adapters import OpenAIResponsesAdapter
try:
from .adapters import OpenAIResponsesAdapter
except ImportError:
OpenAIResponsesAdapter = None
Comment on lines +44 to +47
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!


try:
from .adapters import LangfuseAdapter, create_langfuse_adapter
Expand Down
16 changes: 7 additions & 9 deletions eval_protocol/adapters/openai_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from typing_extensions import Any

from openai.pagination import SyncCursorPage
from openai.types.chat.chat_completion_function_tool_param import ChatCompletionFunctionToolParam
from openai.types.chat.chat_completion_tool_param import ChatCompletionToolParam
from openai.types.chat.chat_completion_message import FunctionCall
from openai.types.responses import Response
from openai.types.responses.response_item import ResponseItem
from openai.types.chat.chat_completion_message_function_tool_call import (
ChatCompletionMessageFunctionToolCall,
from openai.types.chat.chat_completion_message_tool_call import (
ChatCompletionMessageToolCall,
Function,
)
from openai.types.responses.tool import Tool
Expand Down Expand Up @@ -114,11 +114,9 @@ def _create_evaluation_row(self, input_items: SyncCursorPage[ResponseItem], resp
),
)

def _responses_tools_to_chat_completion_tools(
self, tools: List[Tool]
) -> Sequence[ChatCompletionFunctionToolParam]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, what is this change? was it incorrect before?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think its a version issue, i tested in a clean env (0 previous installed dependencies in it) and it complained on this import.

def _responses_tools_to_chat_completion_tools(self, tools: List[Tool]) -> Sequence[ChatCompletionToolParam]:
"""Convert OpenAI Responses API tools to chat completion message function tool calls."""
chat_completion_tools: List[ChatCompletionFunctionToolParam] = []
chat_completion_tools: List[ChatCompletionToolParam] = []
for tool in tools:
if tool.type == "function":
chat_completion_tools.append(
Expand Down Expand Up @@ -146,7 +144,7 @@ def _create_messages(self, input_items: SyncCursorPage[ResponseItem]) -> Iterabl
be added before the assistant message with tool calls.
"""
messages: list[Message] = []
current_tool_calls: list[ChatCompletionMessageFunctionToolCall] = []
current_tool_calls: list[ChatCompletionMessageToolCall] = []
tool_call_outputs: list[Message] = []

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