Skip to content

Commit 97d3a18

Browse files
committed
chore: set max history from global
1 parent c6a7bd2 commit 97d3a18

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

packages/chat-component/src/components/chat-component.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { LitElement, html } from 'lit';
33
import DOMPurify from 'dompurify';
44
import { customElement, property, query, state } from 'lit/decorators.js';
55
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
6-
import { chatHttpOptions, globalConfig, teaserListTexts, requestOptions } from '../config/global-config.js';
6+
import {
7+
chatHttpOptions,
8+
globalConfig,
9+
teaserListTexts,
10+
requestOptions,
11+
MAX_CHAT_HISTORY,
12+
} from '../config/global-config.js';
713
import { chatStyle } from '../styles/chat-component.js';
814
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
915
import { produce } from 'immer';
@@ -384,7 +390,12 @@ export class ChatComponent extends LitElement {
384390
? html`<div class="chat-history__container">
385391
${this.renderChatThread(this.chatHistoryController.chatHistory)}
386392
<div class="chat-history__footer">
387-
${unsafeSVG(iconUp)} ${globalConfig.CHAT_HISTORY_FOOTER_TEXT} ${unsafeSVG(iconUp)}
393+
${unsafeSVG(iconUp)}
394+
${globalConfig.CHAT_HISTORY_FOOTER_TEXT.replace(
395+
globalConfig.CHAT_MAX_COUNT_TAG,
396+
MAX_CHAT_HISTORY,
397+
)}
398+
${unsafeSVG(iconUp)}
388399
</div>
389400
</div>`
390401
: ''}

packages/chat-component/src/components/chat-history-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type ReactiveController, type ReactiveControllerHost } from 'lit';
22
import { html } from 'lit';
3-
import { globalConfig } from '../config/global-config.js';
3+
import { globalConfig, MAX_CHAT_HISTORY } from '../config/global-config.js';
44

55
import iconHistory from '../../public/svg/history-icon.svg?raw';
66
import iconHistoryDismiss from '../../public/svg/history-dismiss-icon.svg?raw';
@@ -41,7 +41,7 @@ export class ChatHistoryController implements ReactiveController {
4141
}
4242
})
4343
.filter((index) => index !== undefined)
44-
.slice(-5);
44+
.slice(-MAX_CHAT_HISTORY);
4545

4646
// trim everything before the first user message
4747
const trimmedHistory = lastUserMessagesIndexes.length === 0 ? history : history.slice(lastUserMessagesIndexes[0]);

packages/chat-component/src/config/global-config.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const globalConfig = {
3636
CITATIONS_TAB_LABEL: 'Citations',
3737
SHOW_CHAT_HISTORY_LABEL: 'Show Chat History',
3838
HIDE_CHAT_HISTORY_LABEL: 'Hide Chat History',
39-
CHAT_HISTORY_FOOTER_TEXT: 'Showing past 5 conversations',
39+
CHAT_MAX_COUNT_TAG: '{MAX_CHAT_HISTORY}',
40+
CHAT_HISTORY_FOOTER_TEXT: 'Showing past {MAX_CHAT_HISTORY} conversations',
4041
};
4142

4243
const teaserListTexts = {
@@ -75,6 +76,16 @@ const chatHttpOptions = {
7576
stream: true,
7677
};
7778

79+
const MAX_CHAT_HISTORY = 5;
80+
7881
const APPROACH_MODEL = ['rrr', 'rtr'];
7982

80-
export { globalConfig, requestOptions, chatHttpOptions, NEXT_QUESTION_INDICATOR, APPROACH_MODEL, teaserListTexts };
83+
export {
84+
globalConfig,
85+
requestOptions,
86+
chatHttpOptions,
87+
NEXT_QUESTION_INDICATOR,
88+
APPROACH_MODEL,
89+
teaserListTexts,
90+
MAX_CHAT_HISTORY,
91+
};

0 commit comments

Comments
 (0)