Spaces:
Sleeping
Sleeping
fix cohere models
Browse files
src/lib/JsonEditor/JsonEditor.svelte
CHANGED
|
@@ -136,7 +136,11 @@
|
|
| 136 |
if (exampleHelloWorld) {
|
| 137 |
exampleInputs = [
|
| 138 |
...exampleInputs,
|
| 139 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
];
|
| 141 |
}
|
| 142 |
|
|
@@ -144,7 +148,11 @@
|
|
| 144 |
if (exampleReasoning) {
|
| 145 |
exampleInputs = [
|
| 146 |
...exampleInputs,
|
| 147 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
];
|
| 149 |
}
|
| 150 |
|
|
@@ -152,7 +160,11 @@
|
|
| 152 |
if (exampleToolUsage) {
|
| 153 |
exampleInputs = [
|
| 154 |
...exampleInputs,
|
| 155 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
];
|
| 157 |
}
|
| 158 |
|
|
@@ -170,10 +182,6 @@
|
|
| 170 |
}
|
| 171 |
}
|
| 172 |
|
| 173 |
-
exampleInputs = exampleInputs.map((exampleInput) =>
|
| 174 |
-
transformInput(exampleInput, selectedTemplate.template)
|
| 175 |
-
);
|
| 176 |
-
|
| 177 |
content = exampleInputs.at(-1)?.content ?? {};
|
| 178 |
selectedExampleInputId = exampleInputs.at(-1)?.id ?? '';
|
| 179 |
value = JSON5.stringify(content, null, 2);
|
|
|
|
| 136 |
if (exampleHelloWorld) {
|
| 137 |
exampleInputs = [
|
| 138 |
...exampleInputs,
|
| 139 |
+
{
|
| 140 |
+
id: 'hello-world',
|
| 141 |
+
label: 'hello world example',
|
| 142 |
+
content: transformInput(exampleHelloWorld, selectedTemplate.template)
|
| 143 |
+
}
|
| 144 |
];
|
| 145 |
}
|
| 146 |
|
|
|
|
| 148 |
if (exampleReasoning) {
|
| 149 |
exampleInputs = [
|
| 150 |
...exampleInputs,
|
| 151 |
+
{
|
| 152 |
+
id: 'reasoning',
|
| 153 |
+
label: 'reasoning example',
|
| 154 |
+
content: transformInput(exampleReasoning, selectedTemplate.template)
|
| 155 |
+
}
|
| 156 |
];
|
| 157 |
}
|
| 158 |
|
|
|
|
| 160 |
if (exampleToolUsage) {
|
| 161 |
exampleInputs = [
|
| 162 |
...exampleInputs,
|
| 163 |
+
{
|
| 164 |
+
id: 'tool-usage',
|
| 165 |
+
label: 'tool usage example',
|
| 166 |
+
content: transformInput(exampleToolUsage, selectedTemplate.template)
|
| 167 |
+
}
|
| 168 |
];
|
| 169 |
}
|
| 170 |
|
|
|
|
| 182 |
}
|
| 183 |
}
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
content = exampleInputs.at(-1)?.content ?? {};
|
| 186 |
selectedExampleInputId = exampleInputs.at(-1)?.id ?? '';
|
| 187 |
value = JSON5.stringify(content, null, 2);
|
src/lib/example-inputs/helloWorld.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import { Template } from '@huggingface/jinja';
|
|
|
|
| 2 |
|
| 3 |
const variations = {
|
| 4 |
variation1_with_system_prompt: {
|
|
@@ -50,7 +51,9 @@ const variations = {
|
|
| 50 |
export function getExampleHelloWorld(templateStr: string): Record<string, unknown> | undefined {
|
| 51 |
const template = new Template(templateStr);
|
| 52 |
const variationSystemPrompt = variations.variation1_with_system_prompt.example;
|
| 53 |
-
const variationSystemPromptRendered = template.render(
|
|
|
|
|
|
|
| 54 |
if (variationSystemPromptRendered.includes('You are a helpful assistant.')) {
|
| 55 |
return variations.variation1_with_system_prompt.example;
|
| 56 |
}
|
|
|
|
| 1 |
import { Template } from '@huggingface/jinja';
|
| 2 |
+
import { transformInput } from '$lib/utils/transformInput';
|
| 3 |
|
| 4 |
const variations = {
|
| 5 |
variation1_with_system_prompt: {
|
|
|
|
| 51 |
export function getExampleHelloWorld(templateStr: string): Record<string, unknown> | undefined {
|
| 52 |
const template = new Template(templateStr);
|
| 53 |
const variationSystemPrompt = variations.variation1_with_system_prompt.example;
|
| 54 |
+
const variationSystemPromptRendered = template.render(
|
| 55 |
+
transformInput(variationSystemPrompt, templateStr)
|
| 56 |
+
);
|
| 57 |
if (variationSystemPromptRendered.includes('You are a helpful assistant.')) {
|
| 58 |
return variations.variation1_with_system_prompt.example;
|
| 59 |
}
|
src/lib/example-inputs/reasoning.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import { Template } from '@huggingface/jinja';
|
| 2 |
|
| 3 |
const variations = {
|
|
@@ -55,7 +56,9 @@ export function getExampleReasoning(templateStr: string): Record<string, unknown
|
|
| 55 |
}
|
| 56 |
const template = new Template(templateStr);
|
| 57 |
const variationSystemPrompt = variations.variation1_with_system_prompt.example;
|
| 58 |
-
const variationSystemPromptRendered = template.render(
|
|
|
|
|
|
|
| 59 |
if (variationSystemPromptRendered.includes('You are a helpful assistant.')) {
|
| 60 |
return variations.variation1_with_system_prompt.example;
|
| 61 |
}
|
|
|
|
| 1 |
+
import { transformInput } from '$lib/utils/transformInput';
|
| 2 |
import { Template } from '@huggingface/jinja';
|
| 3 |
|
| 4 |
const variations = {
|
|
|
|
| 56 |
}
|
| 57 |
const template = new Template(templateStr);
|
| 58 |
const variationSystemPrompt = variations.variation1_with_system_prompt.example;
|
| 59 |
+
const variationSystemPromptRendered = template.render(
|
| 60 |
+
transformInput(variationSystemPrompt, templateStr)
|
| 61 |
+
);
|
| 62 |
if (variationSystemPromptRendered.includes('You are a helpful assistant.')) {
|
| 63 |
return variations.variation1_with_system_prompt.example;
|
| 64 |
}
|
src/lib/example-inputs/toolUsage.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import { Template } from '@huggingface/jinja';
|
| 2 |
|
| 3 |
const variations = {
|
|
@@ -383,7 +384,7 @@ export function getExampleToolUsage(templateStr: string): Record<string, unknown
|
|
| 383 |
const template = new Template(templateStr);
|
| 384 |
for (const variation of Object.values(variations)) {
|
| 385 |
try {
|
| 386 |
-
const variationRendered = template.render(variation.example);
|
| 387 |
if (variationRendered.includes('get_weather')) {
|
| 388 |
return variation.example;
|
| 389 |
}
|
|
|
|
| 1 |
+
import { transformInput } from '$lib/utils/transformInput';
|
| 2 |
import { Template } from '@huggingface/jinja';
|
| 3 |
|
| 4 |
const variations = {
|
|
|
|
| 384 |
const template = new Template(templateStr);
|
| 385 |
for (const variation of Object.values(variations)) {
|
| 386 |
try {
|
| 387 |
+
const variationRendered = template.render(transformInput(variation.example, templateStr));
|
| 388 |
if (variationRendered.includes('get_weather')) {
|
| 389 |
return variation.example;
|
| 390 |
}
|
src/lib/utils/transformInput.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
| 1 |
-
export function transformInput(
|
| 2 |
-
input: { id: string; label: string; content: Record<string, unknown> },
|
| 3 |
-
templateStr: string
|
| 4 |
-
) {
|
| 5 |
// handle cohere special case
|
| 6 |
if (templateStr.includes('safety_mode')) {
|
| 7 |
-
input.
|
| 8 |
}
|
| 9 |
return input;
|
| 10 |
}
|
|
|
|
| 1 |
+
export function transformInput(input: Record<string, unknown>, templateStr: string) {
|
|
|
|
|
|
|
|
|
|
| 2 |
// handle cohere special case
|
| 3 |
if (templateStr.includes('safety_mode')) {
|
| 4 |
+
input.safety_mode = '';
|
| 5 |
}
|
| 6 |
return input;
|
| 7 |
}
|