weiqingy opened a new issue, #1266:
URL: https://github.com/apache/flink-agents/issues/1266

   ### Search before asking
   
   - [x] I searched in the 
[issues](https://github.com/apache/flink-agents/issues) and found nothing 
similar.
   
   ### Description
   
   Six Python chat model connections each define a private 
`_native_output_model(output_schema)`: Anthropic, Azure OpenAI, DashScope, 
Ollama, OpenAI and watsonx. Each returns the Pydantic `BaseModel` subclass 
inside an `OutputSchema`, or `None` when there is no schema or the schema is a 
`RowTypeInfo`.
   
   The copies give the same result for what the connections pass in, an 
`OutputSchema` or `None`. They differ only in form: watsonx and DashScope have 
no explicit `None` check, and DashScope reads the attribute with `getattr` 
instead of checking `isinstance(output_schema, OutputSchema)`.
   
   Rendering the schema is already shared through `render_output_schema` in 
`flink_agents/api/agents/types.py`. Picking the model is not, so a change to 
which schemas go native, such as supporting another schema kind, has to be made 
six times, and the copies can drift apart. If #1265 merges as is, the vLLM 
connection becomes a seventh user: it imports the OpenAI module's private copy.
   
   Proposed fix: add one public helper beside `render_output_schema` and 
replace the six copies with it. Keep each connection's request builder 
(`_native_response_format`, `_native_output_config`, `_native_format`) as it 
is. This is a refactor with no behavior change, covered by the existing native 
structured output tests.
   
   Files:
   
   - 
`python/flink_agents/integrations/chat_models/anthropic/anthropic_chat_model.py`
   - 
`python/flink_agents/integrations/chat_models/azure/azure_openai_chat_model.py`
   - `python/flink_agents/integrations/chat_models/dashscope_chat_model.py`
   - `python/flink_agents/integrations/chat_models/ollama_chat_model.py`
   - `python/flink_agents/integrations/chat_models/openai/openai_chat_model.py`
   - 
`python/flink_agents/integrations/chat_models/watsonx/watsonx_chat_model.py`
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!
   


-- 
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