Stop scattering LLM SDK/API calls across your codebase. Here is the 2-file rule that fixed mine
The article discusses the challenges of managing LLM SDK/API calls in a codebase and introduces a solution called the 2-file rule. This approach limits SDK imports to two specific files, allowing for better organization and easier upgrades. By applying hexagonal architecture principles, the author demonstrates how to isolate SDK dependencies and streamline operations.
- ▪The author faced issues with breaking changes across multiple files when upgrading an LLM SDK.
- ▪The 2-file rule restricts SDK imports to one adapter and one provider registry, simplifying the codebase.
- ▪This method allows for easier SDK upgrades without affecting the majority of the codebase.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 3947119) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Babak Abbaschian Posted on May 23 • Originally published at babak.ai Stop scattering LLM SDK/API calls across your codebase. Here is the 2-file rule that fixed mine #ai #opensource #typescript #architecture I upgraded an LLM SDK and expected a routine version bump. Instead I had to touch 15+ files, fix breaking changes across four providers, and spend the rest of the day hoping I had not missed one. That was the second time it happened. I knew there would be a third.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).