| 1 | """Response cache. Mid-migration: the key format is being made model-aware.""" |
| 2 | |
| 3 | _ENTRIES = {} |
| 4 | |
| 5 | |
| 6 | def legacy_key(prompt): |
| 7 | """Old key. Collides across models, which is the bug being fixed.""" |
| 8 | return prompt.strip() |
| 9 | |
| 10 | |
| 11 | def get(prompt): |
| 12 | return _ENTRIES.get(legacy_key(prompt)) |
| 13 | |
| 14 | |
| 15 | def put(prompt, value): |
| 16 | # TODO: switch to cache.keys.model_scoped_key once callers pass the model. |
| 17 | _ENTRIES[legacy_key(prompt)] = value |
| 18 |