{{ $t('Start the conversation') }}
-{{ $t('Give any input to begin') }}
-{{ $t('Start the conversation') }}
+{{ $t('Give any input to begin') }}
+- {{ content }} -
-Error occured
@@ -56,12 +25,11 @@ + + \ No newline at end of file diff --git a/custom/package.json b/custom/package.json index bea611a..2e8953c 100644 --- a/custom/package.json +++ b/custom/package.json @@ -21,6 +21,7 @@ "dompurify": "^3.3.3", "katex": "^0.16.45", "marked": "^18.0.0", - "vega-embed": "^7.1.0" + "vega-embed": "^7.1.0", + "vue-custom-scrollbar": "^2.0.2" } } diff --git a/custom/pnpm-lock.yaml b/custom/pnpm-lock.yaml index 15d5382..c5c0f92 100644 --- a/custom/pnpm-lock.yaml +++ b/custom/pnpm-lock.yaml @@ -41,6 +41,9 @@ importers: vega-embed: specifier: ^7.1.0 version: 7.1.0(vega-lite@6.4.2(vega@6.2.0))(vega@6.2.0) + vue-custom-scrollbar: + specifier: ^2.0.2 + version: 2.0.2(vue@3.5.32) packages: @@ -653,6 +656,9 @@ packages: parse-entities@4.0.2: resolution: {integrity: sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw==} + perfect-scrollbar@1.5.6: + resolution: {integrity: sha512-rixgxw3SxyJbCaSpo1n35A/fwI1r2rdwMKOTCg/AcG+xOEyZcE8UHVjpZMFCVImzsFoCZeJTT+M/rdEIQYO2nw==} + picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -873,6 +879,11 @@ packages: vfile@6.0.3: resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==} + vue-custom-scrollbar@2.0.2: + resolution: {integrity: sha512-eRyxGb7UFLLH8P0B8FDux2uPrzNBH0X6IN+A/RB5sfmLq1ym7shbCPVKua1pC7LPqPB7dc86evFXyWO/svrfKA==} + peerDependencies: + vue: ^3.3.0 + vue@3.5.32: resolution: {integrity: sha512-vM4z4Q9tTafVfMAK7IVzmxg34rSzTFMyIe0UUEijUCkn9+23lj0WRfA83dg7eQZIUlgOSGrkViIaCfqSAUXsMw==} peerDependencies: @@ -1755,6 +1766,8 @@ snapshots: is-decimal: 2.0.1 is-hexadecimal: 2.0.1 + perfect-scrollbar@1.5.6: {} + picocolors@1.1.1: {} postcss@8.5.10: @@ -2129,6 +2142,11 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.3 + vue-custom-scrollbar@2.0.2(vue@3.5.32): + dependencies: + perfect-scrollbar: 1.5.6 + vue: 3.5.32 + vue@3.5.32: dependencies: '@vue/compiler-dom': 3.5.32 diff --git a/custom/types.ts b/custom/types.ts index 0d6ed0a..719737c 100644 --- a/custom/types.ts +++ b/custom/types.ts @@ -7,12 +7,22 @@ export interface IPartData { durationMs?: number; } export interface IPart { - type: string; + type: 'reasoning' | 'data-tool-call' | 'text'; text?: string; state?: 'started' | 'thinking' | 'processing' | 'streaming' | 'done'; data?: IPartData; } +export interface IFormattedToolCallPart { + type: 'data-tool-call'; + toolInfo: IPartData; +} + +export interface IToolGroup { + title: string; + groupedTools: IFormattedToolCallPart[]; +} + export interface IMessage { id: string; role: 'user' | 'assistant'; diff --git a/custom/utils.ts b/custom/utils.ts index c40e9d2..2df30f8 100644 --- a/custom/utils.ts +++ b/custom/utils.ts @@ -1,3 +1,5 @@ +import { IMessage, IPart } from "./types"; + export function remToPx(rem: number): number { const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize); return rem * rootFontSize; @@ -7,3 +9,30 @@ export function pxToRem(px: number): number { const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize); return px / rootFontSize; } + + +export function getMessageParts(message: IMessage): IPart[] { + return message.parts?.length + ? message.parts + : [{ text: '', type: 'reasoning', state: 'streaming' }]; +} + +function addNewLineBeforeTitles(text: string): string { + return text.replace(/(\*\*[^*]+\*\*)/g, '\n\n$1'); +} + +export function extractTitleAndTextFromReasoning(reasoningText: string): { title: string | null; body: string } { + const match = reasoningText.match(/^\*\*(.*?)\*\*(.*)$/s); + + if (!match) { + return { + title: null, + body: addNewLineBeforeTitles(reasoningText) + }; + } + + return { + title: match[1].trim(), + body: addNewLineBeforeTitles(match[2].trim()) + }; +} \ No newline at end of file