✨ Thinking of the LangChain ver
This commit is contained in:
@@ -21,7 +21,6 @@ var developService = builder.AddProject<Projects.DysonNetwork_Develop>("develop"
|
|||||||
.WithReference(passService)
|
.WithReference(passService)
|
||||||
.WithReference(ringService)
|
.WithReference(ringService)
|
||||||
.WithReference(sphereService);
|
.WithReference(sphereService);
|
||||||
|
|
||||||
var insightService = builder.AddProject<Projects.DysonNetwork_Insight>("insight")
|
var insightService = builder.AddProject<Projects.DysonNetwork_Insight>("insight")
|
||||||
.WithReference(passService)
|
.WithReference(passService)
|
||||||
.WithReference(ringService)
|
.WithReference(ringService)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
<PackageReference Include="NodaTime.Serialization.Protobuf" Version="2.0.2" />
|
<PackageReference Include="NodaTime.Serialization.Protobuf" Version="2.0.2" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4"/>
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4"/>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="9.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="9.0.4" />
|
||||||
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1"/>
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
|
||||||
<PackageReference Include="NodaTime" Version="3.2.2"/>
|
<PackageReference Include="NodaTime" Version="3.2.2"/>
|
||||||
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.3.0"/>
|
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.3.0"/>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using DysonNetwork.Develop.Identity;
|
using DysonNetwork.Develop.Identity;
|
||||||
using DysonNetwork.Shared.Auth;
|
using DysonNetwork.Shared.Auth;
|
||||||
using DysonNetwork.Shared.Http;
|
using DysonNetwork.Shared.Http;
|
||||||
using Prometheus;
|
|
||||||
|
|
||||||
namespace DysonNetwork.Develop.Startup;
|
namespace DysonNetwork.Develop.Startup;
|
||||||
|
|
||||||
@@ -9,7 +8,6 @@ public static class ApplicationConfiguration
|
|||||||
{
|
{
|
||||||
public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration)
|
public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
app.MapMetrics();
|
|
||||||
app.MapOpenApi();
|
app.MapOpenApi();
|
||||||
|
|
||||||
app.UseRequestLocalization();
|
app.UseRequestLocalization();
|
||||||
|
|||||||
@@ -18,9 +18,5 @@
|
|||||||
},
|
},
|
||||||
"Etcd": {
|
"Etcd": {
|
||||||
"Insecure": true
|
"Insecure": true
|
||||||
},
|
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Develop",
|
|
||||||
"Url": "https://localhost:7192"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,11 +43,6 @@
|
|||||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.13.0" />
|
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.13.0" />
|
||||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
|
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
|
||||||
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
|
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
|
||||||
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1" />
|
|
||||||
<PackageReference Include="prometheus-net.AspNetCore.HealthChecks" Version="8.2.1" />
|
|
||||||
<PackageReference Include="prometheus-net.DotNetRuntime" Version="4.4.1" />
|
|
||||||
<PackageReference Include="prometheus-net.EntityFramework" Version="0.9.5" />
|
|
||||||
<PackageReference Include="prometheus-net.SystemMetrics" Version="3.1.0" />
|
|
||||||
<PackageReference Include="Quartz" Version="3.14.0" />
|
<PackageReference Include="Quartz" Version="3.14.0" />
|
||||||
<PackageReference Include="Quartz.AspNetCore" Version="3.14.0" />
|
<PackageReference Include="Quartz.AspNetCore" Version="3.14.0" />
|
||||||
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.14.0" />
|
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.14.0" />
|
||||||
|
|||||||
@@ -117,9 +117,5 @@
|
|||||||
"KnownProxies": [
|
"KnownProxies": [
|
||||||
"127.0.0.1",
|
"127.0.0.1",
|
||||||
"::1"
|
"::1"
|
||||||
],
|
]
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Drive",
|
|
||||||
"Url": "https://localhost:7092"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ builder.Services.AddRateLimiter(options =>
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
var serviceNames = new[] { "ring", "pass", "drive", "sphere", "develop" };
|
var serviceNames = new[] { "ring", "pass", "drive", "sphere", "develop", "insight" };
|
||||||
|
|
||||||
var specialRoutes = new[]
|
var specialRoutes = new[]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,13 +8,21 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="EFCore.NamingConventions" Version="9.0.0" />
|
<PackageReference Include="EFCore.NamingConventions" Version="9.0.0" />
|
||||||
|
<PackageReference Include="LangChain" Version="0.17.0" />
|
||||||
|
<PackageReference Include="LangChain.Databases.Postgres" Version="0.17.0" />
|
||||||
|
<PackageReference Include="LangChain.Serve" Version="0.17.0" />
|
||||||
|
<PackageReference Include="LangChain.Serve.OpenAI" Version="0.17.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.10" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="9.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="9.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DysonNetwork.Develop\DysonNetwork.Develop.csproj" />
|
<ProjectReference Include="..\DysonNetwork.Shared\DysonNetwork.Shared.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Controllers\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
@DysonNetwork.Insight_HostAddress = http://localhost:5232
|
|
||||||
|
|
||||||
GET {{DysonNetwork.Insight_HostAddress}}/weatherforecast/
|
|
||||||
Accept: application/json
|
|
||||||
|
|
||||||
###
|
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
using DysonNetwork.Insight;
|
using DysonNetwork.Insight;
|
||||||
using DysonNetwork.Insight.Startup;
|
using DysonNetwork.Insight.Startup;
|
||||||
using DysonNetwork.Shared.Http;
|
using DysonNetwork.Shared.Http;
|
||||||
|
using LangChain.Extensions.DependencyInjection;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using LangChain.Serve;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@@ -9,7 +11,13 @@ builder.AddServiceDefaults();
|
|||||||
|
|
||||||
builder.ConfigureAppKestrel(builder.Configuration);
|
builder.ConfigureAppKestrel(builder.Configuration);
|
||||||
|
|
||||||
builder.Services.AddDbContext<AppDatabase>();
|
builder.Services.AddControllers();
|
||||||
|
builder.Services.AddAppServices(builder.Configuration);
|
||||||
|
builder.Services.AddAppAuthentication();
|
||||||
|
builder.Services.AddAppFlushHandlers();
|
||||||
|
builder.Services.AddAppBusinessServices();
|
||||||
|
builder.Services.AddThinkingServices(builder.Configuration);
|
||||||
|
builder.Services.AddLangChainServe();
|
||||||
|
|
||||||
builder.AddSwaggerManifest(
|
builder.AddSwaggerManifest(
|
||||||
"DysonNetwork.Insight",
|
"DysonNetwork.Insight",
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": false,
|
"launchBrowser": false,
|
||||||
"applicationUrl": "http://localhost:5232",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": false,
|
"launchBrowser": false,
|
||||||
"applicationUrl": "https://localhost:7142;http://localhost:5232",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using DysonNetwork.Shared.Http;
|
using DysonNetwork.Shared.Http;
|
||||||
using Prometheus;
|
|
||||||
|
|
||||||
namespace DysonNetwork.Insight.Startup;
|
namespace DysonNetwork.Insight.Startup;
|
||||||
|
|
||||||
@@ -7,7 +6,6 @@ public static class ApplicationConfiguration
|
|||||||
{
|
{
|
||||||
public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration)
|
public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
app.MapMetrics();
|
|
||||||
app.MapOpenApi();
|
app.MapOpenApi();
|
||||||
|
|
||||||
app.UseRequestLocalization();
|
app.UseRequestLocalization();
|
||||||
|
|||||||
115
DysonNetwork.Insight/Startup/ServiceCollectionExtensions.cs
Normal file
115
DysonNetwork.Insight/Startup/ServiceCollectionExtensions.cs
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using DysonNetwork.Insight.Thinking;
|
||||||
|
using DysonNetwork.Shared.Cache;
|
||||||
|
using LangChain.Memory;
|
||||||
|
using LangChain.Serve;
|
||||||
|
using LangChain.Serve.Abstractions.Repository;
|
||||||
|
using LangChain.Serve.OpenAI;
|
||||||
|
using static LangChain.Chains.Chain;
|
||||||
|
using Message = LangChain.Providers.Message;
|
||||||
|
using MessageRole = LangChain.Providers.MessageRole;
|
||||||
|
using NodaTime;
|
||||||
|
using NodaTime.Serialization.SystemTextJson;
|
||||||
|
|
||||||
|
namespace DysonNetwork.Insight.Startup;
|
||||||
|
|
||||||
|
public static class ServiceCollectionExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddAppServices(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services.AddDbContext<AppDatabase>();
|
||||||
|
services.AddSingleton<IClock>(SystemClock.Instance);
|
||||||
|
services.AddHttpContextAccessor();
|
||||||
|
services.AddSingleton<ICacheService, CacheServiceRedis>();
|
||||||
|
|
||||||
|
services.AddHttpClient();
|
||||||
|
|
||||||
|
// Register gRPC services
|
||||||
|
services.AddGrpc(options =>
|
||||||
|
{
|
||||||
|
options.EnableDetailedErrors = true; // Will be adjusted in Program.cs
|
||||||
|
options.MaxReceiveMessageSize = 16 * 1024 * 1024; // 16MB
|
||||||
|
options.MaxSendMessageSize = 16 * 1024 * 1024; // 16MB
|
||||||
|
});
|
||||||
|
|
||||||
|
// Register gRPC reflection for service discovery
|
||||||
|
services.AddGrpc();
|
||||||
|
|
||||||
|
// Register gRPC services
|
||||||
|
|
||||||
|
// Register OIDC services
|
||||||
|
services.AddControllers().AddJsonOptions(options =>
|
||||||
|
{
|
||||||
|
options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals;
|
||||||
|
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower;
|
||||||
|
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.SnakeCaseLower;
|
||||||
|
|
||||||
|
options.JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
|
||||||
|
});
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddAppAuthentication(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddAuthorization();
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddAppFlushHandlers(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddSingleton<FlushBufferService>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddAppBusinessServices(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddThinkingServices(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
var modelProvider = new ThinkingProvider(configuration);
|
||||||
|
services.AddSingleton(modelProvider);
|
||||||
|
|
||||||
|
services.AddCustomNameGenerator(async messages =>
|
||||||
|
{
|
||||||
|
var template =
|
||||||
|
@"You will be given conversation between User and Assistant. Your task is to give name to this conversation using maximum 3 words
|
||||||
|
Conversation:
|
||||||
|
{chat_history}
|
||||||
|
Your name: ";
|
||||||
|
var conversationBufferMemory = await ConvertToConversationBuffer(messages);
|
||||||
|
var chain = LoadMemory(conversationBufferMemory, "chat_history")
|
||||||
|
| Template(template)
|
||||||
|
| LLM(modelProvider.GetModel());
|
||||||
|
|
||||||
|
return await chain.RunAsync("text") ?? string.Empty;
|
||||||
|
});
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<ConversationBufferMemory> ConvertToConversationBuffer(
|
||||||
|
IReadOnlyCollection<StoredMessage> list
|
||||||
|
)
|
||||||
|
{
|
||||||
|
var conversationBufferMemory = new ConversationBufferMemory
|
||||||
|
{
|
||||||
|
Formatter =
|
||||||
|
{
|
||||||
|
HumanPrefix = "User",
|
||||||
|
AiPrefix = "Assistant",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
List<Message> converted = list
|
||||||
|
.Select(x => new Message(x.Content, x.Author == MessageAuthor.User ? MessageRole.Human : MessageRole.Ai))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
await conversationBufferMemory.ChatHistory.AddMessages(converted);
|
||||||
|
|
||||||
|
return conversationBufferMemory;
|
||||||
|
}
|
||||||
|
}
|
||||||
99
DysonNetwork.Insight/Thinking/ThinkingController.cs
Normal file
99
DysonNetwork.Insight/Thinking/ThinkingController.cs
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using LangChain.Providers;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Text;
|
||||||
|
using CSharpToJsonSchema;
|
||||||
|
|
||||||
|
namespace DysonNetwork.Insight.Thinking;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("/api/thinking")]
|
||||||
|
public class ThinkingController(ThinkingProvider provider) : ControllerBase
|
||||||
|
{
|
||||||
|
public class StreamThinkingRequest
|
||||||
|
{
|
||||||
|
[Required] public string UserMessage { get; set; } = null!;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("stream")]
|
||||||
|
public async Task ChatStream([FromBody] StreamThinkingRequest request)
|
||||||
|
{
|
||||||
|
// Set response for streaming
|
||||||
|
Response.Headers.Append("Content-Type", "text/event-stream");
|
||||||
|
Response.StatusCode = 200;
|
||||||
|
|
||||||
|
var model = provider.GetModel();
|
||||||
|
|
||||||
|
// Build conversation history (you may load from your memory store)
|
||||||
|
var messages = new List<Message>
|
||||||
|
{
|
||||||
|
new Message
|
||||||
|
{
|
||||||
|
Role = MessageRole.System,
|
||||||
|
Content =
|
||||||
|
"You're a helpful assistant on the Solar Network, a social network. Your name is Sn-chan, a cute sweet heart with passion for almost everything."
|
||||||
|
},
|
||||||
|
new Message
|
||||||
|
{
|
||||||
|
Role = MessageRole.Human,
|
||||||
|
Content = request.UserMessage
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Mock tool definitions — you will replace these with your real tool calls
|
||||||
|
Func<string, Task<string>> getUserProfileAsync = async (userId) =>
|
||||||
|
{
|
||||||
|
// MOCK: simulate fetching user profile
|
||||||
|
await Task.Delay(100); // simulate async work
|
||||||
|
return $"{{\"userId\":\"{userId}\",\"name\":\"MockUser\",\"bio\":\"Loves music and tech.\"}}";
|
||||||
|
};
|
||||||
|
|
||||||
|
Func<string, Task<string>> getRecentPostsAsync = async (topic) =>
|
||||||
|
{
|
||||||
|
// MOCK: simulate fetching recent posts
|
||||||
|
await Task.Delay(200);
|
||||||
|
return
|
||||||
|
$"[{{\"postId\":\"p1\",\"topic\":\"{topic}\",\"content\":\"Mock post content 1.\"}} , {{\"postId\":\"p2\",\"topic\":\"{topic}\",\"content\":\"Mock post content 2.\"}}]";
|
||||||
|
};
|
||||||
|
|
||||||
|
// You might pass these tools into your model/agent context
|
||||||
|
// (Assuming your LangChain .NET version supports tool-binding; adapt as needed.)
|
||||||
|
|
||||||
|
// Kick off streaming generation
|
||||||
|
var accumulatedContent = new StringBuilder();
|
||||||
|
await foreach (var chunk in model.GenerateAsync(
|
||||||
|
new ChatRequest
|
||||||
|
{
|
||||||
|
Messages = messages,
|
||||||
|
Tools =
|
||||||
|
[
|
||||||
|
new Tool
|
||||||
|
{
|
||||||
|
Name = "get_user_profile",
|
||||||
|
Description = "Get a user profile from the Solar Network."
|
||||||
|
},
|
||||||
|
new Tool
|
||||||
|
{
|
||||||
|
Name = "get_recent_posts",
|
||||||
|
Description = "Get recent posts from the Solar Network."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
new ChatSettings { UseStreaming = true }
|
||||||
|
))
|
||||||
|
{
|
||||||
|
// Write each chunk to the HTTP response as SSE
|
||||||
|
var data = chunk.LastMessageContent;
|
||||||
|
accumulatedContent.Append(data);
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.Append("data: ");
|
||||||
|
sb.AppendLine(accumulatedContent.ToString().Replace("\n", "\ndata: "));
|
||||||
|
sb.AppendLine(); // the blank line terminates the chunk
|
||||||
|
var bytes = Encoding.UTF8.GetBytes(sb.ToString());
|
||||||
|
await Response.Body.WriteAsync(bytes);
|
||||||
|
await Response.Body.FlushAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optionally: after finishing streaming, you can save the assistant message to history.
|
||||||
|
}
|
||||||
|
}
|
||||||
37
DysonNetwork.Insight/Thinking/ThinkingProvider.cs
Normal file
37
DysonNetwork.Insight/Thinking/ThinkingProvider.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using LangChain.Providers;
|
||||||
|
using LangChain.Providers.Ollama;
|
||||||
|
|
||||||
|
namespace DysonNetwork.Insight.Thinking;
|
||||||
|
|
||||||
|
public class ThinkingProvider
|
||||||
|
{
|
||||||
|
public readonly Provider Provider;
|
||||||
|
public readonly string? ModelProviderType;
|
||||||
|
public readonly string? ModelDefault;
|
||||||
|
|
||||||
|
public ThinkingProvider(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
var cfg = configuration.GetSection("Thinking");
|
||||||
|
ModelProviderType = cfg.GetValue<string>("Provider")?.ToLower();
|
||||||
|
switch (ModelProviderType)
|
||||||
|
{
|
||||||
|
case "ollama":
|
||||||
|
var endpoint = cfg.GetValue<string>("Endpoint");
|
||||||
|
Provider = new OllamaProvider(endpoint ?? "http://localhost:11434/api");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IndexOutOfRangeException("Unknown thinking provider: " + ModelProviderType);
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelDefault = cfg.GetValue<string>("Model");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatModel GetModel(string? name = null)
|
||||||
|
{
|
||||||
|
return ModelProviderType switch
|
||||||
|
{
|
||||||
|
"ollama" => new OllamaChatModel((Provider as OllamaProvider)!, (name ?? ModelDefault)!),
|
||||||
|
_ => throw new IndexOutOfRangeException("Unknown thinking provider: " + ModelProviderType),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +1,27 @@
|
|||||||
{
|
{
|
||||||
"Debug": true,
|
"Debug": true,
|
||||||
"BaseUrl": "http://localhost:5071",
|
"BaseUrl": "http://localhost:5071",
|
||||||
"SiteUrl": "https://solian.app",
|
"SiteUrl": "https://solian.app",
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"App": "Host=localhost;Port=5432;Database=dyson_insight;Username=postgres;Password=postgres;Include Error Detail=True;Maximum Pool Size=20;Connection Idle Lifetime=60"
|
||||||
|
},
|
||||||
|
"KnownProxies": [
|
||||||
|
"127.0.0.1",
|
||||||
|
"::1"
|
||||||
|
],
|
||||||
|
"Etcd": {
|
||||||
|
"Insecure": true
|
||||||
|
},
|
||||||
|
"Thinking": {
|
||||||
|
"Provider": "ollama",
|
||||||
|
"Model": "qwen3:8b",
|
||||||
|
"Endpoint": "http://localhost:11434/api"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"AllowedHosts": "*",
|
|
||||||
"ConnectionStrings": {
|
|
||||||
"App": "Host=localhost;Port=5432;Database=dyson_insight;Username=postgres;Password=postgres;Include Error Detail=True;Maximum Pool Size=20;Connection Idle Lifetime=60"
|
|
||||||
},
|
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
|
||||||
"Swagger": {
|
|
||||||
"PublicBasePath": "/insight"
|
|
||||||
},
|
|
||||||
"Etcd": {
|
|
||||||
"Insecure": true
|
|
||||||
},
|
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Insight",
|
|
||||||
"Url": "https://localhost:7192"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -32,11 +32,6 @@
|
|||||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0"/>
|
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0"/>
|
||||||
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0"/>
|
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0"/>
|
||||||
<PackageReference Include="Otp.NET" Version="1.4.0"/>
|
<PackageReference Include="Otp.NET" Version="1.4.0"/>
|
||||||
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1"/>
|
|
||||||
<PackageReference Include="prometheus-net.AspNetCore.HealthChecks" Version="8.2.1"/>
|
|
||||||
<PackageReference Include="prometheus-net.DotNetRuntime" Version="4.4.1"/>
|
|
||||||
<PackageReference Include="prometheus-net.EntityFramework" Version="0.9.5"/>
|
|
||||||
<PackageReference Include="prometheus-net.SystemMetrics" Version="3.1.0"/>
|
|
||||||
<PackageReference Include="Quartz" Version="3.14.0"/>
|
<PackageReference Include="Quartz" Version="3.14.0"/>
|
||||||
<PackageReference Include="Quartz.AspNetCore" Version="3.14.0"/>
|
<PackageReference Include="Quartz.AspNetCore" Version="3.14.0"/>
|
||||||
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.14.0"/>
|
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.14.0"/>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using DysonNetwork.Pass.Permission;
|
|||||||
using DysonNetwork.Pass.Realm;
|
using DysonNetwork.Pass.Realm;
|
||||||
using DysonNetwork.Pass.Wallet;
|
using DysonNetwork.Pass.Wallet;
|
||||||
using DysonNetwork.Shared.Http;
|
using DysonNetwork.Shared.Http;
|
||||||
using Prometheus;
|
|
||||||
|
|
||||||
namespace DysonNetwork.Pass.Startup;
|
namespace DysonNetwork.Pass.Startup;
|
||||||
|
|
||||||
@@ -14,7 +13,6 @@ public static class ApplicationConfiguration
|
|||||||
{
|
{
|
||||||
public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration)
|
public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
app.MapMetrics();
|
|
||||||
app.MapOpenApi();
|
app.MapOpenApi();
|
||||||
|
|
||||||
app.UseRequestLocalization();
|
app.UseRequestLocalization();
|
||||||
|
|||||||
@@ -71,12 +71,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
"KnownProxies": ["127.0.0.1", "::1"]
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Pass",
|
|
||||||
"Url": "https://localhost:7058"
|
|
||||||
},
|
|
||||||
"Etcd": {
|
|
||||||
"Insecure": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,11 +47,6 @@
|
|||||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.13.0" />
|
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.13.0" />
|
||||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0"/>
|
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0"/>
|
||||||
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0"/>
|
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0"/>
|
||||||
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1"/>
|
|
||||||
<PackageReference Include="prometheus-net.AspNetCore.HealthChecks" Version="8.2.1"/>
|
|
||||||
<PackageReference Include="prometheus-net.DotNetRuntime" Version="4.4.1"/>
|
|
||||||
<PackageReference Include="prometheus-net.EntityFramework" Version="0.9.5"/>
|
|
||||||
<PackageReference Include="prometheus-net.SystemMetrics" Version="3.1.0"/>
|
|
||||||
<PackageReference Include="Quartz" Version="3.14.0"/>
|
<PackageReference Include="Quartz" Version="3.14.0"/>
|
||||||
<PackageReference Include="Quartz.AspNetCore" Version="3.14.0"/>
|
<PackageReference Include="Quartz.AspNetCore" Version="3.14.0"/>
|
||||||
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.14.0"/>
|
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.14.0"/>
|
||||||
|
|||||||
@@ -12,12 +12,5 @@
|
|||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"App": "Host=host.docker.internal;Port=5432;Database=dyson_network_dev;Username=postgres;Password=postgres;Include Error Detail=True;Maximum Pool Size=20;Connection Idle Lifetime=60"
|
"App": "Host=host.docker.internal;Port=5432;Database=dyson_network_dev;Username=postgres;Password=postgres;Include Error Detail=True;Maximum Pool Size=20;Connection Idle Lifetime=60"
|
||||||
},
|
},
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
"KnownProxies": ["127.0.0.1", "::1"]
|
||||||
"Etcd": {
|
|
||||||
"Insecure": true
|
|
||||||
},
|
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Develop",
|
|
||||||
"Url": "https://localhost:7192"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,9 +119,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
"KnownProxies": ["127.0.0.1", "::1"]
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Drive",
|
|
||||||
"Url": "https://localhost:7092"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,12 +71,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
"KnownProxies": ["127.0.0.1", "::1"]
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Pass",
|
|
||||||
"Url": "https://localhost:7058"
|
|
||||||
},
|
|
||||||
"Etcd": {
|
|
||||||
"Insecure": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,12 +36,5 @@
|
|||||||
"GeoIp": {
|
"GeoIp": {
|
||||||
"DatabasePath": "./Keys/GeoLite2-City.mmdb"
|
"DatabasePath": "./Keys/GeoLite2-City.mmdb"
|
||||||
},
|
},
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
"KnownProxies": ["127.0.0.1", "::1"]
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Ring",
|
|
||||||
"Url": "https://localhost:7259"
|
|
||||||
},
|
|
||||||
"Etcd": {
|
|
||||||
"Insecure": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,5 @@
|
|||||||
"SecretId": "",
|
"SecretId": "",
|
||||||
"SecretKey": ""
|
"SecretKey": ""
|
||||||
},
|
},
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
"KnownProxies": ["127.0.0.1", "::1"]
|
||||||
"Etcd": {
|
|
||||||
"Insecure": true
|
|
||||||
},
|
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Sphere",
|
|
||||||
"Url": "https://localhost:7099"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,5 @@
|
|||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"App": "Host=host.docker.internal;Port=5432;Database=dyson_develop;Username=postgres;Password=postgres;Include Error Detail=True;Maximum Pool Size=20;Connection Idle Lifetime=60"
|
"App": "Host=host.docker.internal;Port=5432;Database=dyson_develop;Username=postgres;Password=postgres;Include Error Detail=True;Maximum Pool Size=20;Connection Idle Lifetime=60"
|
||||||
},
|
},
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
"KnownProxies": ["127.0.0.1", "::1"]
|
||||||
"Etcd": {
|
|
||||||
"Insecure": true
|
|
||||||
},
|
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Develop",
|
|
||||||
"Url": "https://localhost:7192"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,9 +119,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
"KnownProxies": ["127.0.0.1", "::1"]
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Drive",
|
|
||||||
"Url": "https://localhost:7092"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,12 +71,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
"KnownProxies": ["127.0.0.1", "::1"]
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Pass",
|
|
||||||
"Url": "https://localhost:7058"
|
|
||||||
},
|
|
||||||
"Etcd": {
|
|
||||||
"Insecure": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,12 +36,5 @@
|
|||||||
"GeoIp": {
|
"GeoIp": {
|
||||||
"DatabasePath": "/app/keys/GeoLite2-City.mmdb"
|
"DatabasePath": "/app/keys/GeoLite2-City.mmdb"
|
||||||
},
|
},
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
"KnownProxies": ["127.0.0.1", "::1"]
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Ring",
|
|
||||||
"Url": "https://localhost:7259"
|
|
||||||
},
|
|
||||||
"Etcd": {
|
|
||||||
"Insecure": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,5 @@
|
|||||||
"SecretId": "",
|
"SecretId": "",
|
||||||
"SecretKey": ""
|
"SecretKey": ""
|
||||||
},
|
},
|
||||||
"KnownProxies": ["127.0.0.1", "::1"],
|
"KnownProxies": ["127.0.0.1", "::1"]
|
||||||
"Etcd": {
|
|
||||||
"Insecure": true
|
|
||||||
},
|
|
||||||
"Service": {
|
|
||||||
"Name": "DysonNetwork.Sphere",
|
|
||||||
"Url": "https://localhost:7099"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user