Add prompt preview
This commit is contained in:
@@ -699,4 +699,5 @@ export const languageEnglish = {
|
|||||||
selectFile: "Select File",
|
selectFile: "Select File",
|
||||||
namespace: "Namespace",
|
namespace: "Namespace",
|
||||||
moduleIntergration: "Module Integration",
|
moduleIntergration: "Module Integration",
|
||||||
|
previewInfo: "This preview shows prompt before model-specific processing.",
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
import NumberInput from "../UI/GUI/NumberInput.svelte";
|
import NumberInput from "../UI/GUI/NumberInput.svelte";
|
||||||
import Button from "../UI/GUI/Button.svelte";
|
import Button from "../UI/GUI/Button.svelte";
|
||||||
import { getRequestLog } from "src/ts/storage/globalApi";
|
import { getRequestLog } from "src/ts/storage/globalApi";
|
||||||
import { alertMd } from "src/ts/alert";
|
import { alertMd, alertWait } from "src/ts/alert";
|
||||||
import Arcodion from "../UI/Arcodion.svelte";
|
import Arcodion from "../UI/Arcodion.svelte";
|
||||||
import { getCharToken, getChatToken } from "src/ts/tokenizer";
|
import { getCharToken, getChatToken } from "src/ts/tokenizer";
|
||||||
import { tokenizePreset } from "src/ts/process/prompt";
|
import { tokenizePreset } from "src/ts/process/prompt";
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
import { FolderUpIcon, PlusIcon, TrashIcon } from "lucide-svelte";
|
import { FolderUpIcon, PlusIcon, TrashIcon } from "lucide-svelte";
|
||||||
import { selectSingleFile } from "src/ts/util";
|
import { selectSingleFile } from "src/ts/util";
|
||||||
import { file } from "jszip";
|
import { file } from "jszip";
|
||||||
import { doingChat, sendChat } from "src/ts/process";
|
import { doingChat, previewFormated, sendChat } from "src/ts/process";
|
||||||
|
|
||||||
|
|
||||||
let autopilot = []
|
let autopilot = []
|
||||||
@@ -148,6 +148,38 @@
|
|||||||
doingChat.set(false)
|
doingChat.set(false)
|
||||||
}}>Run</Button>
|
}}>Run</Button>
|
||||||
</Arcodion>
|
</Arcodion>
|
||||||
|
|
||||||
<Button className="mt-2" on:click={() => {
|
<Button className="mt-2" on:click={() => {
|
||||||
alertMd(getRequestLog())
|
alertMd(getRequestLog())
|
||||||
}}>Request Log</Button>
|
}}>Request Log</Button>
|
||||||
|
|
||||||
|
<Button className="mt-2" on:click={async () => {
|
||||||
|
if($doingChat){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
alertWait("Loading...")
|
||||||
|
await sendChat(-1, {
|
||||||
|
preview: true
|
||||||
|
})
|
||||||
|
|
||||||
|
let md = ''
|
||||||
|
const styledRole = {
|
||||||
|
"function": "📐 Function",
|
||||||
|
"user": "😐 User",
|
||||||
|
"system": "⚙️ System",
|
||||||
|
"assistant": "✨ Assistant",
|
||||||
|
}
|
||||||
|
for(let i=0;i<previewFormated.length;i++){
|
||||||
|
|
||||||
|
md += '### ' + (styledRole[previewFormated[i].role] ?? '🤔 Unknown role') + '\n'
|
||||||
|
const modals = previewFormated[i].multimodals
|
||||||
|
|
||||||
|
if(modals && modals.length > 0){
|
||||||
|
md += `> ${modals.length} non-text content(s) included\n`
|
||||||
|
}
|
||||||
|
|
||||||
|
md += '```\n' + previewFormated[i].content.replaceAll('```', '\\`\\`\\`') + '\n```\n'
|
||||||
|
}
|
||||||
|
$doingChat = false
|
||||||
|
alertMd(md)
|
||||||
|
}}>Preview Prompt</Button>
|
||||||
@@ -56,8 +56,15 @@ export interface OpenAIChatFull extends OpenAIChat{
|
|||||||
export const doingChat = writable(false)
|
export const doingChat = writable(false)
|
||||||
export const chatProcessStage = writable(0)
|
export const chatProcessStage = writable(0)
|
||||||
export const abortChat = writable(false)
|
export const abortChat = writable(false)
|
||||||
|
export let previewFormated:OpenAIChat[] = []
|
||||||
|
|
||||||
export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:number,signal?:AbortSignal,continue?:boolean,usedContinueTokens?:number} = {}):Promise<boolean> {
|
export async function sendChat(chatProcessIndex = -1,arg:{
|
||||||
|
chatAdditonalTokens?:number,
|
||||||
|
signal?:AbortSignal,
|
||||||
|
continue?:boolean,
|
||||||
|
usedContinueTokens?:number,
|
||||||
|
preview?:boolean
|
||||||
|
} = {}):Promise<boolean> {
|
||||||
|
|
||||||
chatProcessStage.set(0)
|
chatProcessStage.set(0)
|
||||||
const abortSignal = arg.signal ?? (new AbortController()).signal
|
const abortSignal = arg.signal ?? (new AbortController()).signal
|
||||||
@@ -1090,6 +1097,11 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
maxContext: maxContextTokens,
|
maxContext: maxContextTokens,
|
||||||
}
|
}
|
||||||
chatProcessStage.set(3)
|
chatProcessStage.set(3)
|
||||||
|
if(arg.preview){
|
||||||
|
previewFormated = formated
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
const req = await requestChatData({
|
const req = await requestChatData({
|
||||||
formated: formated,
|
formated: formated,
|
||||||
biasString: biases,
|
biasString: biases,
|
||||||
|
|||||||
Reference in New Issue
Block a user