Skip to content

Conversation

jiafu1115
Copy link
Contributor

@jiafu1115 jiafu1115 commented Oct 21, 2025

  • Created AbstractObservableChatModel base class for observation, retry, and tool calling
  • Refactored OpenAiChatModel and DeepSeekChatModel to extend the base class
  • Reduced code duplication in subclass
  • Introduced template method pattern for doCall() /doStream()/others

When reviewing #4649, I found that the issue isn’t limited to DeepSeek and all other models have similar logic for observation, retry, return directly and tool calling. So the best solution would be to refactor all the chat model code to centralize the common logic. That way, we can avoid having to make the same change in multiple places (10+ models mean 10+ * work load), and it will also make future maintenance easier across all models.

BTW, since this is a change which could easily conflict with other ongoing work (though it’s low risk due to method extracting only), and I’m not sure about the community’s thoughts on it, I only applied the refactor to two models for now to get feedback. If this approach looks good and gets reviewed, I can go ahead and update the rest of the models in some more separate PRs.

Thanks for reviewing!

@jiafu1115 jiafu1115 marked this pull request as ready for review October 21, 2025 12:26
@jiafu1115 jiafu1115 changed the title Refactor: Extract AbstractObservableChatModel to centralize common logic Refactor: Extract AbstractObservableChatModel to centralize all chat models' common logic Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant