Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
more typing
Browse files
src/lib/components/InferencePlayground/InferencePlaygroundCodeSnippets.svelte
CHANGED
|
@@ -29,6 +29,12 @@
|
|
| 29 |
language?: Language;
|
| 30 |
}
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
$: snippetsByLanguage = {
|
| 33 |
javascript: getJavascriptSnippets(conversation),
|
| 34 |
python: getPythonSnippets(conversation),
|
|
@@ -52,14 +58,14 @@
|
|
| 52 |
}
|
| 53 |
|
| 54 |
function getJavascriptSnippets(conversation: Conversation) {
|
| 55 |
-
const formattedMessages = ({ sep, start, end }) =>
|
| 56 |
start +
|
| 57 |
getMessages()
|
| 58 |
.map(({ role, content }) => `{ role: "${role}", content: "${content}" }`)
|
| 59 |
.join(sep) +
|
| 60 |
end;
|
| 61 |
|
| 62 |
-
const formattedConfig = ({ sep, start, end }) =>
|
| 63 |
start +
|
| 64 |
Object.entries(conversation.config)
|
| 65 |
.map(([key, val]) => `${key}: ${val}`)
|
|
@@ -118,14 +124,14 @@ console.log(out.choices[0].message);`,
|
|
| 118 |
}
|
| 119 |
|
| 120 |
function getPythonSnippets(conversation: Conversation) {
|
| 121 |
-
const formattedMessages = ({ sep, start, end }) =>
|
| 122 |
start +
|
| 123 |
getMessages()
|
| 124 |
.map(({ role, content }) => `{ "role": "${role}", "content": "${content}" }`)
|
| 125 |
.join(sep) +
|
| 126 |
end;
|
| 127 |
|
| 128 |
-
const formattedConfig = ({ sep, start, end }) =>
|
| 129 |
start +
|
| 130 |
Object.entries(conversation.config)
|
| 131 |
.map(([key, val]) => `${key}: ${val}`)
|
|
@@ -178,14 +184,14 @@ print(output.choices[0].message)`,
|
|
| 178 |
}
|
| 179 |
|
| 180 |
function getHttpSnippets(conversation: Conversation) {
|
| 181 |
-
const formattedMessages = ({ sep, start, end }) =>
|
| 182 |
start +
|
| 183 |
getMessages()
|
| 184 |
.map(({ role, content }) => `{ "role": "${role}", "content": "${content}" }`)
|
| 185 |
.join(sep) +
|
| 186 |
end;
|
| 187 |
|
| 188 |
-
const formattedConfig = ({ sep, start, end }) =>
|
| 189 |
start +
|
| 190 |
Object.entries(conversation.config)
|
| 191 |
.map(([key, val]) => `"${key}": ${val}`)
|
|
|
|
| 29 |
language?: Language;
|
| 30 |
}
|
| 31 |
|
| 32 |
+
interface MessagesJoiner {
|
| 33 |
+
sep: string;
|
| 34 |
+
start: string;
|
| 35 |
+
end: string;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
$: snippetsByLanguage = {
|
| 39 |
javascript: getJavascriptSnippets(conversation),
|
| 40 |
python: getPythonSnippets(conversation),
|
|
|
|
| 58 |
}
|
| 59 |
|
| 60 |
function getJavascriptSnippets(conversation: Conversation) {
|
| 61 |
+
const formattedMessages = ({ sep, start, end }: MessagesJoiner) =>
|
| 62 |
start +
|
| 63 |
getMessages()
|
| 64 |
.map(({ role, content }) => `{ role: "${role}", content: "${content}" }`)
|
| 65 |
.join(sep) +
|
| 66 |
end;
|
| 67 |
|
| 68 |
+
const formattedConfig = ({ sep, start, end }: MessagesJoiner) =>
|
| 69 |
start +
|
| 70 |
Object.entries(conversation.config)
|
| 71 |
.map(([key, val]) => `${key}: ${val}`)
|
|
|
|
| 124 |
}
|
| 125 |
|
| 126 |
function getPythonSnippets(conversation: Conversation) {
|
| 127 |
+
const formattedMessages = ({ sep, start, end }: MessagesJoiner) =>
|
| 128 |
start +
|
| 129 |
getMessages()
|
| 130 |
.map(({ role, content }) => `{ "role": "${role}", "content": "${content}" }`)
|
| 131 |
.join(sep) +
|
| 132 |
end;
|
| 133 |
|
| 134 |
+
const formattedConfig = ({ sep, start, end }: MessagesJoiner) =>
|
| 135 |
start +
|
| 136 |
Object.entries(conversation.config)
|
| 137 |
.map(([key, val]) => `${key}: ${val}`)
|
|
|
|
| 184 |
}
|
| 185 |
|
| 186 |
function getHttpSnippets(conversation: Conversation) {
|
| 187 |
+
const formattedMessages = ({ sep, start, end }: MessagesJoiner) =>
|
| 188 |
start +
|
| 189 |
getMessages()
|
| 190 |
.map(({ role, content }) => `{ "role": "${role}", "content": "${content}" }`)
|
| 191 |
.join(sep) +
|
| 192 |
end;
|
| 193 |
|
| 194 |
+
const formattedConfig = ({ sep, start, end }: MessagesJoiner) =>
|
| 195 |
start +
|
| 196 |
Object.entries(conversation.config)
|
| 197 |
.map(([key, val]) => `"${key}": ${val}`)
|