Merge branch 'master' of https://dev.azure.com/luolan/ASG/_git/asg_backend
This commit is contained in:
		
						commit
						c48ff0418e
					
				@ -318,7 +318,7 @@ namespace asg_form.Controllers
 | 
			
		||||
        public DbSet<FileDB> 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);
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
@ -91,7 +91,7 @@ IServiceCollection services = builder.Services;
 | 
			
		||||
 | 
			
		||||
services.AddDbContext<IDBcontext>(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<qqbot>();
 | 
			
		||||
 | 
			
		||||
@ -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<MessagesItem> messages { get; set; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static async Task<string> SendPostRequestAsync(string url, aimessage Content, string apiKey)
 | 
			
		||||
        private static async Task<string[]> 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<MessagesItem> ();
 | 
			
		||||
                  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<MessagesItem>();
 | 
			
		||||
                 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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user