Merged redundant project onto server

This commit is contained in:
EzFeDezy
2025-06-05 21:45:34 +02:00
parent 7899130c30
commit a6786219ce
26 changed files with 40 additions and 62 deletions

View File

@@ -16,7 +16,7 @@ The configuration is located in `src/Indexer` and conforms to the [ASP.NET confi
If you plan to use multiple environments, create any `appsettings.{YourEnvironment}.json` (e.g. `Development`, `Staging`, `Prod`) and set the environment variable `DOTNET_ENVIRONMENT` accordingly on the target machine. If you plan to use multiple environments, create any `appsettings.{YourEnvironment}.json` (e.g. `Development`, `Staging`, `Prod`) and set the environment variable `DOTNET_ENVIRONMENT` accordingly on the target machine.
## Setup ## Setup
If you just installed the server and want to configure it: If you just installed the server and want to configure it:
1. Open `src/server/appsettings.Development.json` 1. Open `src/Server/appsettings.Development.json`
2. If your search server is not on the same machine as the indexer, update "BaseUri" to reflect the URL to the server. 2. If your search server is not on the same machine as the indexer, update "BaseUri" to reflect the URL to the server.
3. If your search server requires API keys, (i.e. it's operating outside of the "Development" environment) set `"ApiKey": "<your key here>"` beneath `"BaseUri"` in the `"Embeddingsearch"` section. 3. If your search server requires API keys, (i.e. it's operating outside of the "Development" environment) set `"ApiKey": "<your key here>"` beneath `"BaseUri"` in the `"Embeddingsearch"` section.
4. Create your own indexing script(s) in `src/Indexer/Scripts/` and configure their use as 4. Create your own indexing script(s) in `src/Indexer/Scripts/` and configure their use as

View File

@@ -27,12 +27,12 @@ Download the [.NET SDK](https://dotnet.microsoft.com/en-us/download) or follow t
# Configuration # Configuration
## Environments ## Environments
The configuration is located in `src/server/` and conforms to the [ASP.NET configuration design pattern](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-9.0), i.e. `src/server/appsettings.json` is the base configuration, and `/src/server/appsettings.Development.json` overrides it. The configuration is located in `src/Server/` and conforms to the [ASP.NET configuration design pattern](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-9.0), i.e. `src/Server/appsettings.json` is the base configuration, and `/src/Server/appsettings.Development.json` overrides it.
If you plan to use multiple environments, create any `appsettings.{YourEnvironment}.json` (e.g. `Development`, `Staging`, `Prod`) and set the environment variable `DOTNET_ENVIRONMENT` accordingly on the target machine. If you plan to use multiple environments, create any `appsettings.{YourEnvironment}.json` (e.g. `Development`, `Staging`, `Prod`) and set the environment variable `DOTNET_ENVIRONMENT` accordingly on the target machine.
## Setup ## Setup
If you just installed the server and want to configure it: If you just installed the server and want to configure it:
1. Open `src/server/appsettings.Development.json` 1. Open `src/Server/appsettings.Development.json`
2. Change the password in the "SQL" section (`pwd=<your password goes here>;`) 2. Change the password in the "SQL" section (`pwd=<your password goes here>;`)
3. If your Ollama instance does not run locally, update "OllamaURL" to point at your Ollama instance. 3. If your Ollama instance does not run locally, update "OllamaURL" to point at your Ollama instance.
4. If you plan on using the server in production: 4. If you plan on using the server in production:

View File

@@ -5,9 +5,7 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6AA0A9E0-A361-4E86-BA02-D5F6779C6DEF}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6AA0A9E0-A361-4E86-BA02-D5F6779C6DEF}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "embeddingsearch", "src\embeddingsearch\embeddingsearch.csproj", "{67AA89C0-3630-4994-B4EE-FC86CFF407DB}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "src\Server\Server.csproj", "{643CB1D1-02F6-4BCC-A1CC-6E403D78C442}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server", "src\Server\Server.csproj", "{643CB1D1-02F6-4BCC-A1CC-6E403D78C442}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cli", "cli", "{BC4F3063-B921-4C4A-A7CE-11FAF5B73D50}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cli", "cli", "{BC4F3063-B921-4C4A-A7CE-11FAF5B73D50}"
EndProject EndProject
@@ -25,10 +23,6 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{67AA89C0-3630-4994-B4EE-FC86CFF407DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67AA89C0-3630-4994-B4EE-FC86CFF407DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67AA89C0-3630-4994-B4EE-FC86CFF407DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67AA89C0-3630-4994-B4EE-FC86CFF407DB}.Release|Any CPU.Build.0 = Release|Any CPU
{643CB1D1-02F6-4BCC-A1CC-6E403D78C442}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {643CB1D1-02F6-4BCC-A1CC-6E403D78C442}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{643CB1D1-02F6-4BCC-A1CC-6E403D78C442}.Debug|Any CPU.Build.0 = Debug|Any CPU {643CB1D1-02F6-4BCC-A1CC-6E403D78C442}.Debug|Any CPU.Build.0 = Debug|Any CPU
{643CB1D1-02F6-4BCC-A1CC-6E403D78C442}.Release|Any CPU.ActiveCfg = Release|Any CPU {643CB1D1-02F6-4BCC-A1CC-6E403D78C442}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -54,7 +48,6 @@ Global
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{67AA89C0-3630-4994-B4EE-FC86CFF407DB} = {6AA0A9E0-A361-4E86-BA02-D5F6779C6DEF}
{643CB1D1-02F6-4BCC-A1CC-6E403D78C442} = {6AA0A9E0-A361-4E86-BA02-D5F6779C6DEF} {643CB1D1-02F6-4BCC-A1CC-6E403D78C442} = {6AA0A9E0-A361-4E86-BA02-D5F6779C6DEF}
{BC4F3063-B921-4C4A-A7CE-11FAF5B73D50} = {6AA0A9E0-A361-4E86-BA02-D5F6779C6DEF} {BC4F3063-B921-4C4A-A7CE-11FAF5B73D50} = {6AA0A9E0-A361-4E86-BA02-D5F6779C6DEF}
{D61A2C50-B46C-42BA-B75D-E84D8FA28C29} = {BC4F3063-B921-4C4A-A7CE-11FAF5B73D50} {D61A2C50-B46C-42BA-B75D-E84D8FA28C29} = {BC4F3063-B921-4C4A-A7CE-11FAF5B73D50}

