Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/lib/common/markdown/Markdown.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script>
import SvelteMarkdown from 'svelte-markdown';
import { marked } from 'marked';
import { replaceMarkdown, replaceNewLine } from '$lib/helpers/http';
import CodeBlock from './CodeBlock.svelte';

/** @type {string} */
export let text;
Expand All @@ -17,19 +16,25 @@

let innerText = '';
$: {
innerText = !rawText ? replaceNewLine(replaceMarkdown(text || '')) : text;
const markedText = !rawText ? replaceNewLine(marked(replaceMarkdown(text || ''))?.toString()) : marked(text || '')?.toString();
if (!!markedText && markedText.endsWith('<br>')) {
const idx = markedText.lastIndexOf('<br>');
innerText = markedText.substring(0, idx);
} else {
innerText = markedText;
}
}
</script>

<div
class={`markdown-container markdown-lite ${containerClasses || 'text-white'}`}
style={`${containerStyles}`}
>
<!-- {@html innerText} -->
<SvelteMarkdown
{@html innerText}
<!-- <SvelteMarkdown
source={innerText}
renderers={{
code: CodeBlock
}}
/>
/> -->
</div>
3 changes: 2 additions & 1 deletion src/lib/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const FILE_EDITORS = [
EditorType.File
];

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

export const DEFAULT_KNOWLEDGE_COLLECTION = "BotSharp";
13 changes: 13 additions & 0 deletions src/lib/scss/custom/common/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@ button:focus {
overflow-x: auto;
scrollbar-width: thin;

&:has(.language-sql),
&:has(.language-java),
&:has(.language-javascript),
&:has(.language-typescript),
&:has(.language-csharp),
&:has(.language-python),
&:has(.language-json) {
background-color: black;
color: white;
border-radius: 5px;
padding: 5px 10px;
}

pre {
-ms-overflow-style: none !important;
white-space: pre-wrap;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/scss/custom/pages/_chat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,8 @@
padding: 10px 15px;
overflow-y: auto;
scrollbar-width: none;
height: 200px;
height: fit-content;
max-height: 200px;

.card-element-title {
font-size: 0.85rem;
Expand Down
6 changes: 3 additions & 3 deletions src/routes/chat/[agentId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { getToken, setToken } from '$lib/services/auth-service.js'
import { getUserStore } from '$lib/helpers/store.js';
import { conversationStore } from '$lib/helpers/store.js';
import { LERNER_ID, TRAINING_MODE } from '$lib/helpers/constants';
import { LEARNER_ID, TRAINING_MODE } from '$lib/helpers/constants';

const params = $page.params;

Expand All @@ -29,7 +29,7 @@
} else {
await getToken("guest@gmail.com", "123456", () => {
console.log("login as guest.");
});
}, () => {});
}

conversation = conversationStore.get();
Expand All @@ -43,7 +43,7 @@
const chatUrl = new URL(`chat/${agentId}/${conversationId}`, window.location.origin);

const searchParams = new URLSearchParams();
if (agentId === LERNER_ID) {
if (agentId === LEARNER_ID) {
searchParams.append('mode', TRAINING_MODE);
}

Expand Down
6 changes: 3 additions & 3 deletions src/routes/chat/[agentId]/[conversationId]/chat-box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
PUBLIC_LIVECHAT_ENABLE_TRAINING,
PUBLIC_DEBUG_MODE
} from '$env/static/public';
import { BOT_SENDERS, LERNER_ID, TEXT_EDITORS, TRAINING_MODE, USER_SENDERS, ADMIN_ROLES } from '$lib/helpers/constants';
import { BOT_SENDERS, LEARNER_ID, TRAINING_MODE, USER_SENDERS, ADMIN_ROLES } from '$lib/helpers/constants';
import { signalr } from '$lib/services/signalr-service.js';
import { webSpeech } from '$lib/services/web-speech.js';
import { newConversation } from '$lib/services/conversation-service';
Expand Down Expand Up @@ -573,7 +573,7 @@
function sendChatMessage(msgText, data = null, conversationId = null) {
isSendingMsg = true;
autoScrollLog = true;
clearInstantLogs();
clearInstantLogs();
renewUserSentMessages(msgText);
const agentId = params.agentId;
const convId = conversationId || params.conversationId;
Expand Down Expand Up @@ -1530,7 +1530,7 @@
Add Tags
</DropdownItem>
{/if}
{#if agent?.id === LERNER_ID && mode === TRAINING_MODE}
{#if agent?.id === LEARNER_ID && mode === TRAINING_MODE}
<DropdownItem on:click={() => handleSaveKnowledge()}>Save Knowledge</DropdownItem>
{/if}
</DropdownMenu>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/page/agent/card-agent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Badge, Card, CardBody, Col } from '@sveltestrap/sveltestrap';
import { format } from '$lib/helpers/datetime';
import { _ } from 'svelte-i18n';
import { LERNER_ID } from "$lib/helpers/constants";
import { LEARNER_ID } from "$lib/helpers/constants";

/** @type {import('$agentTypes').AgentModel[]} */
export let agents;
Expand Down Expand Up @@ -73,7 +73,7 @@
</li>
{#if agent.is_public }
<li class="list-inline-item me-1">
<Link href={`/chat/${LERNER_ID}`} class="btn btn-primary btn-sm" target="_blank" disabled>
<Link href={`/chat/${LEARNER_ID}`} class="btn btn-primary btn-sm" target="_blank" disabled>
<i class="bx bx-book-open" /> {$_('Train')}
</Link>
</li>
Expand Down
Loading