Merge branch 'master' of https://github.com/Qtoss-AI/BotSharp
This commit is contained in:
commit
527e689338
|
|
@ -33,4 +33,6 @@ public class UserRole
|
|||
/// AI Assistant
|
||||
/// </summary>
|
||||
public const string Assistant = "assistant";
|
||||
|
||||
public const string Root = "root";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ public class InstructModeController : ControllerBase
|
|||
.SetState("model", input.Model, source: StateSource.External)
|
||||
.SetState("model_id", input.ModelId, source: StateSource.External)
|
||||
.SetState("instruction", input.Instruction, source: StateSource.External)
|
||||
.SetState("input_text", input.Text,source: StateSource.External);
|
||||
.SetState("input_text", input.Text, source: StateSource.External)
|
||||
.SetState("template_name", input.Template, source: StateSource.External);
|
||||
|
||||
var instructor = _services.GetRequiredService<IInstructService>();
|
||||
var result = await instructor.Execute(agentId,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Anthropic.SDK" Version="3.2.3" />
|
||||
<PackageReference Include="Anthropic.SDK" Version="4.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -179,8 +179,15 @@ public class ChatCompletionProvider : IChatCompletion
|
|||
Model = settings.Name,
|
||||
Stream = false,
|
||||
Temperature = temperature,
|
||||
SystemMessage = instruction,
|
||||
Tools = new List<Function>() { }
|
||||
Tools = new List<Anthropic.SDK.Common.Tool>()
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(instruction))
|
||||
{
|
||||
parameters.System = new List<SystemMessage>()
|
||||
{
|
||||
new SystemMessage(instruction)
|
||||
};
|
||||
};
|
||||
|
||||
JsonSerializerOptions jsonSerializationOptions = new()
|
||||
|
|
@ -221,7 +228,7 @@ public class ChatCompletionProvider : IChatCompletion
|
|||
|
||||
private string GetPrompt(MessageParameters parameters)
|
||||
{
|
||||
var prompt = $"{parameters.SystemMessage}\r\n";
|
||||
var prompt = $"{string.Join("\r\n", parameters.System.Select(x => x.Text))}\r\n";
|
||||
prompt += "\r\n[CONVERSATION]";
|
||||
|
||||
var verbose = string.Join("\r\n", parameters.Messages
|
||||
|
|
@ -264,7 +271,7 @@ public class ChatCompletionProvider : IChatCompletion
|
|||
{
|
||||
var functions = string.Join("\r\n", parameters.Tools.Select(x =>
|
||||
{
|
||||
return $"\r\n{x.Name}: {x.Description}\r\n{JsonSerializer.Serialize(x.Parameters)}";
|
||||
return $"\r\n{x.Function.Name}: {x.Function.Description}\r\n{JsonSerializer.Serialize(x.Function.Parameters)}";
|
||||
}));
|
||||
prompt += $"\r\n[FUNCTIONS]\r\n{functions}\r\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public partial class KnowledgeService
|
|||
payload[KnowledgePayloadName.FileUrl] = file.FileUrl;
|
||||
}
|
||||
|
||||
var dataIds = await SaveToVectorDb(collectionName, fileId, file.FileName, contents, payload);
|
||||
var dataIds = await SaveToVectorDb(collectionName, contents, payload);
|
||||
if (!dataIds.IsNullOrEmpty())
|
||||
{
|
||||
db.SaveKnolwedgeBaseFileMeta(new KnowledgeDocMetaData
|
||||
|
|
@ -145,7 +145,7 @@ public partial class KnowledgeService
|
|||
payload[KnowledgePayloadName.FileUrl] = refData.Url;
|
||||
}
|
||||
|
||||
var dataIds = await SaveToVectorDb(collectionName, fileId, fileName, contents, payload);
|
||||
var dataIds = await SaveToVectorDb(collectionName, contents, payload);
|
||||
db.SaveKnolwedgeBaseFileMeta(new KnowledgeDocMetaData
|
||||
{
|
||||
Collection = collectionName,
|
||||
|
|
@ -411,8 +411,7 @@ public partial class KnowledgeService
|
|||
return saved;
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<string>> SaveToVectorDb(
|
||||
string collectionName, Guid fileId, string fileName, IEnumerable<string> contents, Dictionary<string, object>? payload = null)
|
||||
private async Task<IEnumerable<string>> SaveToVectorDb(string collectionName, IEnumerable<string> contents, Dictionary<string, object>? payload = null)
|
||||
{
|
||||
if (contents.IsNullOrEmpty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
"type": "string",
|
||||
"description": "table name"
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
"required": [ "sql_statement", "reason", "tables" ]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue