Skip to content

Commit

Permalink
Merge pull request #520 from solliancenet/cj-polymorphic-models
Browse files Browse the repository at this point in the history
Management API updates
  • Loading branch information
joelhulen authored Jan 30, 2024
2 parents 424d65c + 11b545e commit a4d68ef
Show file tree
Hide file tree
Showing 42 changed files with 1,098 additions and 29 deletions.
1 change: 1 addition & 0 deletions docs/deployment/app-configuration-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FoundationaLLM uses Azure App Configuration to store configuration values, Key V

| Key | Default Value | Description |
| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FoundationaLLM:Instance:Id` | Generated GUID | The value should be a GUID represents a unique instance of the FoundationaLLM instance. |
| `FoundationaLLM:AgentHub:AgentMetadata:StorageContainer` | agents | |
| `FoundationaLLM:AgentHub:StorageManager:BlobStorage:ConnectionString` | Key Vault secret name: `foundationallm-agenthub-storagemanager-blobstorage-connectionstring` | This is a Key Vault reference. |
| `FoundationaLLM:APIs:AgentFactoryAPI:APIKey` | Key Vault secret name: `foundationallm-apis-agentfactoryapi-apikey` | This is a Key Vault reference. |
Expand Down
9 changes: 8 additions & 1 deletion src/FoundationaLLM.sln
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Management", "dotnet\Manage
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManagementAPI", "dotnet\ManagementAPI\ManagementAPI.csproj", "{2D54392A-8D86-4F54-9993-FB3B6C4C090E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SemanticKernel", "dotnet\SemanticKernel\SemanticKernel.csproj", "{CDB843FE-108B-435A-BF17-68052C64F500}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SemanticKernel", "dotnet\SemanticKernel\SemanticKernel.csproj", "{CDB843FE-108B-435A-BF17-68052C64F500}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agent", "dotnet\Agent\Agent.csproj", "{9BE97AEC-032C-454B-BDAA-29418A769237}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -200,6 +202,10 @@ Global
{CDB843FE-108B-435A-BF17-68052C64F500}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CDB843FE-108B-435A-BF17-68052C64F500}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CDB843FE-108B-435A-BF17-68052C64F500}.Release|Any CPU.Build.0 = Release|Any CPU
{9BE97AEC-032C-454B-BDAA-29418A769237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BE97AEC-032C-454B-BDAA-29418A769237}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BE97AEC-032C-454B-BDAA-29418A769237}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BE97AEC-032C-454B-BDAA-29418A769237}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -239,6 +245,7 @@ Global
{46FB5F1B-57C6-4CA3-B626-887DF6D806DD} = {B6DC1190-2873-44A3-85B3-63D7BDE99231}
{2D54392A-8D86-4F54-9993-FB3B6C4C090E} = {B6DC1190-2873-44A3-85B3-63D7BDE99231}
{CDB843FE-108B-435A-BF17-68052C64F500} = {B6DC1190-2873-44A3-85B3-63D7BDE99231}
{9BE97AEC-032C-454B-BDAA-29418A769237} = {B6DC1190-2873-44A3-85B3-63D7BDE99231}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FF5DE858-4B85-4EE8-8A6D-46E8E4FBA078}
Expand Down
21 changes: 21 additions & 0 deletions src/dotnet/Agent/Agent.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>FoundationaLLM.Agent</RootNamespace>
<AssemblyName>FoundationaLLM.Agent</AssemblyName>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />
</ItemGroup>

</Project>
84 changes: 84 additions & 0 deletions src/dotnet/Agent/Models/Metadata/AgentBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using FoundationaLLM.Common.Models.Metadata;
using FoundationaLLM.Common.Models.ResourceProvider;
using Newtonsoft.Json;

namespace FoundationaLLM.Agent.Models.Metadata
{
/// <summary>
/// Base agent metadata model.
/// </summary>
public class AgentBase : ResourceBase
{
/// <summary>
/// The agent's language model configuration.
/// </summary>
[JsonProperty("language_model")]
public LanguageModel? LanguageModel { get; set; }
/// <summary>
/// Indicates whether sessions are enabled for the agent.
/// </summary>
[JsonProperty("sessions_enabled")]
public bool SessionsEnabled { get; set; }
/// <summary>
/// The agent's conversation history configuration.
/// </summary>
[JsonProperty("conversation_history")]
public ConversationHistory? ConversationHistory { get; set; }
/// <summary>
/// The agent's Gatekeeper configuration.
/// </summary>
[JsonProperty("gatekeeper")]
public Gatekeeper? Gatekeeper { get; set; }
/// <summary>
/// The agent's LLM orchestrator type.
/// </summary>
[JsonProperty("orchestrator")]
public string? Orchestrator { get; set; }
/// <summary>
/// The agent's prompt.
/// </summary>
[JsonProperty("prompt")]
public string? Prompt { get; set; }
}

/// <summary>
/// Agent conversation history settings.
/// </summary>
public class ConversationHistory
{
/// <summary>
/// Indicates whether the conversation history is enabled.
/// </summary>
[JsonProperty("enabled")]
public bool Enabled { get; set; }
/// <summary>
/// The maximum number of turns to store in the conversation history.
/// </summary>
[JsonProperty("max_history")]
public int MaxHistory { get; set; }
}

/// <summary>
/// Agent Gatekeeper settings.
/// </summary>
public class Gatekeeper
{
/// <summary>
/// Indicates whether to abide by or override the system settings for the Gatekeeper.
/// </summary>
[JsonProperty("use_system_setting")]
public bool UseSystemSetting { get; set; }
/// <summary>
/// If <see cref="UseSystemSetting"/> is false, provides Gatekeeper feature selection.
/// </summary>
[JsonProperty("options")]
public string[]? Options { get; set; }
}

}
32 changes: 32 additions & 0 deletions src/dotnet/Agent/Models/Metadata/KnowledgeManagementAgent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FoundationaLLM.Agent.Models.Metadata
{
/// <summary>
/// The Knowledge Management agent metadata model.
/// </summary>
public class KnowledgeManagementAgent : AgentBase
{
/// <summary>
/// The vectorization indexing profile resource path.
/// </summary>
[JsonProperty("indexing_profile")]
public string? IndexingProfile { get; set; }
/// <summary>
/// The vectorization embedding profile resource path.
/// </summary>
[JsonProperty("embedding_profile")]
public string? EmbeddingProfile { get; set; }

/// <summary>
/// Set default property values.
/// </summary>
public KnowledgeManagementAgent() =>
Type = Common.Constants.AgentTypes.KnowledgeManagement;
}
}
37 changes: 37 additions & 0 deletions src/dotnet/Agent/Models/Resources/AgentReference.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using FoundationaLLM.Agent.Models.Metadata;
using FoundationaLLM.Common.Constants;
using FoundationaLLM.Common.Exceptions;
using Newtonsoft.Json;

namespace FoundationaLLM.Agent.Models.Resources
{
/// <summary>
/// Provides details about an agent.
/// </summary>
public class AgentReference
{
/// <summary>
/// The name of the agent.
/// </summary>
public required string Name { get; set; }
/// <summary>
/// The filename of the agent.
/// </summary>
public required string Filename { get; set; }
/// <summary>
/// The type of the agent.
/// </summary>
public required string Type { get; set; }

/// <summary>
/// The object type of the agent.
/// </summary>
[JsonIgnore]
public Type AgentType =>
Type switch
{
AgentTypes.KnowledgeManagement => typeof(KnowledgeManagementAgent),
_ => throw new ResourceProviderException($"The agent type {Type} is not supported.")
};
}
}
37 changes: 37 additions & 0 deletions src/dotnet/Agent/Models/Resources/AgentReferenceStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FoundationaLLM.Agent.Models.Resources
{
/// <summary>
/// Models the content of the agent reference store managed by the FoundationaLLM.Agent resource provider.
/// </summary>
public class AgentReferenceStore
{
/// <summary>
/// The list of all agents registered in the system.
/// </summary>
public required List<AgentReference> AgentReferences { get; set; }

/// <summary>
/// Creates a string-based dictionary of <see cref="AgentReference"/> values from the current object.
/// </summary>
/// <returns>The string-based dictionary of <see cref="AgentReference"/> values from the current object.</returns>
public Dictionary<string, AgentReference> ToDictionary() =>
AgentReferences.ToDictionary<AgentReference, string>(ar => ar.Name);

/// <summary>
/// Creates a new instance of the <see cref="AgentReferenceStore"/> from a dictionary.
/// </summary>
/// <param name="dictionary">A string-based dictionary of <see cref="AgentReference"/> values.</param>
/// <returns>The <see cref="AgentReferenceStore"/> object created from the dictionary.</returns>
public static AgentReferenceStore FromDictionary(Dictionary<string, AgentReference> dictionary) =>
new AgentReferenceStore
{
AgentReferences = dictionary.Values.ToList()
};
}
}
Loading

0 comments on commit a4d68ef

Please sign in to comment.