Skip to content

Refine/refine project dep #1049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
minor change
  • Loading branch information
iceljc committed May 8, 2025
commit 363c9be56b7b75f215c8c0d9c5ed2f34ff2f1a68
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ private static async Task RegisterFunctionCall(IServiceCollection services, McpS
});
}
}
catch { }
catch (Exception ex)
{
Console.WriteLine($"Error when registering {server?.Name} MCP tools. {ex.Message}\r\n{ex.InnerException}");
}
}
}
9 changes: 6 additions & 3 deletions src/Infrastructure/BotSharp.Core/Templating/TemplateRender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public TemplateRender(IServiceProvider services, ILogger<TemplateRender> logger)
_options.MemberAccessStrategy.Register<UserIdentity>();
_options.MemberAccessStrategy.Register<TranslationInput>();

_parser.RegisterIdentifierTag("link", RenderIdentifierTag);
_parser.RegisterIdentifierTag("link", (string identifier, TextWriter writer, TextEncoder encoder, TemplateContext context) =>
{
return RenderIdentifierTag("link", identifier, writer, encoder, context);
});
}

public string Render(string template, Dictionary<string, object> dict)
Expand Down Expand Up @@ -79,14 +82,14 @@ public void RegisterType(Type type)


#region Private methods
private static async ValueTask<Completion> RenderIdentifierTag(string identifier, TextWriter writer, TextEncoder encoder, TemplateContext context)
private static async ValueTask<Completion> RenderIdentifierTag(string tag, string identifier, TextWriter writer, TextEncoder encoder, TemplateContext context)
{
try
{
var value = await context.Model.GetValueAsync(TemplateRenderConstant.RENDER_AGENT, context);
var agent = value?.ToObjectValue() as Agent;
var found = agent?.Templates?.FirstOrDefault(x => x.Name.IsEqualTo(identifier));
var key = $"{agent?.Id} | {identifier}";
var key = $"{agent?.Id} | {tag} | {identifier}";

if (found == null || (context.AmbientValues.TryGetValue(key, out var visited) && (bool)visited))
{
Expand Down
Loading