Skip to content

Features/add agent function impact #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Expand Up @@ -4,6 +4,7 @@ public class FunctionDef
{
public string Name { get; set; }
public string Description { get; set; }
public string? Impact { get; set; }
public FunctionParametersDef Parameters { get; set; } = new FunctionParametersDef();

public override string ToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public async Task<List<Conversation>> GetConversations()
public async Task<Conversation> NewConversation(Conversation sess)
{
var db = _services.GetRequiredService<IBotSharpRepository>();
var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>();
var conversationSettings = _services.GetRequiredService<ConversationSetting>();
var user = db.GetUserByExternalId(_user.Id);
var foundUserId = user?.Id ?? string.Empty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using BotSharp.Abstraction.Agents.Models;
using MongoDB.Driver;
using BotSharp.Abstraction.Routing.Models;
using Amazon.Util;

namespace BotSharp.Core.Repository;

Expand Down Expand Up @@ -373,13 +372,7 @@ private void UpdateAgentFunctions(string agentId, List<FunctionDef> inputFunctio
var functionFile = Path.Combine(_dbSettings.FileRepository, _agentSettings.DataDir,
agentId, "functions.json");

var functions = new List<string>();
foreach (var function in inputFunctions)
{
functions.Add(JsonSerializer.Serialize(function, _options));
}

var functionText = JsonSerializer.Serialize(functions, _options);
var functionText = JsonSerializer.Serialize(inputFunctions, _options);
File.WriteAllText(functionFile, functionText);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace BotSharp.Plugin.MongoStorage.Models;

[BsonIgnoreExtraElements]
public class AgentResponseMongoElement
{
public string Prefix { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace BotSharp.Plugin.MongoStorage.Models;

[BsonIgnoreExtraElements]
public class AgentTemplateMongoElement
{
public string Name { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

namespace BotSharp.Plugin.MongoStorage.Models;

[BsonIgnoreExtraElements]
public class FunctionDefMongoElement
{
public string Name { get; set; }
public string Description { get; set; }
public string? Impact { get; set; }
public FunctionParametersDefMongoElement Parameters { get; set; } = new FunctionParametersDefMongoElement();

public FunctionDefMongoElement()
Expand All @@ -20,6 +22,7 @@ public static FunctionDefMongoElement ToMongoElement(FunctionDef function)
{
Name = function.Name,
Description = function.Description,
Impact = function.Impact,
Parameters = new FunctionParametersDefMongoElement
{
Type = function.Parameters.Type,
Expand All @@ -35,6 +38,7 @@ public static FunctionDef ToDomainElement(FunctionDefMongoElement mongoFunction)
{
Name = mongoFunction.Name,
Description = mongoFunction.Description,
Impact = mongoFunction.Impact,
Parameters = new FunctionParametersDef
{
Type = mongoFunction.Parameters.Type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace BotSharp.Plugin.MongoStorage.Models;

[BsonIgnoreExtraElements]
public class RoutingRuleMongoElement
{
public string Field { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion src/Plugins/BotSharp.Plugin.MongoStorage/Using.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using MongoDB.Bson;
global using MongoDB.Driver;
global using MongoDB.Driver;
global using MongoDB.Bson.Serialization.Attributes;