Skip to content

OpenAIModelAdapter.structured_chat calls undefined handle_response method #36

Description

@wilsonadenuga

Description

The structured_chat method in OpenAIModelAdapter calls self.handle_response(response), but this method is never defined in the class. This causes an AttributeError at runtime.

Location

common/llm/adapters/azure_openai.py - line 40

Current Code

async def structured_chat(self, messages: list[dict[str, str]], response_format: type[T]) -> T:
    response = await self.async_azure_client.beta.chat.completions.parse(
        model=self._model, messages=messages, response_format=response_format, **self._kwargs
    )
    choice = self.handle_response(response)  ===>>>>> undefined method
    return choice.message.parsed

Impact

Azure OpenAI structured outputs fail silently
Speaker identification returns generic labels ("Speaker 1", "Speaker 2") instead of identified names
Error is swallowed by except Exception handlers in the calling code

Suggested Fix

async def structured_chat(self, messages: list[dict[str, str]], response_format: type[T]) -> T:
    response = await self.async_azure_client.beta.chat.completions.parse(
        model=self._model, messages=messages, response_format=response_format, **self._kwargs
    )
    choice = response.choices[0]
    self.choice_incomplete(choice, response)
    return choice.message.parsed

This matches the pattern used in the chat method.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions