-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Open
Copy link
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codeai connectorAnything related to AI connectorsAnything related to AI connectorsbugSomething isn't workingSomething isn't working
Description
Describe the bug
I have setup semantic kernel with bedrock chat completion service as below:
services.AddSemanticKernelServices();
services.AddBedrockChatCompletionService(
modelId: "us.anthropic.claude-3-5-sonnet-20241022-v2:0"
);
services.AddBedrockEmbeddingGenerator(modelId: "amazon.titan-embed-text-v2:0");
and then create an agent as follows:
Kernel agentKernel = kernel.Clone();
agentKernel.ImportPluginFromObject(new LightsPlugin());
agentKernel.ImportPluginFromObject(new InternalDocumentsPlugin(vectorStore, agentEntity.KnowledgeBaseIds.ToArray()));
ChatCompletionAgent agent = new()
{
Name = agentId,
Instructions = agentPrompt.Text,
Kernel = agentKernel,
Description = agentEntity.Description,
Arguments = new KernelArguments(new AmazonClaudeExecutionSettings()
{
MaxTokensToSample = 1024 * 4,
FunctionChoiceBehavior = FunctionChoiceBehavior.Required(),
}),
};
Sample tool is configured as below (based on examples)
public class LightModel
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string? Name { get; set; }
[JsonPropertyName("is_on")]
public bool? IsOn { get; set; }
[JsonPropertyName("brightness")]
public Brightness? Brightness { get; set; }
[JsonPropertyName("color")]
[Description("The color of the light with a hex code (ensure you include the # symbol)")]
public string? Color { get; set; }
}
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum Brightness
{
Low,
Medium,
High
}
public class LightsPlugin
{
private readonly List<LightModel> _lights;
public LightsPlugin()
{
_lights = new List<LightModel>
{
new LightModel { Id = 1, Name = "Living Room", IsOn = true, Brightness = Brightness.Medium, Color = "#FFFFFF" },
new LightModel { Id = 2, Name = "Kitchen", IsOn = false, Brightness = Brightness.Low, Color = "#FF0000" },
new LightModel { Id = 3, Name = "Bedroom", IsOn = true, Brightness = Brightness.High, Color = "#00FF00" }
};
}
[KernelFunction("get_lights")]
[Description("Gets a list of lights and their current state")]
public async Task<List<LightModel>> GetLightsAsync()
{
return _lights;
}
}
But when chatting with the agent, is has no knowledge of the tools and does not invoke any.
Metadata
Metadata
Assignees
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codeai connectorAnything related to AI connectorsAnything related to AI connectorsbugSomething isn't workingSomething isn't working
Type
Projects
Status
No status