machineuser commited on
Commit
ae43bf0
1 Parent(s): 790ed2e

Sync widgets demo

Browse files
packages/tasks/src/tokenizer-data.ts CHANGED
@@ -28,5 +28,5 @@ export type SpecialTokensMap = {
28
  */
29
  export interface TokenizerConfig extends SpecialTokensMap {
30
  use_default_system_prompt?: boolean;
31
- chat_template?: string;
32
  }
 
28
  */
29
  export interface TokenizerConfig extends SpecialTokensMap {
30
  use_default_system_prompt?: boolean;
31
+ chat_template?: string | Array<{ name: string; template: string }>;
32
  }
packages/widgets/src/lib/components/InferenceWidget/widgets/ConversationalWidget/ConversationalWidget.svelte CHANGED
@@ -65,11 +65,19 @@
65
  }
66
  tokenizerConfig = config.tokenizer_config;
67
 
68
- const chatTemplate = tokenizerConfig.chat_template;
69
  if (chatTemplate === undefined) {
70
  error = "No chat template found in tokenizer config";
71
  return;
72
  }
 
 
 
 
 
 
 
 
73
  try {
74
  compiledTemplate = new Template(chatTemplate);
75
  } catch (e) {
 
65
  }
66
  tokenizerConfig = config.tokenizer_config;
67
 
68
+ let chatTemplate = tokenizerConfig.chat_template;
69
  if (chatTemplate === undefined) {
70
  error = "No chat template found in tokenizer config";
71
  return;
72
  }
73
+ if (Array.isArray(chatTemplate)) {
74
+ chatTemplate =
75
+ chatTemplate.find((template) => template.name === "default")?.template ?? chatTemplate[0]?.template;
76
+ }
77
+ if (!chatTemplate) {
78
+ error = "No chat template found in tokenizer config";
79
+ return;
80
+ }
81
  try {
82
  compiledTemplate = new Template(chatTemplate);
83
  } catch (e) {