Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(TargetFramework)</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public class RoleDialogModel : ITrackableMessage
[JsonPropertyName("generated_images")]
public List<ImageGeneration> GeneratedImages { get; set; } = new List<ImageGeneration>();


[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public string RenderedInstruction { get; set; } = string.Empty;

private RoleDialogModel()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public interface IInstructHook
string SelfId { get; }
Task BeforeCompletion(Agent agent, RoleDialogModel message);
Task AfterCompletion(Agent agent, InstructResult result);
Task OnResponseGenerated(InstructResponseModel response);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ public virtual async Task AfterCompletion(Agent agent, InstructResult result)
{
return;
}

public virtual async Task OnResponseGenerated(InstructResponseModel response)
{
return;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;

namespace BotSharp.Abstraction.Instructs.Models;

public class InstructLogFilter : Pagination
{
public List<string>? AgentIds { get; set; }
public List<string>? Providers { get; set; }
public List<string>? Models { get; set; }
public List<string>? TemplateNames { get; set; }

public static InstructLogFilter Empty()
{
return new InstructLogFilter();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace BotSharp.Abstraction.Instructs.Models;

public class InstructResponseModel
{
public string? AgentId { get; set; }
public string Provider { get; set; } = default!;
public string Model { get; set; } = default!;
public string? TemplateName { get; set; }
public string UserMessage { get; set; } = default!;
public string? SystemInstruction { get; set; }
public string CompletionText { get; set; } = default!;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System.Text.Json;

namespace BotSharp.Abstraction.Loggers.Models;

public class InstructionLogModel
{
[JsonPropertyName("id")]
public string Id { get; set; } = default!;

[JsonPropertyName("agent_id")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? AgentId { get; set; }

[JsonPropertyName("agent_name")]
[JsonIgnore]
public string? AgentName { get; set; }

[JsonPropertyName("provider")]
public string Provider { get; set; } = default!;

[JsonPropertyName("model")]
public string Model { get; set; } = default!;

[JsonPropertyName("template_name")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? TemplateName { get; set; }

[JsonPropertyName("user_message")]
public string UserMessage { get; set; } = string.Empty;

[JsonPropertyName("system_instruction")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? SystemInstruction { get; set; }

[JsonPropertyName("completion_text")]
public string CompletionText { get; set; } = string.Empty;

[JsonPropertyName("user_id")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? UserId { get; set; }

[JsonIgnore]
public Dictionary<string, string> States { get; set; } = [];

[JsonPropertyName("states")]
public Dictionary<string, JsonDocument> InnerStates { get; set; } = [];

[JsonPropertyName("created_time")]
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public interface IAudioCompletion
{
string Provider { get; }

string Model { get; }

Task<string> GenerateTextFromAudioAsync(Stream audio, string audioFileName, string? text = null);
Task<BinaryData> GenerateAudioFromTextAsync(string text);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public interface IChatCompletion
/// </summary>
string Provider { get; }

string Model { get; }

/// <summary>
/// Set model name, one provider can consume different model or version(s)
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public interface IImageCompletion
/// </summary>
string Provider { get; }

string Model { get; }

/// <summary>
/// Set model name, one provider can consume different model or version(s)
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public interface IRealTimeCompletion
{
string Provider { get; }
string Model { get; }

void SetModelName(string model);

Task Connect(RealtimeHubConnection conn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public interface ITextCompletion
/// The LLM provider like Microsoft Azure, OpenAI, ClaudAI
/// </summary>
string Provider { get; }
string Model { get; }

/// <summary>
/// Set model name, one provider can consume different model or version(s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ public interface ITextEmbedding
/// The Embedding provider like Microsoft Azure, OpenAI, ClaudAI
/// </summary>
string Provider { get; }
string Model { get; }

void SetModelName(string model);


Task<float[]> GetVectorAsync(string text);
Task<List<float[]>> GetVectorsAsync(List<string> texts);
void SetModelName(string model);

void SetDimension(int dimension);
int GetDimension();
}
14 changes: 14 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Models/KeyValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@ public override string ToString()
return $"Key: {Key}, Value: {Value}";
}
}

public class KeyValue<T>
{
[JsonPropertyName("key")]
public string Key { get; set; }

[JsonPropertyName("value")]
public T? Value { get; set; }

public override string ToString()
{
return $"Key: {Key}, Value: {Value}";
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using BotSharp.Abstraction.Instructs.Models;
using BotSharp.Abstraction.Loggers.Models;
using BotSharp.Abstraction.Plugins.Models;
using BotSharp.Abstraction.Repositories.Filters;
Expand Down Expand Up @@ -171,6 +172,14 @@ List<ConversationStateLogModel> GetConversationStateLogs(string conversationId)
=> throw new NotImplementedException();
#endregion

#region Instruction Log
bool SaveInstructionLogs(IEnumerable<InstructionLogModel> logs)
=> throw new NotImplementedException();

PagedItems<InstructionLogModel> GetInstructionLogs(InstructLogFilter filter)
=> throw new NotImplementedException();
#endregion

#region Statistics
BotSharpStats? GetGlobalStats(string metric, string dimension, string dimRefVal, DateTime recordTime, StatsInterval interval)
=> throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,20 @@ public static string JsonArrayContent(this string text)

return JsonSerializer.Deserialize<T[]>(text, options);
}

public static bool IsPrimitiveValue(this string value)
{
return int.TryParse(value, out _) ||
long.TryParse(value, out _) ||
double.TryParse(value, out _) ||
float.TryParse(value, out _) ||
bool.TryParse(value, out _) ||
char.TryParse(value, out _) ||
byte.TryParse(value, out _) ||
sbyte.TryParse(value, out _) ||
short.TryParse(value, out _) ||
ushort.TryParse(value, out _) ||
uint.TryParse(value, out _) ||
ulong.TryParse(value, out _);
}
}
Loading