You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I felt its implementation is a bit too simple, here's my some suggestions (from line 385):
// The result always replace to system prompt,// so we can skip the data retrieve if there do not provided system promptif(assistantHasDynamicPrompt&&preprompt&&messagesForPrompt[0].from==="system"){// process the prepromptconsturlRegex=/{{\s?url=(.*?)\s?}}/g;// define a max loop count// This is a recursive loop,// If the result contains the '{{url=xxxx}}' format with same content url,// it will diving into a infinite loopletmatch,maxLoop=10;// it can be define at other fileswhile((match=urlRegex.exec(preprompt))!==null&&maxLoop--){try{// Add programmable placeholder for more context,// It's very useful because the user prompt is always provided,// the service can return the targeted result.// The assistant's author can configure it as a path parameter or a query// eg. https://xxx.com/%S or https://xxx.com/?q=%SletpreUrl=match[1];preUrl=preUrl.replaceAll('%S',messagesForPrompt[0].content)// may it should be encoded// Other placeholder// Such as %R for random seed, bypass cache// %T for timestampconsturl=newURL(preUrl);if(awaitisURLLocal(url)){thrownewError("URL couldn't be fetched, it resolved to a local address.");}// Add more identity headers// If the service contains many response format,// these headers can tell it which correct format should be returnedconstres=awaitfetch(url.href,{headers: {"accept": "text/plain, text/markdown, text/*;q=0.9, */*;q=0.8","user-agent": "ChatUI/0.8",},});if(!res.ok){thrownewError("URL couldn't be fetched, error "+res.status);}consttext=awaitres.text();preprompt=preprompt.replaceAll(match[0],text);}catch(e){preprompt=preprompt.replaceAll(match[0],(easError).message);}}// if (messagesForPrompt[0].from === "system") {messagesForPrompt[0].content=preprompt;//}}
The text was updated successfully, but these errors were encountered:
Assistant dynamic prompt is an awesome feature, I read the implementation at
chat-ui/src/routes/conversation/[id]/+server.ts
Line 385 in 18fba9f
I felt its implementation is a bit too simple, here's my some suggestions (from line 385):
The text was updated successfully, but these errors were encountered: