Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit bcb18be

Browse files
committed
cache models
1 parent 9967143 commit bcb18be

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

assets/javascripts/discourse/components/ai-usage.gjs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export default class AiUsage extends Component {
8585
}
8686

8787
get availableFeatures() {
88+
// when you switch we don't want the list to change
89+
// only when you switch durations
8890
this._cachedFeatures =
8991
this._cachedFeatures ||
9092
(this.data?.features || []).map((f) => ({
@@ -96,10 +98,14 @@ export default class AiUsage extends Component {
9698
}
9799

98100
get availableModels() {
99-
return (this.data?.models || []).map((m) => ({
100-
id: m.llm,
101-
name: m.llm,
102-
}));
101+
this._cachedModels =
102+
this._cachedModels ||
103+
(this.data?.models || []).map((m) => ({
104+
id: m.llm,
105+
name: m.llm,
106+
}));
107+
108+
return this._cachedModels;
103109
}
104110

105111
<template>

0 commit comments

Comments
 (0)