diff --git a/src/LLTSharp/ITemplate.cs b/src/LLTSharp/ITemplate.cs
index 60acee6..5a2eb51 100644
--- a/src/LLTSharp/ITemplate.cs
+++ b/src/LLTSharp/ITemplate.cs
@@ -12,8 +12,9 @@ public interface ITemplate : IMetadataProvider
/// Renders the template with the given context.
///
/// The context to use for rendering the template. Can be null.
+ /// Optional set of functions to use during rendering. Can be null.
/// The result of rendering the template.
- object Render(object? context = null);
+ object Render(object? context = null, TemplateFunctionSet? functions = null);
}
///
@@ -22,8 +23,8 @@ public interface ITemplate : IMetadataProvider
/// The type of result produced by the template.
public interface ITemplate : ITemplate
{
- ///
- new TResult Render(object? context = null);
+ ///
+ new TResult Render(object? context = null, TemplateFunctionSet? functions = null);
}
///
diff --git a/src/LLTSharp/MessagesTemplate.cs b/src/LLTSharp/MessagesTemplate.cs
index f038c6e..c592e59 100644
--- a/src/LLTSharp/MessagesTemplate.cs
+++ b/src/LLTSharp/MessagesTemplate.cs
@@ -33,20 +33,15 @@ public MessagesTemplate(MessagesTemplateNode mainNode, IMetadataCollection metad
LocalLibrary = localLibrary ?? throw new ArgumentNullException(nameof(localLibrary));
}
- ///
- /// Renders the messages template using the provided data accessor.
- ///
- /// The context accessor to use for rendering.
- /// The rendered prompt as a collection of messages.
- public IEnumerable Render(object? context = null)
+ public IEnumerable Render(object? context = null, TemplateFunctionSet? functions = null)
{
- var ctx = new TemplateContextAccessor(TemplateDataAccessor.Create(context), Metadata, library: LocalLibrary);
+ var ctx = new TemplateContextAccessor(TemplateDataAccessor.Create(context), Metadata, functions: functions, library: LocalLibrary);
return _node.Render(ctx);
}
- object ITemplate.Render(object? context)
+ object ITemplate.Render(object? context, TemplateFunctionSet? functions)
{
- var ctx = new TemplateContextAccessor(TemplateDataAccessor.Create(context), Metadata, library: LocalLibrary);
+ var ctx = new TemplateContextAccessor(TemplateDataAccessor.Create(context), Metadata, functions: functions, library: LocalLibrary);
return _node.Render(ctx);
}
}
diff --git a/src/LLTSharp/PlaintextTemplate.cs b/src/LLTSharp/PlaintextTemplate.cs
index 163b9ab..c23f05d 100644
--- a/src/LLTSharp/PlaintextTemplate.cs
+++ b/src/LLTSharp/PlaintextTemplate.cs
@@ -49,14 +49,14 @@ public PlaintextTemplate(string content, IMetadataCollection metadata)
Metadata = new MetadataCollection(metadata) ?? throw new ArgumentNullException(nameof(metadata));
}
- public string Render(object? context = null)
+ public string Render(object? context = null, TemplateFunctionSet? functions = null)
{
return Content;
}
- object ITemplate.Render(object? context)
+ object ITemplate.Render(object? context, TemplateFunctionSet? functions)
{
- return Render(context);
+ return Render(context, functions);
}
}
}
\ No newline at end of file
diff --git a/src/LLTSharp/TextTemplate.cs b/src/LLTSharp/TextTemplate.cs
index 87f8393..f8ecee4 100644
--- a/src/LLTSharp/TextTemplate.cs
+++ b/src/LLTSharp/TextTemplate.cs
@@ -35,20 +35,15 @@ public TextTemplate(TextTemplateNode mainNode, IMetadataCollection metadata, Tem
LocalLibrary = localLibrary ?? throw new ArgumentNullException(nameof(localLibrary));
}
- ///
- /// Renders the text template using the provided data accessor.
- ///
- /// The context accessor to use for rendering.
- /// The rendered text as a string.
- public string Render(object? context = null)
+ public string Render(object? context = null, TemplateFunctionSet? functions = null)
{
- var ctx = new TemplateContextAccessor(TemplateDataAccessor.Create(context), Metadata, library: LocalLibrary);
+ var ctx = new TemplateContextAccessor(TemplateDataAccessor.Create(context), Metadata, functions: functions, library: LocalLibrary);
return _node.Render(ctx);
}
- object ITemplate.Render(object? context)
+ object ITemplate.Render(object? context, TemplateFunctionSet? functions)
{
- var ctx = new TemplateContextAccessor(TemplateDataAccessor.Create(context), Metadata, library: LocalLibrary);
+ var ctx = new TemplateContextAccessor(TemplateDataAccessor.Create(context), Metadata, functions: functions, library: LocalLibrary);
return _node.Render(ctx);
}
}