View File

@@ -5,7 +5,6 @@ using System.Threading.Tasks;
using System.Web; using System.Web;
using System.Text.Json; using System.Text.Json;
using Models; using Models;
using embeddingsearch;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using System.Reflection.Metadata.Ecma335; using System.Reflection.Metadata.Ecma335;
@@ -87,12 +86,12 @@ public class Client
return await GetUrlAndProcessJson<EntityQueryResults>(url); return await GetUrlAndProcessJson<EntityQueryResults>(url);
} }
public async Task<EntityIndexResult> EntityIndexAsync(List<JSONEntity> jsonEntity) public async Task<EntityIndexResult> EntityIndexAsync(List<Server.JSONEntity> jsonEntity)
{ {
return await EntityIndexAsync(searchdomain, jsonEntity); return await EntityIndexAsync(searchdomain, jsonEntity);
} }
public async Task<EntityIndexResult> EntityIndexAsync(string searchdomain, List<JSONEntity> jsonEntity) public async Task<EntityIndexResult> EntityIndexAsync(string searchdomain, List<Server.JSONEntity> jsonEntity)
{ {
return await EntityIndexAsync(searchdomain, JsonSerializer.Serialize(jsonEntity)); return await EntityIndexAsync(searchdomain, JsonSerializer.Serialize(jsonEntity));
} }

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\server\server.csproj" /> <ProjectReference Include="..\Server\Server.csproj" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>

View File

@@ -13,7 +13,7 @@
<PackageReference Include="Pythonnet" Version="3.0.5" /> <PackageReference Include="Pythonnet" Version="3.0.5" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\server\server.csproj" /> <ProjectReference Include="..\Server\Server.csproj" />
<ProjectReference Include="..\Client\Client.csproj" /> <ProjectReference Include="..\Client\Client.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,6 +1,5 @@
using System.Text.Json; using System.Text.Json;
using System.Timers; using System.Timers;
using embeddingsearch;
using Python.Runtime; using Python.Runtime;
namespace Indexer.Models; namespace Indexer.Models;

View File

@@ -1,6 +1,6 @@
using Indexer.Models; using Indexer.Models;
using Indexer.Services; using Indexer.Services;
using server; using Server;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);

View File

@@ -6,7 +6,6 @@ using Indexer.Exceptions;
using Indexer.Models; using Indexer.Models;
using System.Timers; using System.Timers;
using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Http.HttpResults;
using embeddingsearch;
using Python.Runtime; using Python.Runtime;
namespace Indexer.Services; namespace Indexer.Services;

View File

@@ -1,6 +1,6 @@
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
namespace server; namespace Server;
public class ApiKeyMiddleware public class ApiKeyMiddleware
{ {
@@ -23,14 +23,14 @@ public class ApiKeyMiddleware
} }
var validApiKeys = _configuration.GetSection("Embeddingsearch").GetSection("ApiKeys").Get<List<string>>(); var validApiKeys = _configuration.GetSection("Embeddingsearch").GetSection("ApiKeys").Get<List<string>>();
#pragma warning disable CS8604 #pragma warning disable CS8604
if (validApiKeys == null || !validApiKeys.Contains(extractedApiKey)) // CS8604 extractedApiKey is not null here, but the compiler still thinks that it might be. if (validApiKeys == null || !validApiKeys.Contains(extractedApiKey)) // CS8604 extractedApiKey is not null here, but the compiler still thinks that it might be.
{ {
context.Response.StatusCode = 403; context.Response.StatusCode = 403;
await context.Response.WriteAsync("Invalid API Key."); await context.Response.WriteAsync("Invalid API Key.");
return; return;
} }
#pragma warning restore CS8604 #pragma warning restore CS8604
await _next(context); await _next(context);
} }

