Merge branch 'SciSharp:master' into master

This commit is contained in:
Haiping 2024-10-08 19:05:44 -05:00 committed by GitHub
commit 7e927dd604
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 7 deletions

View file

@ -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,

View file

@ -11,7 +11,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Anthropic.SDK" Version="3.2.3" />
<PackageReference Include="Anthropic.SDK" Version="4.1.1" />
</ItemGroup>
<ItemGroup>

View file

@ -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";
}

View file

@ -19,7 +19,8 @@
"type": "string",
"description": "table name"
}
},
}
},
"required": [ "sql_statement", "reason", "tables" ]
}
}