From 49bed65db1df816bb630d9a706d349033645974c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=AF=85?= <2667210109@qq.com> Date: Sun, 23 Mar 2025 01:51:52 +0800 Subject: [PATCH] 111 --- asg_form/Controllers/Dbset.cs | 2 +- asg_form/Program.cs | 2 +- asg_form/qqbot.cs | 24 +++++++++++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/asg_form/Controllers/Dbset.cs b/asg_form/Controllers/Dbset.cs index 7c1844c..a004bc9 100644 --- a/asg_form/Controllers/Dbset.cs +++ b/asg_form/Controllers/Dbset.cs @@ -294,7 +294,7 @@ namespace asg_form.Controllers public DbSet T_Audit { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - string connStr = @"Host=localhost;Port=2345;Database=asg;Username=postgres;Password=luolan12323;"; + string connStr = @"Host=172.30.121.91;Port=2345;Database=postgres;Username=asg;Password=luolan12323;"; optionsBuilder.UseNpgsql(connStr); diff --git a/asg_form/Program.cs b/asg_form/Program.cs index 0122461..ff9056e 100644 --- a/asg_form/Program.cs +++ b/asg_form/Program.cs @@ -91,7 +91,7 @@ IServiceCollection services = builder.Services; services.AddDbContext(opt => { - string connStr = @"Host=localhost;Port=2345;Database=asg;Username=postgres;Password=luolan12323;"; + string connStr = @"Host=172.30.121.91;Port=2345;Database=postgres;Username=asg;Password=luolan12323;"; opt.UseNpgsql(connStr); }); //services.AddHostedService(); diff --git a/asg_form/qqbot.cs b/asg_form/qqbot.cs index 84ff807..8498879 100644 --- a/asg_form/qqbot.cs +++ b/asg_form/qqbot.cs @@ -27,6 +27,7 @@ using Flandre.Core.Common; using Microsoft.OpenApi.Models; using Flurl.Http; using Microsoft.AspNetCore.Identity; +using Flandre.Core.Messaging.Segments; namespace asg_form { @@ -247,11 +248,14 @@ namespace asg_form public List messages { get; set; } } - private static async Task SendPostRequestAsync(string url, aimessage Content, string apiKey) + private static async Task SendPostRequestAsync(string url, aimessage Content, string apiKey) { + string[] messages = new string[2]; var re= await url.WithOAuthBearerToken(apiKey).PostJsonAsync(Content); var a= await re.GetJsonAsync(); - return a.choices[0].message.content; + messages[0]=a.choices[0].message.reasoning_content; + messages[1]=a.choices[0].message.content; + return messages; } @@ -284,9 +288,13 @@ namespace asg_form { var message= new List (); message.Add(new MessagesItem {role="user", content = msg }); - var ai1= new aimessage() { model= "qwen-turbo",messages=message }; - var msg1= await SendPostRequestAsync("https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions", ai1, "sk-c6f37689f4014b5bbf5fd8b2e872d20b"); - return msg1; + var ai1= new aimessage() { model= "deepseek-reasoner", messages=message }; + var msg1= await SendPostRequestAsync("https://api.deepseek.com/chat/completions", ai1, "sk-2f3167fe9c524a5fa906313f72747cb2"); + await Task.Delay(1000); + var message1 = new MessageBuilder().Text("这是用户询问DeepSeek时产生的思考链\r\n").Text(msg1[0]).Build(); + await runbot.runbotr.SendMessageAsync(MessageEnvironment.Channel, "931217544", null, message1, "931217544"); + + return msg1[1]; } catch(Exception ex) @@ -306,8 +314,10 @@ namespace asg_form var message = new List(); message.Add(new MessagesItem { role = "user", content = msg }); var ai = new aimessage() { model = "qwen-math-plus", messages = message }; - var msg1 = await SendPostRequestAsync("https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions", ai, "sk-c6f37689f4014b5bbf5fd8b2e872d20b"); - return msg1; + var msg1 = await SendPostRequestAsync("https://api.deepseek.com/chat/completions", ai, "sk-c6f37689f4014b5bbf5fd8b2e872d20b"); + return msg1[1]; + + } catch