View File

@@ -1,9 +1,8 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using embeddingsearch;
using System.Text.Json; using System.Text.Json;
using Models; using Models;
using System.Text.Json.Nodes; using System.Text.Json.Nodes;
namespace server.Controllers; namespace Server.Controllers;
[ApiController] [ApiController]
[Route("[controller]")] [Route("[controller]")]

View File

@@ -1,8 +1,7 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using embeddingsearch;
using Models; using Models;
namespace server.Controllers; namespace Server.Controllers;
[ApiController] [ApiController]
[Route("[controller]")] [Route("[controller]")]

View File

@@ -7,7 +7,7 @@ using Microsoft.Extensions.AI;
using OllamaSharp; using OllamaSharp;
using OllamaSharp.Models; using OllamaSharp.Models;
namespace embeddingsearch; namespace Server;
public class Datapoint public class Datapoint
{ {

View File

@@ -1,6 +1,7 @@
using System; using System;
using Server;
namespace embeddingsearch; namespace Server;
public class Entity(Dictionary<string, string> attributes, Probmethods.probMethodDelegate probMethod, List<Datapoint> datapoints, string name) public class Entity(Dictionary<string, string> attributes, Probmethods.probMethodDelegate probMethod, List<Datapoint> datapoints, string name)
{ {

View File

@@ -1,4 +1,4 @@
namespace server.Exceptions; namespace Server.Exceptions;
public class ServerConfigurationException : Exception public class ServerConfigurationException : Exception
{ {

View File

@@ -1,4 +1,4 @@
namespace embeddingsearch; namespace Server;
public class JSONEntity public class JSONEntity
{ {

View File

@@ -2,7 +2,7 @@
using System.Numerics.Tensors; using System.Numerics.Tensors;
namespace embeddingsearch; namespace Server;
public class Probmethods public class Probmethods

View File

@@ -1,4 +1,4 @@
using server; using Server;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);

View File

@@ -17,8 +17,9 @@ using Mysqlx.Resultset;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Text.Json; using System.Text.Json;
using System.Numerics.Tensors; using System.Numerics.Tensors;
using Server;
namespace embeddingsearch; namespace Server;
public class Searchdomain public class Searchdomain
{ {

View File

@@ -1,11 +1,10 @@
using embeddingsearch;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using System.Data.Common; using System.Data.Common;
using OllamaSharp; using OllamaSharp;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using server.Exceptions; using Server.Exceptions;
namespace server; namespace Server;
public class SearchdomainManager public class SearchdomainManager
{ {

View File

@@ -8,11 +8,20 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.1" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.3" />
<PackageReference Include="MySql.Data" Version="9.2.0" />
<PackageReference Include="Npgsql" Version="9.0.3" />
<PackageReference Include="OllamaSharp" Version="5.1.9" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.3" />
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
<PackageReference Include="System.Data.Sqlite" Version="1.0.119" />
<PackageReference Include="System.Numerics.Tensors" Version="9.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\embeddingsearch\embeddingsearch.csproj" /> <ProjectReference Include="..\embeddingsearch\embeddingsearch.csproj" />
<ProjectReference Include="..\Models\Models.csproj" /> <ProjectReference Include="..\Models\Models.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,5 +1,4 @@
using System.Drawing.Printing; using System.Drawing.Printing;
using embeddingsearch;
using Microsoft.Extensions.AI; using Microsoft.Extensions.AI;
using OllamaSharp; using OllamaSharp;
using OllamaSharp.Models; using OllamaSharp.Models;
@@ -11,6 +10,7 @@ using Org.BouncyCastle.Asn1.X509.Qualified;
using Microsoft.Identity.Client; using Microsoft.Identity.Client;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Text.Json; using System.Text.Json;
using Server;
// ParserSettings parserSettings = new() // ParserSettings parserSettings = new()
// { // {

View File

@@ -14,6 +14,7 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="../Server/Server.csproj" />
<ProjectReference Include="..\embeddingsearch\embeddingsearch.csproj" /> <ProjectReference Include="..\embeddingsearch\embeddingsearch.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,21 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.1" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.3" />
<PackageReference Include="MySql.Data" Version="9.2.0" />
<PackageReference Include="Npgsql" Version="9.0.3" />
<PackageReference Include="OllamaSharp" Version="5.1.9" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.3" />
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
<PackageReference Include="System.Data.Sqlite" Version="1.0.119" />
<PackageReference Include="System.Numerics.Tensors" Version="9.0.3" />
</ItemGroup>
</Project>