{"version":3,"file":"index.360bbf2c.js","sources":["../../../../../../src/lib/apis/prompts/index.ts"],"sourcesContent":["import { WEBUI_API_BASE_URL } from '$lib/constants';\n\nexport const createNewPrompt = async (\n\ttoken: string,\n\tcommand: string,\n\ttitle: string,\n\tcontent: string\n) => {\n\tlet error = null;\n\n\tconst res = await fetch(`${WEBUI_API_BASE_URL}/prompts/create`, {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\tAccept: 'application/json',\n\t\t\t'Content-Type': 'application/json',\n\t\t\tauthorization: `Bearer ${token}`\n\t\t},\n\t\tbody: JSON.stringify({\n\t\t\tcommand: `/${command}`,\n\t\t\ttitle: title,\n\t\t\tcontent: content\n\t\t})\n\t})\n\t\t.then(async (res) => {\n\t\t\tif (!res.ok) throw await res.json();\n\t\t\treturn res.json();\n\t\t})\n\t\t.catch((err) => {\n\t\t\terror = err.detail;\n\t\t\tconsole.log(err);\n\t\t\treturn null;\n\t\t});\n\n\tif (error) {\n\t\tthrow error;\n\t}\n\n\treturn res;\n};\n\nexport const getPrompts = async (token: string = '') => {\n\tlet error = null;\n\n\tconst res = await fetch(`${WEBUI_API_BASE_URL}/prompts/`, {\n\t\tmethod: 'GET',\n\t\theaders: {\n\t\t\tAccept: 'application/json',\n\t\t\t'Content-Type': 'application/json',\n\t\t\tauthorization: `Bearer ${token}`\n\t\t}\n\t})\n\t\t.then(async (res) => {\n\t\t\tif (!res.ok) throw await res.json();\n\t\t\treturn res.json();\n\t\t})\n\t\t.then((json) => {\n\t\t\treturn json;\n\t\t})\n\t\t.catch((err) => {\n\t\t\terror = err.detail;\n\t\t\tconsole.log(err);\n\t\t\treturn null;\n\t\t});\n\n\tif (error) {\n\t\tthrow error;\n\t}\n\n\treturn res;\n};\n\nexport const getPromptByCommand = async (token: string, command: string) => {\n\tlet error = null;\n\n\tconst res = await fetch(`${WEBUI_API_BASE_URL}/prompts/command/${command}`, {\n\t\tmethod: 'GET',\n\t\theaders: {\n\t\t\tAccept: 'application/json',\n\t\t\t'Content-Type': 'application/json',\n\t\t\tauthorization: `Bearer ${token}`\n\t\t}\n\t})\n\t\t.then(async (res) => {\n\t\t\tif (!res.ok) throw await res.json();\n\t\t\treturn res.json();\n\t\t})\n\t\t.then((json) => {\n\t\t\treturn json;\n\t\t})\n\t\t.catch((err) => {\n\t\t\terror = err.detail;\n\n\t\t\tconsole.log(err);\n\t\t\treturn null;\n\t\t});\n\n\tif (error) {\n\t\tthrow error;\n\t}\n\n\treturn res;\n};\n\nexport const updatePromptByCommand = async (\n\ttoken: string,\n\tcommand: string,\n\ttitle: string,\n\tcontent: string\n) => {\n\tlet error = null;\n\n\tconst res = await fetch(`${WEBUI_API_BASE_URL}/prompts/command/${command}/update`, {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\tAccept: 'application/json',\n\t\t\t'Content-Type': 'application/json',\n\t\t\tauthorization: `Bearer ${token}`\n\t\t},\n\t\tbody: JSON.stringify({\n\t\t\tcommand: `/${command}`,\n\t\t\ttitle: title,\n\t\t\tcontent: content\n\t\t})\n\t})\n\t\t.then(async (res) => {\n\t\t\tif (!res.ok) throw await res.json();\n\t\t\treturn res.json();\n\t\t})\n\t\t.then((json) => {\n\t\t\treturn json;\n\t\t})\n\t\t.catch((err) => {\n\t\t\terror = err.detail;\n\n\t\t\tconsole.log(err);\n\t\t\treturn null;\n\t\t});\n\n\tif (error) {\n\t\tthrow error;\n\t}\n\n\treturn res;\n};\n\nexport const deletePromptByCommand = async (token: string, command: string) => {\n\tlet error = null;\n\n\tcommand = command.charAt(0) === '/' ? command.slice(1) : command;\n\n\tconst res = await fetch(`${WEBUI_API_BASE_URL}/prompts/command/${command}/delete`, {\n\t\tmethod: 'DELETE',\n\t\theaders: {\n\t\t\tAccept: 'application/json',\n\t\t\t'Content-Type': 'application/json',\n\t\t\tauthorization: `Bearer ${token}`\n\t\t}\n\t})\n\t\t.then(async (res) => {\n\t\t\tif (!res.ok) throw await res.json();\n\t\t\treturn res.json();\n\t\t})\n\t\t.then((json) => {\n\t\t\treturn json;\n\t\t})\n\t\t.catch((err) => {\n\t\t\terror = err.detail;\n\n\t\t\tconsole.log(err);\n\t\t\treturn null;\n\t\t});\n\n\tif (error) {\n\t\tthrow error;\n\t}\n\n\treturn res;\n};\n"],"names":["createNewPrompt","token","command","title","content","error","res","WEBUI_API_BASE_URL","err","getPrompts","json","updatePromptByCommand","deletePromptByCommand"],"mappings":"wCAEO,MAAMA,EAAkB,MAC9BC,EACAC,EACAC,EACAC,IACI,CACJ,IAAIC,EAAQ,KAEZ,MAAMC,EAAM,MAAM,MAAM,GAAGC,CAAkB,kBAAmB,CAC/D,OAAQ,OACR,QAAS,CACR,OAAQ,mBACR,eAAgB,mBAChB,cAAe,UAAUN,CAAK,EAC/B,EACA,KAAM,KAAK,UAAU,CACpB,QAAS,IAAIC,CAAO,GACpB,MAAAC,EACA,QAAAC,CAAA,CACA,CAAA,CACD,EACC,KAAK,MAAOE,GAAQ,CACpB,GAAI,CAACA,EAAI,GAAU,MAAA,MAAMA,EAAI,OAC7B,OAAOA,EAAI,MAAK,CAChB,EACA,MAAOE,IACPH,EAAQG,EAAI,OACZ,QAAQ,IAAIA,CAAG,EACR,KACP,EAEF,GAAIH,EACG,MAAAA,EAGA,OAAAC,CACR,EAEaG,EAAa,MAAOR,EAAgB,KAAO,CACvD,IAAII,EAAQ,KAEZ,MAAMC,EAAM,MAAM,MAAM,GAAGC,CAAkB,YAAa,CACzD,OAAQ,MACR,QAAS,CACR,OAAQ,mBACR,eAAgB,mBAChB,cAAe,UAAUN,CAAK,EAC/B,CAAA,CACA,EACC,KAAK,MAAOK,GAAQ,CACpB,GAAI,CAACA,EAAI,GAAU,MAAA,MAAMA,EAAI,OAC7B,OAAOA,EAAI,MAAK,CAChB,EACA,KAAMI,GACCA,CACP,EACA,MAAOF,IACPH,EAAQG,EAAI,OACZ,QAAQ,IAAIA,CAAG,EACR,KACP,EAEF,GAAIH,EACG,MAAAA,EAGA,OAAAC,CACR,EAkCaK,EAA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