wenjin272 commented on code in PR #930:
URL: https://github.com/apache/flink-agents/pull/930#discussion_r3701061740


##########
python/flink_agents/integrations/chat_models/azure/azure_openai_chat_model.py:
##########
@@ -114,6 +185,41 @@ def client(self) -> AzureOpenAI:
             )
         return self._client
 
+    @override
+    def supports_native_structured_output(self, effective_model: str | None) 
-> bool:
+        """Whether Azure documents json_schema strict support for 
``effective_model``.
+
+        ``effective_model`` is the model backing an Azure deployment, not the 
deployment
+        name. See the module-level allowlist for the source of truth and for 
why the
+        match is exact. An unrecognized model reports ``False`` so it degrades 
to the
+        prompt-engineering fallback rather than failing at the provider.
+
+        Reads no instance state, so it stays answerable on an instance that 
was never
+        initialized, where any field access would raise.
+        """
+        if not effective_model:
+            return False
+        return effective_model in _NATIVE_STRUCTURED_OUTPUT_MODELS
+
+    def _api_version_supports_structured_output(self) -> bool:
+        """Whether the configured api-version reaches the structured-output 
floor.
+
+        Azure documents ``2024-08-01-preview`` as the first api-version 
supporting
+        structured outputs, and whether an older version rejects 
``response_format`` or
+        silently ignores it is not documented. The request therefore never 
carries
+        ``response_format`` below the floor, which is safe under either 
behavior.
+
+        The comparison assumes the documented api-version form, a zero-padded
+        ``YYYY-MM-DD`` date optionally suffixed ``-preview``; over that form 
comparing
+        the leading date lexicographically is exact. The GA ``v1`` literal 
sorts above
+        the floor, which matches Azure documenting ``v1`` as supporting 
structured
+        outputs. This is not a validator: a value of any other shape is not 
classified
+        reliably, and the service rejects an api-version it does not recognize.
+        """
+        if not self.api_version:
+            return False
+        return self.api_version[:10] >= _MIN_STRUCTURED_OUTPUT_API_VERSION

Review Comment:
   `v1` passes this gate only because the comparison is lexicographic: `"v1" >= 
"2024-08-01"` evaluates to `true`. However, the current `AzureOpenAI` client 
still sends the legacy 
`/openai/deployments/{model}/chat/completions?api-version=v1` request, while 
Azure v1 uses `/openai/v1/chat/completions`. Since the mocked test does not 
inspect the final URL, could we remove `v1` from this gate/test until both 
connections support the unified endpoint?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to