Skip to content

Commit

Permalink
feat: adds logging for DA imports
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Biret <[email protected]>
  • Loading branch information
baywet committed Dec 3, 2024
1 parent 2c93e97 commit 5c89ca1
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,36 @@ public static async Task<T> CreateChatCompletionAgentFromDeclarativeAgentManifes
Id = string.IsNullOrEmpty(document.Id) ? Guid.NewGuid().ToString() : document.Id,

Check failure on line 74 in dotnet/src/Functions/Functions.OpenApi.Extensions/Extensions/DeclarativeAgentExtensions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (8.0, ubuntu-latest, Release, true, integration)

Possible null reference assignment.

Check failure on line 74 in dotnet/src/Functions/Functions.OpenApi.Extensions/Extensions/DeclarativeAgentExtensions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (8.0, ubuntu-latest, Release, true, integration)

Possible null reference assignment.

Check failure on line 74 in dotnet/src/Functions/Functions.OpenApi.Extensions/Extensions/DeclarativeAgentExtensions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (8.0, windows-latest, Debug)

Possible null reference assignment.

Check failure on line 74 in dotnet/src/Functions/Functions.OpenApi.Extensions/Extensions/DeclarativeAgentExtensions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (8.0, windows-latest, Debug)

Possible null reference assignment.

Check failure on line 74 in dotnet/src/Functions/Functions.OpenApi.Extensions/Extensions/DeclarativeAgentExtensions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (8.0, windows-latest, Release)

Possible null reference assignment.

Check failure on line 74 in dotnet/src/Functions/Functions.OpenApi.Extensions/Extensions/DeclarativeAgentExtensions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (8.0, windows-latest, Release)

Possible null reference assignment.
};

await Task.WhenAll(document.Actions.Select(action => kernel.ImportPluginFromCopilotAgentPluginAsync(action.Id, GetFullPath(manifestDirectory, action.File), pluginParameters, cancellationToken))).ConfigureAwait(false);
if (document.Capabilities is { Count: > 0 })
{
logger.LogWarning("Importing capabilities from declarative agent is not supported in semantic kernel.");
}

if (document.Actions is { Count: > 0 })
{
logger.LogInformation("Importing {ActionsCount} actions from declarative agent.", document.Actions.Count);
await Task.WhenAll(document.Actions.Select(action => ImportCAPFromActionAsync(action, manifestDirectory, kernel, pluginParameters, logger, cancellationToken))).ConfigureAwait(false);
}
return agent;
}
private static async Task ImportCAPFromActionAsync(DCAction action, string? manifestDirectory, Kernel kernel, CopilotAgentPluginParameters? pluginParameters, ILogger logger, CancellationToken cancellationToken)
{
try
{
var capManifestPath = GetFullPath(manifestDirectory, action.File);
logger.LogInformation("Importing action {ActionName} from declarative agent from path {Path}.", action.Id, capManifestPath);
await kernel.ImportPluginFromCopilotAgentPluginAsync(action.Id, capManifestPath, pluginParameters, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex) when (ex is FileNotFoundException or InvalidOperationException)
{
logger.LogError(ex, "Error importing action {ActionName} from declarative agent.", action.Id);
}
catch (Exception ex)
{
logger.LogError(ex, "Error importing action {ActionName} from declarative agent.", action.Id);
throw;
}
}
private static async Task<string?> GetEffectiveInstructionsAsync(string? manifestFilePath, string? source, ILogger logger, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(source) ||
Expand Down

0 comments on commit 5c89ca1

Please sign in to comment.