Currently to import native skills in kernel you must manuall inject the dependencies like so :
kernel.ImportSkill( new GlobalVariablesSkill(
contentHandleManager:sp.GetRequiredService<IContentHandleManager>(),
contentManager:sp.GetRequiredService<IContentManager>()
), nameof(GlobalVariablesSkill));
these services require calls to an sql server database .
Here is the native function :
public sealed class GlobalVariablesSkill
{
private readonly IContentHandleManager _contentHandleManager;
private readonly IContentManager _contentManager;
public GlobalVariablesSkill(IContentHandleManager contentHandleManager, IContentManager contentManager)
{
_contentHandleManager = contentHandleManager;
_contentManager = contentManager;
}
[SKFunction, Description("Get a global variable value")]
public async Task<string> GetAsync( [Description("Variable name")] string variable)
{
var contentItemId= await _contentHandleManager.GetContentItemIdAsync("alias:" + variable);
if (string.IsNullOrEmpty(contentItemId))
{
return null;
}
var contentItem = await _contentManager.GetAsync(contentItemId );
if (contentItem == null)
{
return null;
}
//get the value of the text field named "Value"
return contentItem.Content?.Workspacevariable.Content.Text.ToString() ?? null;
}
}
My issuse is thate when calling this native function twice in a semantic function : eg :
{{ GlobalVariablesSkill.Get "param1" }}
{{ GlobalVariablesSkill.Get "param2" }}
i get a database error from database '' The connection does not support MultipleActiveResultSets."
if i change the connection string to support MultipleActiveResultSets =True then it works .
If i make only 1 call to {{ GlobalVariablesSkill.Get "param1" }} within the semantic function it works.
Any ideas ?
My guess is that because im manually injecting the required services to the native function this is happening.
Ideally i would like to not have to change my connection string settings to allow multiple calls the native functions.
Currently to import native skills in kernel you must manuall inject the dependencies like so :
these services require calls to an sql server database .
Here is the native function :
My issuse is thate when calling this native function twice in a semantic function : eg :
i get a database error from database '' The connection does not support MultipleActiveResultSets."
if i change the connection string to support MultipleActiveResultSets =True then it works .
If i make only 1 call to {{ GlobalVariablesSkill.Get "param1" }} within the semantic function it works.
Any ideas ?
My guess is that because im manually injecting the required services to the native function this is happening.
Ideally i would like to not have to change my connection string settings to allow multiple calls the native functions.