refactor: split OpenWebUI into strategy classes by backend #9
Reference in New Issue
Block a user
Delete Branch "refactor/openwebui-strategy-split"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Replace Conditional with Polymorphism from the Refactoring Guru catalog.
The OpenWebUIProvider previously contained two parallel implementations
(completeWithChat / completeWithOllama, streamWithChat / streamWithOllama,
plus branching in validateConnection) selected by a
useOllamaProxyboolean. The 987-line file is split into:
OpenWebUIChatStrategy and
OpenWebUIOllamaStrategy implementations
construction and delegates
OpenWebUIProvider and OpenWebUIConfig (including useOllamaProxy) stay
in their original locations, so consumer imports are unchanged.
Side effects:
hooks added in R2, removing handleOpenWebUIError and its duplicated status switch.
Replace Conditional with Polymorphism from the Refactoring Guru catalog. The OpenWebUIProvider previously contained two parallel implementations (completeWithChat / completeWithOllama, streamWithChat / streamWithOllama, plus branching in validateConnection) selected by a `useOllamaProxy` boolean. The 987-line file is split into: - openwebui-types.ts wire-format response types - openwebui-http.ts shared HTTP client (auth, timeout) - openwebui-strategies.ts OpenWebUIStrategy interface plus OpenWebUIChatStrategy and OpenWebUIOllamaStrategy implementations - openwebui.ts thin provider that picks one strategy at construction and delegates OpenWebUIProvider and OpenWebUIConfig (including useOllamaProxy) stay in their original locations, so consumer imports are unchanged. Side effects: - Error mapping now goes through the base mapProviderError / providerErrorMessages hooks added in R2, removing handleOpenWebUIError and its duplicated status switch. - providerInfo.version bumped to 2.0.0 to reflect the rewrite.