-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2042 from solliancenet/gg-resource-properties
Extend agent tool configuration
- Loading branch information
Showing
26 changed files
with
649 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/dotnet/Common/Constants/ResourceProviders/ResourceObjectIdPropertyNames.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace FoundationaLLM.Common.Constants.ResourceProviders | ||
{ | ||
/// <summary> | ||
/// Contains constants of the resource property names. | ||
/// </summary> | ||
public static class ResourceObjectIdPropertyNames | ||
{ | ||
/// <summary> | ||
/// Object role. | ||
/// </summary> | ||
public const string ObjectRole = "object_role"; | ||
|
||
/// <summary> | ||
/// Model parameters. | ||
/// </summary> | ||
public const string ModelParameters = "model_parameters"; | ||
|
||
/// <summary> | ||
/// Text embedding model name. | ||
/// </summary> | ||
public const string TextEmbeddingModelName = "text_embedding_model_name"; | ||
|
||
/// <summary> | ||
/// Text embedding model parameters. | ||
/// </summary> | ||
public const string TextEmbeddingModelParameters = "text_embedding_model_parameters"; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/dotnet/Common/Constants/ResourceProviders/ResourceObjectIdPropertyValues.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace FoundationaLLM.Common.Constants.ResourceProviders | ||
{ | ||
/// <summary> | ||
/// Contains constants of the resource property values. | ||
/// </summary> | ||
public static class ResourceObjectIdPropertyValues | ||
{ | ||
/// <summary> | ||
/// Main model. | ||
/// </summary> | ||
public const string MainModel = "main_model"; | ||
|
||
/// <summary> | ||
/// Main prompt. | ||
/// </summary> | ||
public const string MainPrompt = "main_prompt"; | ||
|
||
/// <summary> | ||
/// Main indexing profile. | ||
/// </summary> | ||
public const string MainIndexingProfile = "main_indexing_profile"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/dotnet/Common/Models/ResourceProviders/ResourceObjectIdProperties.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using FoundationaLLM.Common.Constants.ResourceProviders; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace FoundationaLLM.Common.Models.ResourceProviders | ||
{ | ||
/// <summary> | ||
/// Defines the properties of a resource. | ||
/// </summary> | ||
public class ResourceObjectIdProperties | ||
{ | ||
/// <summary> | ||
/// The unique identifier of the resource. | ||
/// </summary> | ||
[JsonPropertyName("object_id")] | ||
public required string ObjectId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets a dictionary of properties. | ||
/// </summary> | ||
[JsonPropertyName("properties")] | ||
public Dictionary<string, object> Properties { get; set; } = []; | ||
|
||
/// <summary> | ||
/// Indicates whether the resource has the specified object role. | ||
/// </summary> | ||
/// <param name="role">The object role being searched.</param> | ||
/// <returns><see langword="true"/> if the object role is present, <see langword="false"/> otherwise.</returns> | ||
public bool HasObjectRole(string role) => | ||
Properties.TryGetValue(ResourceObjectIdPropertyNames.ObjectRole, out var objectRole) | ||
&& ((JsonElement)objectRole).GetString() == role; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/dotnet/Orchestration/Orchestration/ExplodedObjectsManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using ZstdSharp.Unsafe; | ||
|
||
namespace FoundationaLLM.Orchestration.Core.Orchestration | ||
{ | ||
/// <summary> | ||
/// Manages the exploded objects dictionary ensuring consistency and integrity. | ||
/// </summary> | ||
public class ExplodedObjectsManager | ||
{ | ||
private readonly Dictionary<string, object> _explodedObjects = []; | ||
|
||
/// <summary> | ||
/// Adds a new key value pair to the exploded objects dictionary. | ||
/// </summary> | ||
/// <param name="key">The key of the object to add to the dictionary.</param> | ||
/// <param name="value">The object to add to the dictionary.</param> | ||
/// <returns><see langword="true"/> if the value was added successfully, <see langword="false"/> otherwise.</returns> | ||
/// <remarks> | ||
/// The first attempt to add an object always wins. | ||
/// This means that if the key already exists in the dictionary, the add operation will have no effect and it will not generate an exception either. | ||
/// </remarks> | ||
public bool TryAdd(string key, object value) | ||
{ | ||
if (_explodedObjects.ContainsKey(key)) | ||
return false; | ||
|
||
_explodedObjects.Add(key, value); | ||
return true; | ||
} | ||
|
||
/// <summary> | ||
/// Indicates whether the exploded objects dictionary contains the specified key. | ||
/// </summary> | ||
/// <param name="key">The key being searched for.</param> | ||
/// <returns><see langword="true"/> if the key is present in the dictionary (even if the associated value is null), <see langword="false"/> otherwise.</returns> | ||
public bool HasKey(string key) => | ||
_explodedObjects.ContainsKey(key); | ||
|
||
/// <summary> | ||
/// Tries to get the value associated with the specified key. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the value associated with the key.</typeparam> | ||
/// <param name="key">The key being searched for.</param> | ||
/// <param name="value">The value being searched for.</param> | ||
/// <returns>The typed object associated with the specified key.</returns> | ||
public bool TryGet<T>(string key, out T? value) where T : class | ||
{ | ||
value = default(T); | ||
|
||
if (_explodedObjects.TryGetValue(key, out var obj)) | ||
{ | ||
value = obj as T; | ||
return value != null; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the exploded objects dictionary. | ||
/// </summary> | ||
/// <returns>A shallow copy of the internal exploded objects dictionary. This only prevents unguarded changes to the key-value pairs but not to the values themselves.</returns> | ||
public Dictionary<string, object> GetExplodedObjects() => | ||
new(_explodedObjects); | ||
} | ||
} |
Oops, something went wrong.