2025-11-28 12:07:35 +01:00
|
|
|
|
using BS.Shared.Exceptions;
|
2025-06-13 11:37:19 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BeWo.Service.Core
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class ConfigReader
|
|
|
|
|
|
{
|
|
|
|
|
|
public static List<string> GetIPAddressList(IPAddressList iPAddressList)
|
|
|
|
|
|
{
|
2025-06-17 15:46:04 +02:00
|
|
|
|
if(iPAddressList == IPAddressList.None)
|
|
|
|
|
|
throw new ArgumentException(nameof(iPAddressList));
|
|
|
|
|
|
|
2025-11-28 12:07:35 +01:00
|
|
|
|
var lSubPath = getIPAddressListName(iPAddressList);
|
|
|
|
|
|
|
|
|
|
|
|
var lConfigPath = getConfigPath(lSubPath);
|
2025-06-13 11:37:19 +02:00
|
|
|
|
|
|
|
|
|
|
var lines = File.ReadAllLines(lConfigPath);
|
|
|
|
|
|
|
|
|
|
|
|
return lines.ToList();
|
|
|
|
|
|
}
|
2025-11-28 12:07:35 +01:00
|
|
|
|
|
|
|
|
|
|
public static string GetConfigPath(SpecialConfig specialConfig)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (specialConfig == SpecialConfig.None)
|
|
|
|
|
|
throw new ArgumentException(nameof(specialConfig));
|
|
|
|
|
|
|
|
|
|
|
|
var lSubPath = getSpecialConfigName(specialConfig);
|
|
|
|
|
|
|
|
|
|
|
|
var lConfigPath = getConfigPath(lSubPath);
|
|
|
|
|
|
|
|
|
|
|
|
return lConfigPath;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static string getConfigPath(string subpath)
|
|
|
|
|
|
{
|
|
|
|
|
|
var root = AppDomain.CurrentDomain.BaseDirectory;
|
|
|
|
|
|
|
|
|
|
|
|
var path = Path.Combine(root, "Config", subpath);
|
|
|
|
|
|
|
|
|
|
|
|
return path;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static string getSpecialConfigName(SpecialConfig config)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (config)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SpecialConfig.None:
|
|
|
|
|
|
break;
|
2026-02-20 12:51:18 +01:00
|
|
|
|
case SpecialConfig.CustomFunctionPreSystemPrompt:
|
|
|
|
|
|
return Path.Combine("ai", "systemPrompts", "customFunctionPreSystemPrompt.txt");
|
|
|
|
|
|
case SpecialConfig.CustomPreSystemPrompt:
|
|
|
|
|
|
return Path.Combine("ai", "systemPrompts", "customPreSystemPrompt.txt");
|
2025-11-28 12:07:35 +01:00
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
throw BeWoNotImplementedException.CreateFromEnum(config);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static string getIPAddressListName(IPAddressList list)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (list)
|
|
|
|
|
|
{
|
|
|
|
|
|
case IPAddressList.None:
|
|
|
|
|
|
break;
|
|
|
|
|
|
case IPAddressList.AdminApi:
|
|
|
|
|
|
return "allowed_ips_admin_api.txt";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
throw BeWoNotImplementedException.CreateFromEnum(list);
|
|
|
|
|
|
}
|
2025-06-13 11:37:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|