Browse Source

自助机跟ai

master
wxd 3 months ago
parent
commit
34caed1f28
  1. 34
      src/Shentun.Peis.Application/AIMessages/AIMessageAppService.cs
  2. 2
      src/Shentun.Peis.Application/SelfServiceMachines/SelfServiceMachineAppService.cs

34
src/Shentun.Peis.Application/AIMessages/AIMessageAppService.cs

@ -76,19 +76,49 @@ namespace Shentun.Peis.AIMessages
client.BaseAddress = new Uri(apiBaseAddress);
// 设置API密钥或其他认证信息(如果有的话)
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
//client.DefaultRequestHeaders.Add("Accept", "text/html");
try
{
var requestBody = new
{
model = modelValue,
messages = new[] { new { role = "user", content = input.Message } }
//response_format = "html"
};
var response = await client.PostAsJsonAsync("chat/completions", requestBody);
var result = await response.Content.ReadFromJsonAsync<DeepSeekResponse>();
string data = result.Choices.First().Message.Content;
messageDto.Result = data;
//string dataHtml = data.Replace("### ", "").Replace("---", "").Replace("-", "");
//var dataHtmlList = dataHtml.Split("**", StringSplitOptions.RemoveEmptyEntries).ToList();
//StringBuilder stringBuilder = new StringBuilder();
//foreach (var item in dataHtmlList)
//{
// var sindex = dataHtmlList.IndexOf(item) + 1;
// if (sindex > 1)
// {
// if (sindex % 2 == 0)
// {
// stringBuilder.Append("<strong>" + item);
// }
// else
// {
// stringBuilder.Append("</strong>" + item);
// }
// }
// else
// {
// stringBuilder.Append(item);
// }
//}
//messageDto.Result = stringBuilder.ToString();
string dataHtml = data.Replace("### ", "").Replace("---", "").Replace("-", "").Replace("**", "");
messageDto.Result = dataHtml;
}
catch (HttpRequestException e)

2
src/Shentun.Peis.Application/SelfServiceMachines/SelfServiceMachineAppService.cs

@ -91,7 +91,7 @@ namespace Shentun.Peis.SelfServiceMachines
{
patientRegisterQuery = patientRegisterQuery.Where(m => m.patientRegister.PatientRegisterNo == input.PatientRegisterNo);
}
else if (!string.IsNullOrWhiteSpace(input.PatientRegisterNo))
else if (!string.IsNullOrWhiteSpace(input.PatientNo))
{
patientRegisterQuery = patientRegisterQuery.Where(m => m.patient.PatientNo == input.PatientNo);
}

Loading…
Cancel
Save