Skip to content

Commit 2acdd7e

Browse files
author
Jicheng Lu
committed
revert markdown
1 parent 64e2cc4 commit 2acdd7e

File tree

7 files changed

+36
-16
lines changed

7 files changed

+36
-16
lines changed

src/lib/common/markdown/Markdown.svelte

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script>
2-
import SvelteMarkdown from 'svelte-markdown';
2+
import { marked } from 'marked';
33
import { replaceMarkdown, replaceNewLine } from '$lib/helpers/http';
4-
import CodeBlock from './CodeBlock.svelte';
54
65
/** @type {string} */
76
export let text;
@@ -17,19 +16,25 @@
1716
1817
let innerText = '';
1918
$: {
20-
innerText = !rawText ? replaceNewLine(replaceMarkdown(text || '')) : text;
19+
const markedText = !rawText ? replaceNewLine(marked(replaceMarkdown(text || ''))?.toString()) : marked(text || '')?.toString();
20+
if (!!markedText && markedText.endsWith('<br>')) {
21+
const idx = markedText.lastIndexOf('<br>');
22+
innerText = markedText.substring(0, idx);
23+
} else {
24+
innerText = markedText;
25+
}
2126
}
2227
</script>
2328
2429
<div
2530
class={`markdown-container markdown-lite ${containerClasses || 'text-white'}`}
2631
style={`${containerStyles}`}
2732
>
28-
<!-- {@html innerText} -->
29-
<SvelteMarkdown
33+
{@html innerText}
34+
<!-- <SvelteMarkdown
3035
source={innerText}
3136
renderers={{
3237
code: CodeBlock
3338
}}
34-
/>
39+
/> -->
3540
</div>

src/lib/helpers/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export const FILE_EDITORS = [
3131
EditorType.File
3232
];
3333

34-
export const LERNER_ID = "01acc3e5-0af7-49e6-ad7a-a760bd12dc40";
34+
export const LEARNER_ID = "01acc3e5-0af7-49e6-ad7a-a760bd12dc40";
35+
export const EVALUATOR_ID = "2cd4b805-7078-4405-87e9-2ec9aadf8a11";
3536
export const TRAINING_MODE = "training";
3637

3738
export const DEFAULT_KNOWLEDGE_COLLECTION = "BotSharp";

src/lib/scss/custom/common/_common.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,19 @@ button:focus {
185185
overflow-x: auto;
186186
scrollbar-width: thin;
187187

188+
&:has(.language-sql),
189+
&:has(.language-java),
190+
&:has(.language-javascript),
191+
&:has(.language-typescript),
192+
&:has(.language-csharp),
193+
&:has(.language-python),
194+
&:has(.language-json) {
195+
background-color: black;
196+
color: white;
197+
border-radius: 5px;
198+
padding: 5px 10px;
199+
}
200+
188201
pre {
189202
-ms-overflow-style: none !important;
190203
white-space: pre-wrap;

src/lib/scss/custom/pages/_chat.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,8 @@
770770
padding: 10px 15px;
771771
overflow-y: auto;
772772
scrollbar-width: none;
773-
height: 200px;
773+
height: fit-content;
774+
max-height: 200px;
774775

775776
.card-element-title {
776777
font-size: 0.85rem;

src/routes/chat/[agentId]/+page.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { getToken, setToken } from '$lib/services/auth-service.js'
99
import { getUserStore } from '$lib/helpers/store.js';
1010
import { conversationStore } from '$lib/helpers/store.js';
11-
import { LERNER_ID, TRAINING_MODE } from '$lib/helpers/constants';
11+
import { LEARNER_ID, TRAINING_MODE } from '$lib/helpers/constants';
1212
1313
const params = $page.params;
1414
@@ -29,7 +29,7 @@
2929
} else {
3030
await getToken("[email protected]", "123456", () => {
3131
console.log("login as guest.");
32-
});
32+
}, () => {});
3333
}
3434
3535
conversation = conversationStore.get();
@@ -43,7 +43,7 @@
4343
const chatUrl = new URL(`chat/${agentId}/${conversationId}`, window.location.origin);
4444
4545
const searchParams = new URLSearchParams();
46-
if (agentId === LERNER_ID) {
46+
if (agentId === LEARNER_ID) {
4747
searchParams.append('mode', TRAINING_MODE);
4848
}
4949

src/routes/chat/[agentId]/[conversationId]/chat-box.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
PUBLIC_LIVECHAT_ENABLE_TRAINING,
4444
PUBLIC_DEBUG_MODE
4545
} from '$env/static/public';
46-
import { BOT_SENDERS, LERNER_ID, TEXT_EDITORS, TRAINING_MODE, USER_SENDERS, ADMIN_ROLES } from '$lib/helpers/constants';
46+
import { BOT_SENDERS, LEARNER_ID, TRAINING_MODE, USER_SENDERS, ADMIN_ROLES } from '$lib/helpers/constants';
4747
import { signalr } from '$lib/services/signalr-service.js';
4848
import { webSpeech } from '$lib/services/web-speech.js';
4949
import { newConversation } from '$lib/services/conversation-service';
@@ -573,7 +573,7 @@
573573
function sendChatMessage(msgText, data = null, conversationId = null) {
574574
isSendingMsg = true;
575575
autoScrollLog = true;
576-
clearInstantLogs();
576+
clearInstantLogs();
577577
renewUserSentMessages(msgText);
578578
const agentId = params.agentId;
579579
const convId = conversationId || params.conversationId;
@@ -1530,7 +1530,7 @@
15301530
Add Tags
15311531
</DropdownItem>
15321532
{/if}
1533-
{#if agent?.id === LERNER_ID && mode === TRAINING_MODE}
1533+
{#if agent?.id === LEARNER_ID && mode === TRAINING_MODE}
15341534
<DropdownItem on:click={() => handleSaveKnowledge()}>Save Knowledge</DropdownItem>
15351535
{/if}
15361536
</DropdownMenu>

src/routes/page/agent/card-agent.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { Badge, Card, CardBody, Col } from '@sveltestrap/sveltestrap';
44
import { format } from '$lib/helpers/datetime';
55
import { _ } from 'svelte-i18n';
6-
import { LERNER_ID } from "$lib/helpers/constants";
6+
import { LEARNER_ID } from "$lib/helpers/constants";
77
88
/** @type {import('$agentTypes').AgentModel[]} */
99
export let agents;
@@ -73,7 +73,7 @@
7373
</li>
7474
{#if agent.is_public }
7575
<li class="list-inline-item me-1">
76-
<Link href={`/chat/${LERNER_ID}`} class="btn btn-primary btn-sm" target="_blank" disabled>
76+
<Link href={`/chat/${LEARNER_ID}`} class="btn btn-primary btn-sm" target="_blank" disabled>
7777
<i class="bx bx-book-open" /> {$_('Train')}
7878
</Link>
7979
</li>

0 commit comments

Comments
 (0)