in src/Core/Compiling/Policy/LlmContentSafetyCompiler.cs [18:51]
public void Handle(ICompilationContext context, InvocationExpressionSyntax node)
{
if (!node.TryExtractingConfigParameter<LlmContentSafetyConfig>(context, "llm-content-safety", out var values))
{
return;
}
var element = new XElement("llm-content-safety");
if (!element.AddAttribute(values, nameof(LlmContentSafetyConfig.BackendId), "backend-id"))
{
context.Report(Diagnostic.Create(
CompilationErrors.RequiredParameterNotDefined,
node.GetLocation(),
"llm-content-safety",
nameof(LlmContentSafetyConfig.BackendId)
));
return;
}
element.AddAttribute(values, nameof(LlmContentSafetyConfig.ShieldPrompt), "shield-prompt");
if (values.TryGetValue(nameof(LlmContentSafetyConfig.Categories), out var categoriesValue))
{
HandleCategories(context, categoriesValue, element);
}
if (values.TryGetValue(nameof(LlmContentSafetyConfig.BlockLists), out var blockListsValue))
{
HandleBlockLists(blockListsValue, element);
}
context.AddPolicy(element);
}