11
This commit is contained in:
@@ -2974,7 +2974,13 @@ namespace BLL
|
||||
/// </summary>
|
||||
public const string HJGL_TDMImportMenuId = "B13BFFA5-3112-4209-8562-5329B78B405C";
|
||||
|
||||
/// <summary>
|
||||
/// 数据导入
|
||||
/// </summary>
|
||||
public const string HJGL_DataInMenuId = "ERDXV53M-09B1-6UIO-6666-5DVZDF329001";
|
||||
#endregion
|
||||
|
||||
|
||||
#region 焊接过程
|
||||
/// <summary>
|
||||
/// 焊口二次设计
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
|
||||
using FastReport.Utils;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.POIFS.Crypt;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace BLL.Common
|
||||
{
|
||||
public class OpenAIhelper
|
||||
{
|
||||
private const string ApiKey = "sk-a5014a22a49049d1b2179a6c0d8eec1c";
|
||||
private const string AIURL = "https://api.deepseek.com/chat/completions";
|
||||
|
||||
public static string ChatCompletion(string content)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + ApiKey);
|
||||
|
||||
var requestData = new
|
||||
{
|
||||
model = "deepseek-v4-flash",
|
||||
messages = new[] {
|
||||
new { role = "user", content = content }
|
||||
},
|
||||
temperature = 0.3
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(requestData);
|
||||
var chatContent = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
// 同步请求
|
||||
var response = client.PostAsync(AIURL, chatContent).Result;
|
||||
string resultJson = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
// 解析返回
|
||||
dynamic result = JsonConvert.DeserializeObject(resultJson);
|
||||
return result.choices[0].message.content.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user