11import { ChatMessage , PromptRequestTemplate } from "api" ;
22
3- /**
4- * Custom error type for missing prompt variables.
5- */
63export class PromptVariablesNotFoundError extends Error {
74 public missingVariables : string [ ] ;
85
@@ -114,8 +111,6 @@ export function populateChatTemplate(
114111 }
115112
116113 // Deep copy the content so we don't mutate the original object.
117- // (Depending on your environment, you might prefer a structured clone
118- // or a third-party solution for deep copying.)
119114 let messageContent = JSON . parse ( JSON . stringify ( message . content ) ) ;
120115
121116 if ( typeof messageContent === "string" ) {
@@ -144,7 +139,7 @@ export function populateChatTemplate(
144139/**
145140 * Populates a string-based prompt or chat-based prompt with the given inputs.
146141 * For string prompts, all occurrences of {{var}} are replaced using populatePromptTemplate.
147- * For chat prompts (array of ChatMessageParams ), each message is handled by populateChatTemplate.
142+ * For chat prompts (array of ChatMessage ), each message is handled by populateChatTemplate.
148143 */
149144export function populateTemplate < T extends PromptRequestTemplate > (
150145 template : T ,
@@ -157,6 +152,5 @@ export function populateTemplate<T extends PromptRequestTemplate>(
157152 // Chat-based prompt
158153 return populateChatTemplate ( template , inputs ) as T ;
159154 }
160- // If you have other template forms, handle them here.
161155 return template ;
162156}
0 commit comments