modprompt 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +15 -1
- package/dist/main.min.js +1 -1
- package/package.json +15 -15
package/dist/main.js
CHANGED
|
@@ -328,7 +328,7 @@ const templates = {
|
|
|
328
328
|
"system": 2,
|
|
329
329
|
},
|
|
330
330
|
"system": {
|
|
331
|
-
"schema": "<<SYS>>\n{
|
|
331
|
+
"schema": "<<SYS>>\n{system}\n<</SYS>>",
|
|
332
332
|
},
|
|
333
333
|
},
|
|
334
334
|
"gemma": {
|
|
@@ -339,6 +339,20 @@ const templates = {
|
|
|
339
339
|
"stop": ["<end_of_turn>"],
|
|
340
340
|
"afterShot": "\n"
|
|
341
341
|
},
|
|
342
|
+
"nemotron": {
|
|
343
|
+
"id": "nemotron",
|
|
344
|
+
"name": "Nemotron",
|
|
345
|
+
"user": "<extra_id_1>User\n{prompt}",
|
|
346
|
+
"assistant": "<extra_id_1>Assistant",
|
|
347
|
+
"linebreaks": {
|
|
348
|
+
"system": 2,
|
|
349
|
+
"user": 1,
|
|
350
|
+
},
|
|
351
|
+
"system": {
|
|
352
|
+
"schema": "<extra_id_0>System\n{system}"
|
|
353
|
+
},
|
|
354
|
+
"afterShot": "\n\n"
|
|
355
|
+
}
|
|
342
356
|
};
|
|
343
357
|
|
|
344
358
|
/**
|
package/dist/main.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var $tpl=function(s){"use strict";const e={none:{id:"none",name:"No template",user:"{prompt}",assistant:""},alpaca:{id:"alpaca",name:"Alpaca",system:{schema:"{system}",message:"Below is an instruction that describes a task. Write a response that appropriately completes the request."},user:"### Instruction:\n{prompt}",assistant:"### Response:",linebreaks:{system:2,user:2}},llama:{id:"llama",name:"Llama",system:{schema:"[INST] <<SYS>>\n{system}\n<</SYS>>",message:"You are a helpful, respectful and honest assistant. Always answer as helpfully as possible\n\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information."},user:"{prompt}",assistant:" [/INST] ",linebreaks:{system:2,user:0},prefix:"<s>",stop:["</s>"]},mistral:{id:"mistral",name:"Mistral",user:"[INST] {prompt}",assistant:" [/INST]",stop:["</s>"],afterShot:"\n"},orca:{id:"orca",name:"Orca",system:{schema:"### System:\n{system}",message:"You are an AI assistant that follows instruction extremely well. Help as much as you can."},user:"### User:\n{prompt}",assistant:"### Response:",linebreaks:{system:2,user:2}},vicuna:{id:"vicuna",name:"Vicuna",user:"USER: {prompt}",assistant:"### ASSISTANT:",linebreaks:{user:2}},vicuna_system:{id:"vicuna_system",name:"Vicuna system",system:{schema:"SYSTEM: {system}"},user:"USER: {prompt}",assistant:"### ASSISTANT:",linebreaks:{system:2,user:2}},wizard_vicuna:{id:"wizard_vicuna",name:"Wizard Vicuna",user:"### Human:\n{prompt}",assistant:"### ASSISTANT:",linebreaks:{user:2},stop:["<|endoftext|>"]},guanaco:{id:"guanaco",name:"Guanaco",user:"### Human: {prompt}",assistant:"### Assistant:",linebreaks:{user:1}},chatml:{id:"chatml",name:"ChatMl",system:{schema:"<|im_start|>system\n{system}\n<|im_end|>"},user:"<|im_start|>user\n{prompt}<|im_end|>",assistant:"<|im_start|>assistant",linebreaks:{system:1,user:1,assistant:1},stop:["<|im_end|>"],afterShot:" <|im_end|>"},zephyr:{id:"zephyr",name:"Zephyr",system:{schema:"<|system|>\n{system}<|endoftext|>"},user:"<|user|>\n{prompt}<|endoftext|>",assistant:"<|assistant|>",linebreaks:{system:1,user:1,assistant:1},afterShot:"\n",stop:["<|endoftext|>"]},octopus:{id:"octopus",name:"Octopus",system:{schema:"<|system|>{system}<|end|>",message:"You are a router. Below is the query from the users, please call the correct function and generate the parameters to call the function."},user:"<|user|>{prompt}<|end|>",assistant:"<|assistant|>",afterShot:"\n",stop:["<|end|>"]},llava:{id:"llava",name:"Llava",user:"USER: {prompt}",assistant:"ASSISTANT:",linebreaks:{user:1}},"synthia-cot":{id:"synthia-cot",name:"Synthia CoT",system:{schema:"SYSTEM: {system}",message:"Elaborate on the topic using a Tree of Thoughts and backtrack when necessary to construct a clear, cohesive Chain of Thought reasoning. Always answer without hesitation."},user:"USER: {prompt}",assistant:"ASSISTANT:",linebreaks:{system:1,user:1}},wizardlm:{id:"wizardlm",name:"WizardLM",system:{schema:"{system}",message:"You are a helpful AI assistant."},user:"USER: {prompt}",assistant:"ASSISTANT:",linebreaks:{user:1}},openchat:{id:"openchat",name:"OpenChat",user:"GPT4 User: {prompt}<|end_of_turn|>",assistant:"GPT4 Assistant:",stop:["<|end_of_turn|>"]},"openchat-correct":{id:"openchat-correct",name:"OpenChat correct",user:"GPT4 Correct User: {prompt}<|end_of_turn|>",assistant:"GPT4 Correct Assistant:",stop:["<|end_of_turn|>"]},human_response:{id:"human_response",name:"Human response",user:"### HUMAN:\n{prompt}",assistant:"### RESPONSE:",linebreaks:{user:2,assistant:1}},minichat:{id:"minichat",name:"Minichat",user:"[|User|] {prompt} </s>",assistant:"[|Assistant|]",stop:["</s>","[|User|]"],afterShot:"\n",prefix:"<s> "},phi:{id:"phi",name:"Phi",user:"Instruct: {prompt}",assistant:"Output:",linebreaks:{user:1},stop:["</s>","Instruct:"]},phi3:{id:"phi3",name:"Phi 3",user:"<|user|> {prompt}<|end|>",assistant:"<|assistant|>",system:{schema:"<|system|> {system}<|end|>"},afterShot:"<|end|>\n",stop:["<|end|>","<|user|>"]},deepseek:{id:"deepseek",name:"Deepseek",system:{schema:"{system}",message:"You are an AI programming assistant, utilizing the DeepSeek Coder model, developed by DeepSeek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer."},afterShot:"\n",user:"### Instruction:\n{prompt}",assistant:"### Response:",linebreaks:{user:1,system:1},stop:["<|EOT|>","### Instruction:"]},deepseek2:{id:"deepseek2",name:"Deepseek v2",system:{schema:"<|begin▁of▁sentence|>{system}"},user:"User: {prompt}",assistant:"Assistant:",linebreaks:{user:2,system:2},stop:["<|end▁of▁sentence|>","<|tool▁calls▁end|>"]},opencodeinterpreter:{id:"opencodeinterpreter",name:"Open code interpreter",user:"<|User|>\n{prompt}",assistant:"<|Assistant|>",linebreaks:{user:2},stop:["<|EOT|>","<|User|>"]},cerebrum:{id:"cerebrum",name:"Cerebrum",system:{schema:"{system}",message:"A chat between a user and a thinking artificial intelligence assistant. The assistant describes its thought process and gives helpful and detailed answers to the user's questions."},user:"User: {prompt}",assistant:"Ai:",linebreaks:{user:1},prefix:"<s>",stop:["</s>"]},"command-r":{id:"command-r",name:"Command-R",user:"<|START_OF_TURN_TOKEN|><|USER_TOKEN|>{prompt}<|END_OF_TURN_TOKEN|>",assistant:"<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>",prefix:"<BOS_TOKEN>",stop:["<|END_OF_TURN_TOKEN|>"],linebreaks:{user:1},system:{schema:"<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{system}<|END_OF_TURN_TOKEN|>"}},llama3:{id:"llama3",name:"Llama 3",user:"<|start_header_id|>user<|end_header_id|>\n\n{prompt}<|eot_id|>",assistant:"<|start_header_id|>assistant<|end_header_id|>",stop:["<|eot_id|>","<|end_of_text|>"],afterShot:"<|eot_id|>\n\n",system:{schema:"<|start_header_id|>system<|end_header_id|>\n\n{system}<|eot_id|>"}},codestral:{id:"codestral",name:"Codestral",user:"[INST] {prompt}",assistant:" [/INST]",stop:["</s>"],afterShot:"\n",linebreaks:{system:2},system:{schema:"<<SYS>>\n{
|
|
1
|
+
var $tpl=function(s){"use strict";const e={none:{id:"none",name:"No template",user:"{prompt}",assistant:""},alpaca:{id:"alpaca",name:"Alpaca",system:{schema:"{system}",message:"Below is an instruction that describes a task. Write a response that appropriately completes the request."},user:"### Instruction:\n{prompt}",assistant:"### Response:",linebreaks:{system:2,user:2}},llama:{id:"llama",name:"Llama",system:{schema:"[INST] <<SYS>>\n{system}\n<</SYS>>",message:"You are a helpful, respectful and honest assistant. Always answer as helpfully as possible\n\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information."},user:"{prompt}",assistant:" [/INST] ",linebreaks:{system:2,user:0},prefix:"<s>",stop:["</s>"]},mistral:{id:"mistral",name:"Mistral",user:"[INST] {prompt}",assistant:" [/INST]",stop:["</s>"],afterShot:"\n"},orca:{id:"orca",name:"Orca",system:{schema:"### System:\n{system}",message:"You are an AI assistant that follows instruction extremely well. Help as much as you can."},user:"### User:\n{prompt}",assistant:"### Response:",linebreaks:{system:2,user:2}},vicuna:{id:"vicuna",name:"Vicuna",user:"USER: {prompt}",assistant:"### ASSISTANT:",linebreaks:{user:2}},vicuna_system:{id:"vicuna_system",name:"Vicuna system",system:{schema:"SYSTEM: {system}"},user:"USER: {prompt}",assistant:"### ASSISTANT:",linebreaks:{system:2,user:2}},wizard_vicuna:{id:"wizard_vicuna",name:"Wizard Vicuna",user:"### Human:\n{prompt}",assistant:"### ASSISTANT:",linebreaks:{user:2},stop:["<|endoftext|>"]},guanaco:{id:"guanaco",name:"Guanaco",user:"### Human: {prompt}",assistant:"### Assistant:",linebreaks:{user:1}},chatml:{id:"chatml",name:"ChatMl",system:{schema:"<|im_start|>system\n{system}\n<|im_end|>"},user:"<|im_start|>user\n{prompt}<|im_end|>",assistant:"<|im_start|>assistant",linebreaks:{system:1,user:1,assistant:1},stop:["<|im_end|>"],afterShot:" <|im_end|>"},zephyr:{id:"zephyr",name:"Zephyr",system:{schema:"<|system|>\n{system}<|endoftext|>"},user:"<|user|>\n{prompt}<|endoftext|>",assistant:"<|assistant|>",linebreaks:{system:1,user:1,assistant:1},afterShot:"\n",stop:["<|endoftext|>"]},octopus:{id:"octopus",name:"Octopus",system:{schema:"<|system|>{system}<|end|>",message:"You are a router. Below is the query from the users, please call the correct function and generate the parameters to call the function."},user:"<|user|>{prompt}<|end|>",assistant:"<|assistant|>",afterShot:"\n",stop:["<|end|>"]},llava:{id:"llava",name:"Llava",user:"USER: {prompt}",assistant:"ASSISTANT:",linebreaks:{user:1}},"synthia-cot":{id:"synthia-cot",name:"Synthia CoT",system:{schema:"SYSTEM: {system}",message:"Elaborate on the topic using a Tree of Thoughts and backtrack when necessary to construct a clear, cohesive Chain of Thought reasoning. Always answer without hesitation."},user:"USER: {prompt}",assistant:"ASSISTANT:",linebreaks:{system:1,user:1}},wizardlm:{id:"wizardlm",name:"WizardLM",system:{schema:"{system}",message:"You are a helpful AI assistant."},user:"USER: {prompt}",assistant:"ASSISTANT:",linebreaks:{user:1}},openchat:{id:"openchat",name:"OpenChat",user:"GPT4 User: {prompt}<|end_of_turn|>",assistant:"GPT4 Assistant:",stop:["<|end_of_turn|>"]},"openchat-correct":{id:"openchat-correct",name:"OpenChat correct",user:"GPT4 Correct User: {prompt}<|end_of_turn|>",assistant:"GPT4 Correct Assistant:",stop:["<|end_of_turn|>"]},human_response:{id:"human_response",name:"Human response",user:"### HUMAN:\n{prompt}",assistant:"### RESPONSE:",linebreaks:{user:2,assistant:1}},minichat:{id:"minichat",name:"Minichat",user:"[|User|] {prompt} </s>",assistant:"[|Assistant|]",stop:["</s>","[|User|]"],afterShot:"\n",prefix:"<s> "},phi:{id:"phi",name:"Phi",user:"Instruct: {prompt}",assistant:"Output:",linebreaks:{user:1},stop:["</s>","Instruct:"]},phi3:{id:"phi3",name:"Phi 3",user:"<|user|> {prompt}<|end|>",assistant:"<|assistant|>",system:{schema:"<|system|> {system}<|end|>"},afterShot:"<|end|>\n",stop:["<|end|>","<|user|>"]},deepseek:{id:"deepseek",name:"Deepseek",system:{schema:"{system}",message:"You are an AI programming assistant, utilizing the DeepSeek Coder model, developed by DeepSeek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer."},afterShot:"\n",user:"### Instruction:\n{prompt}",assistant:"### Response:",linebreaks:{user:1,system:1},stop:["<|EOT|>","### Instruction:"]},deepseek2:{id:"deepseek2",name:"Deepseek v2",system:{schema:"<|begin▁of▁sentence|>{system}"},user:"User: {prompt}",assistant:"Assistant:",linebreaks:{user:2,system:2},stop:["<|end▁of▁sentence|>","<|tool▁calls▁end|>"]},opencodeinterpreter:{id:"opencodeinterpreter",name:"Open code interpreter",user:"<|User|>\n{prompt}",assistant:"<|Assistant|>",linebreaks:{user:2},stop:["<|EOT|>","<|User|>"]},cerebrum:{id:"cerebrum",name:"Cerebrum",system:{schema:"{system}",message:"A chat between a user and a thinking artificial intelligence assistant. The assistant describes its thought process and gives helpful and detailed answers to the user's questions."},user:"User: {prompt}",assistant:"Ai:",linebreaks:{user:1},prefix:"<s>",stop:["</s>"]},"command-r":{id:"command-r",name:"Command-R",user:"<|START_OF_TURN_TOKEN|><|USER_TOKEN|>{prompt}<|END_OF_TURN_TOKEN|>",assistant:"<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>",prefix:"<BOS_TOKEN>",stop:["<|END_OF_TURN_TOKEN|>"],linebreaks:{user:1},system:{schema:"<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{system}<|END_OF_TURN_TOKEN|>"}},llama3:{id:"llama3",name:"Llama 3",user:"<|start_header_id|>user<|end_header_id|>\n\n{prompt}<|eot_id|>",assistant:"<|start_header_id|>assistant<|end_header_id|>",stop:["<|eot_id|>","<|end_of_text|>"],afterShot:"<|eot_id|>\n\n",system:{schema:"<|start_header_id|>system<|end_header_id|>\n\n{system}<|eot_id|>"}},codestral:{id:"codestral",name:"Codestral",user:"[INST] {prompt}",assistant:" [/INST]",stop:["</s>"],afterShot:"\n",linebreaks:{system:2},system:{schema:"<<SYS>>\n{system}\n<</SYS>>"}},gemma:{id:"gemma",name:"Gemma",user:"<start_of_turn>user\n{prompt}",assistant:"<end_of_turn>\n<start_of_turn>model",stop:["<end_of_turn>"],afterShot:"\n"},nemotron:{id:"nemotron",name:"Nemotron",user:"<extra_id_1>User\n{prompt}",assistant:"<extra_id_1>Assistant",linebreaks:{system:2,user:1},system:{schema:"<extra_id_0>System\n{system}"},afterShot:"\n\n"}};class t{id;name;user;assistant;history=[];system;shots;stop;linebreaks;afterShot;prefix;_extraSystem="";_extraAssistant="";_replacePrompt="";_replaceSystem="";constructor(s){let e;e="string"==typeof s?this._load(s):s,this.id=e.id,this.name=e.name,this.user=e.user,this.assistant=e.assistant,this.system=e.system,this.shots=e.shots,this.stop=e.stop,this.linebreaks=e.linebreaks,this.afterShot=e.afterShot,this.prefix=e.prefix}cloneTo(s,e=!0){const a=new t(s);return e&&this?.shots&&this.shots.forEach((s=>{a.addShot(s.user,s.assistant)})),this._extraSystem.length>0&&a.afterSystem(this._extraSystem),this._replaceSystem.length>0&&a.replaceSystem(this._replaceSystem),this._extraAssistant.length>0&&a.afterAssistant(this._extraAssistant),this._replacePrompt.length>0&&a.replacePrompt(this._replacePrompt),a}toJson(){const s={id:this.id,name:this.name,user:this.user,assistant:this.assistant};return this?.prefix&&(s.prefix=this.prefix),this?.system&&(s.system=this.system),this?.shots&&(s.shots=this.shots),this?.afterShot&&(s.afterShot=this.afterShot),this?.stop&&(s.stop=this.stop),this?.linebreaks&&(s.linebreaks=this.linebreaks),s}replaceSystem(s){return this.system?(this._replaceSystem=s,this):this}afterSystem(s){return this.system?(this._extraSystem=s,this):this}afterAssistant(s){return this._extraAssistant=s,this}replacePrompt(s){return this._replacePrompt=s,this}addShot(s,e){this?.shots||(this.shots=[]);let t=e;return this.shots.push({user:s,assistant:t}),this}addShots(s){return s.forEach((s=>this.addShot(s.user,s.assistant))),this}renderShot(s){const e=[];e.push(this._buildUserBlock(s.user));let t=s.assistant;return this.afterShot?t+=this.afterShot:t+="\n\n",e.push(this._buildAssistantBlock(t)),e.join("")}render(s=!1){const e=new Array;this.prefix&&e.push(this.prefix);const t=this._buildSystemBlock(s);if(t.length>0&&(e.push(t),this?.linebreaks?.system&&e.push("\n".repeat(this.linebreaks.system))),this?.shots)for(const s of this.shots)e.push(this.renderShot(s));for(const s of this.history)e.push(this.renderShot(s));return e.push(this._buildUserBlock()),e.push(this._buildAssistantBlock()),e.join("")}prompt(s){return this.render().replace("{prompt}",s)}pushToHistory(s){return this.history.push(s),this}_buildSystemBlock(s){let e="";return this?.system?(this._replaceSystem&&(this.system.message=this._replaceSystem),this.system?.message?(e=this.system.schema.replace("{system}",this.system.message),this._extraSystem&&(e+=this._extraSystem)):s||(e=this.system.schema),e):""}_buildUserBlock(s){let e=[],t=this.user;return this._replacePrompt.length>0&&(t=t.replace("{prompt}",this._replacePrompt)),e.push(t),this?.linebreaks?.user&&e.push("\n".repeat(this.linebreaks.user)),s&&(e[0]=this.user.replace("{prompt}",s)),e.join("")}_buildAssistantBlock(s){let e=[],t=this.assistant;return this._extraAssistant.length>0&&(t+=this._extraAssistant),e.push(t),this?.linebreaks?.assistant&&e.push("\n".repeat(this.linebreaks.assistant)),s&&e.push(s),e.join("")}_load(s){try{if(s in e)return e[s];throw new Error(`Template ${s} not found`)}catch(e){throw new Error(`Error loading template ${s}: ${e}`)}}}return s.PromptTemplate=t,s.templates=e,s}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modprompt",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Prompt templates for language models",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -9,21 +9,21 @@
|
|
|
9
9
|
"docs": "typedoc --entryPointStrategy expand"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
12
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
13
13
|
"@rollup/plugin-terser": "^0.4.4",
|
|
14
|
-
"@rollup/plugin-typescript": "^
|
|
15
|
-
"@types/expect": "^24.3.
|
|
16
|
-
"@types/jest": "^29.5.
|
|
17
|
-
"@types/node": "^
|
|
18
|
-
"jest": "^29.
|
|
19
|
-
"rollup": "^
|
|
20
|
-
"ts-jest": "^29.
|
|
21
|
-
"ts-node": "^10.9.
|
|
22
|
-
"tslib": "^2.
|
|
23
|
-
"typedoc": "^0.
|
|
24
|
-
"typedoc-plugin-markdown": "^
|
|
25
|
-
"typedoc-plugin-rename-defaults": "^0.
|
|
26
|
-
"typescript": "^5.
|
|
14
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
15
|
+
"@types/expect": "^24.3.2",
|
|
16
|
+
"@types/jest": "^29.5.14",
|
|
17
|
+
"@types/node": "^22.8.2",
|
|
18
|
+
"jest": "^29.7.0",
|
|
19
|
+
"rollup": "^4.24.2",
|
|
20
|
+
"ts-jest": "^29.2.5",
|
|
21
|
+
"ts-node": "^10.9.2",
|
|
22
|
+
"tslib": "^2.8.0",
|
|
23
|
+
"typedoc": "^0.26.10",
|
|
24
|
+
"typedoc-plugin-markdown": "^4.2.9",
|
|
25
|
+
"typedoc-plugin-rename-defaults": "^0.7.1",
|
|
26
|
+
"typescript": "^5.6.3"
|
|
27
27
|
},
|
|
28
28
|
"type": "module",
|
|
29
29
|
"files": [
|