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