support system messages in code snippets
Browse files
src/lib/components/InferencePlayground/InferencePlayground.svelte
CHANGED
@@ -40,11 +40,6 @@
|
|
40 |
let waitForNonStreaming = true;
|
41 |
|
42 |
$: systemPromptSupported = isSystemPromptSupported(conversation.model);
|
43 |
-
$: {
|
44 |
-
if (!systemPromptSupported) {
|
45 |
-
conversation.systemMessage = { role: "system", content: "" };
|
46 |
-
}
|
47 |
-
}
|
48 |
|
49 |
function addMessage() {
|
50 |
conversation.messages = [
|
@@ -162,7 +157,8 @@
|
|
162 |
placeholder={systemPromptSupported
|
163 |
? "Enter a custom prompt"
|
164 |
: "System prompt is not supported with the chosen model."}
|
165 |
-
|
|
|
166 |
class="absolute inset-x-0 bottom-0 h-full resize-none bg-transparent px-3 pt-10 text-sm outline-none"
|
167 |
></textarea>
|
168 |
</div>
|
|
|
40 |
let waitForNonStreaming = true;
|
41 |
|
42 |
$: systemPromptSupported = isSystemPromptSupported(conversation.model);
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
function addMessage() {
|
45 |
conversation.messages = [
|
|
|
157 |
placeholder={systemPromptSupported
|
158 |
? "Enter a custom prompt"
|
159 |
: "System prompt is not supported with the chosen model."}
|
160 |
+
value={systemPromptSupported ? conversation.systemMessage.content : ""}
|
161 |
+
on:input={e => (conversation.systemMessage.content = e.currentTarget.value)}
|
162 |
class="absolute inset-x-0 bottom-0 h-full resize-none bg-transparent px-3 pt-10 text-sm outline-none"
|
163 |
></textarea>
|
164 |
</div>
|
src/lib/components/InferencePlayground/InferencePlaygroundCodeSnippets.svelte
CHANGED
@@ -8,6 +8,7 @@
|
|
8 |
import http from "highlight.js/lib/languages/http";
|
9 |
|
10 |
import IconCopyCode from "../Icons/IconCopyCode.svelte";
|
|
|
11 |
|
12 |
hljs.registerLanguage("javascript", javascript);
|
13 |
hljs.registerLanguage("python", python);
|
@@ -46,10 +47,17 @@
|
|
46 |
|
47 |
function getMessages() {
|
48 |
const placeholder = [{ role: "user", content: "Tell me a story" }];
|
49 |
-
|
|
|
50 |
if (messages.length === 1 && messages[0].role === "user" && !messages[0].content) {
|
51 |
messages = placeholder;
|
52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
return messages;
|
54 |
}
|
55 |
|
|
|
8 |
import http from "highlight.js/lib/languages/http";
|
9 |
|
10 |
import IconCopyCode from "../Icons/IconCopyCode.svelte";
|
11 |
+
import { isSystemPromptSupported } from "./inferencePlaygroundUtils";
|
12 |
|
13 |
hljs.registerLanguage("javascript", javascript);
|
14 |
hljs.registerLanguage("python", python);
|
|
|
47 |
|
48 |
function getMessages() {
|
49 |
const placeholder = [{ role: "user", content: "Tell me a story" }];
|
50 |
+
|
51 |
+
let messages = [...conversation.messages];
|
52 |
if (messages.length === 1 && messages[0].role === "user" && !messages[0].content) {
|
53 |
messages = placeholder;
|
54 |
}
|
55 |
+
|
56 |
+
const { model, systemMessage } = conversation;
|
57 |
+
if (isSystemPromptSupported(model) && systemMessage.content?.length) {
|
58 |
+
messages.unshift(systemMessage);
|
59 |
+
}
|
60 |
+
|
61 |
return messages;
|
62 |
}
|
63 |
|