Migrate LLM API cache from pickle to JSON; extract shared LLMCacheBase class#146
Draft
Migrate LLM API cache from pickle to JSON; extract shared LLMCacheBase class#146
Conversation
…Base class - Create LLMCacheBase class with JSON-based _save_cache, _load_cache, set_api_cache - Refactor OpenAIClient to inherit caching from LLMCacheBase - Refactor OllamaClient to inherit from LLMCacheBase (was standalone) - AzureClient inherits from OpenAIClient, so it works automatically - Update default cache file name from openai_api_cache.pickle to openai_api_cache.json - Update tests to use JSON format instead of pickle - Add tests for LLMCacheBase, OllamaClient cache, and inheritance checks Co-authored-by: paulosalem <1709404+paulosalem@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor LLM API caching to use JSON format
Migrate LLM API cache from pickle to JSON; extract shared LLMCacheBase class
Feb 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The API cache stores only dicts, so pickle is unnecessary. The Ollama client duplicated the caching logic without sharing a common base.
Changes
LLMCacheBaseclass inopenai_client.py— extracts_save_cache,_load_cache,set_api_cacheusingjson.dump/json.loadwith UTF-8 encodingOpenAIClientinherits fromLLMCacheBase, removes redundant cache methods andpickleimportOllamaClientinherits fromLLMCacheBaseinstead of reimplementing caching standaloneAzureClientunchanged — inherits transitively viaOpenAIClientopenai_api_cache.pickle→openai_api_cache.jsoninconfig.ini,examples/config.ini, and__init__.pyTestLLMCacheBase(6 tests) andTestOllamaClientCache(5 tests) covering inheritance, roundtrip, corruption handlingInheritance
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.