diff --git a/docs/Indexer.md b/docs/Indexer.md index ad3b06d..7349392 100644 --- a/docs/Indexer.md +++ b/docs/Indexer.md @@ -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. ## Setup 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. 3. If your search server requires API keys, (i.e. it's operating outside of the "Development" environment) set `"ApiKey": ""` beneath `"BaseUri"` in the `"Embeddingsearch"` section. 4. Create your own indexing script(s) in `src/Indexer/Scripts/` and configure their use as diff --git a/docs/Server.md b/docs/Server.md index f9c0e2e..252602e 100644 --- a/docs/Server.md +++ b/docs/Server.md @@ -27,12 +27,12 @@ Download the [.NET SDK](https://dotnet.microsoft.com/en-us/download) or follow t # Configuration ## 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. ## Setup 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=;`) 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: diff --git a/embeddingsearch.sln b/embeddingsearch.sln index a0fb9fd..40d07f4 100644 --- a/embeddingsearch.sln +++ b/embeddingsearch.sln @@ -5,9 +5,7 @@ VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6AA0A9E0-A361-4E86-BA02-D5F6779C6DEF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "embeddingsearch", "src\embeddingsearch\embeddingsearch.csproj", "{67AA89C0-3630-4994-B4EE-FC86CFF407DB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server", "src\Server\Server.csproj", "{643CB1D1-02F6-4BCC-A1CC-6E403D78C442}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "src\Server\Server.csproj", "{643CB1D1-02F6-4BCC-A1CC-6E403D78C442}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cli", "cli", "{BC4F3063-B921-4C4A-A7CE-11FAF5B73D50}" EndProject @@ -25,10 +23,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection 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.Build.0 = Debug|Any CPU {643CB1D1-02F6-4BCC-A1CC-6E403D78C442}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -54,7 +48,6 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {67AA89C0-3630-4994-B4EE-FC86CFF407DB} = {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} {D61A2C50-B46C-42BA-B75D-E84D8FA28C29} = {BC4F3063-B921-4C4A-A7CE-11FAF5B73D50} diff --git a/src/Client/Client.cs b/src/Client/Client.cs index 2f1b624..de12483 100644 --- a/src/Client/Client.cs +++ b/src/Client/Client.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using System.Web; using System.Text.Json; using Models; -using embeddingsearch; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Configuration; using System.Reflection.Metadata.Ecma335; @@ -87,12 +86,12 @@ public class Client return await GetUrlAndProcessJson(url); } - public async Task EntityIndexAsync(List jsonEntity) + public async Task EntityIndexAsync(List jsonEntity) { return await EntityIndexAsync(searchdomain, jsonEntity); } - public async Task EntityIndexAsync(string searchdomain, List jsonEntity) + public async Task EntityIndexAsync(string searchdomain, List jsonEntity) { return await EntityIndexAsync(searchdomain, JsonSerializer.Serialize(jsonEntity)); } diff --git a/src/Client/Client.csproj b/src/Client/Client.csproj index e8ed42c..15f7891 100644 --- a/src/Client/Client.csproj +++ b/src/Client/Client.csproj @@ -1,7 +1,7 @@  - - + + diff --git a/src/Indexer/Indexer.csproj b/src/Indexer/Indexer.csproj index 07dfbdc..c07b499 100644 --- a/src/Indexer/Indexer.csproj +++ b/src/Indexer/Indexer.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Indexer/Models/Script.cs b/src/Indexer/Models/Script.cs index dc93198..45806c8 100644 --- a/src/Indexer/Models/Script.cs +++ b/src/Indexer/Models/Script.cs @@ -1,6 +1,5 @@ using System.Text.Json; using System.Timers; -using embeddingsearch; using Python.Runtime; namespace Indexer.Models; diff --git a/src/Indexer/Program.cs b/src/Indexer/Program.cs index cddc340..a924076 100644 --- a/src/Indexer/Program.cs +++ b/src/Indexer/Program.cs @@ -1,6 +1,6 @@ using Indexer.Models; using Indexer.Services; -using server; +using Server; var builder = WebApplication.CreateBuilder(args); diff --git a/src/Indexer/Services/IndexerService.cs b/src/Indexer/Services/IndexerService.cs index b5ece9e..2fd5324 100644 --- a/src/Indexer/Services/IndexerService.cs +++ b/src/Indexer/Services/IndexerService.cs @@ -6,7 +6,6 @@ using Indexer.Exceptions; using Indexer.Models; using System.Timers; using Microsoft.AspNetCore.Http.HttpResults; -using embeddingsearch; using Python.Runtime; namespace Indexer.Services; diff --git a/src/Models/EntityModels.cs b/src/Models/EntityResults.cs similarity index 100% rename from src/Models/EntityModels.cs rename to src/Models/EntityResults.cs diff --git a/src/Models/SearchdomainModels.cs b/src/Models/SearchdomainResults.cs similarity index 100% rename from src/Models/SearchdomainModels.cs rename to src/Models/SearchdomainResults.cs diff --git a/src/Server/ApiKeyMiddleware.cs b/src/Server/ApiKeyMiddleware.cs index 81ef5a2..1379cde 100644 --- a/src/Server/ApiKeyMiddleware.cs +++ b/src/Server/ApiKeyMiddleware.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.Primitives; -namespace server; +namespace Server; public class ApiKeyMiddleware { @@ -23,14 +23,14 @@ public class ApiKeyMiddleware } var validApiKeys = _configuration.GetSection("Embeddingsearch").GetSection("ApiKeys").Get>(); - #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. { context.Response.StatusCode = 403; await context.Response.WriteAsync("Invalid API Key."); return; } - #pragma warning restore CS8604 +#pragma warning restore CS8604 await _next(context); } diff --git a/src/Server/Controllers/EntityController.cs b/src/Server/Controllers/EntityController.cs index 7e42b7e..153e5b3 100644 --- a/src/Server/Controllers/EntityController.cs +++ b/src/Server/Controllers/EntityController.cs @@ -1,9 +1,8 @@ using Microsoft.AspNetCore.Mvc; -using embeddingsearch; using System.Text.Json; using Models; using System.Text.Json.Nodes; -namespace server.Controllers; +namespace Server.Controllers; [ApiController] [Route("[controller]")] diff --git a/src/Server/Controllers/SearchdomainController.cs b/src/Server/Controllers/SearchdomainController.cs index 2b090bc..0286935 100644 --- a/src/Server/Controllers/SearchdomainController.cs +++ b/src/Server/Controllers/SearchdomainController.cs @@ -1,8 +1,7 @@ using Microsoft.AspNetCore.Mvc; -using embeddingsearch; using Models; -namespace server.Controllers; +namespace Server.Controllers; [ApiController] [Route("[controller]")] diff --git a/src/embeddingsearch/Datapoint.cs b/src/Server/Datapoint.cs similarity index 99% rename from src/embeddingsearch/Datapoint.cs rename to src/Server/Datapoint.cs index 5f8eff0..9ad103e 100644 --- a/src/embeddingsearch/Datapoint.cs +++ b/src/Server/Datapoint.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.AI; using OllamaSharp; using OllamaSharp.Models; -namespace embeddingsearch; +namespace Server; public class Datapoint { diff --git a/src/embeddingsearch/Entity.cs b/src/Server/Entity.cs similarity index 92% rename from src/embeddingsearch/Entity.cs rename to src/Server/Entity.cs index 7a3ff3a..4fb16fd 100644 --- a/src/embeddingsearch/Entity.cs +++ b/src/Server/Entity.cs @@ -1,6 +1,7 @@ using System; +using Server; -namespace embeddingsearch; +namespace Server; public class Entity(Dictionary attributes, Probmethods.probMethodDelegate probMethod, List datapoints, string name) { diff --git a/src/Server/Exceptions/ServerExceptions.cs b/src/Server/Exceptions/ServerExceptions.cs index b0688c0..4d11046 100644 --- a/src/Server/Exceptions/ServerExceptions.cs +++ b/src/Server/Exceptions/ServerExceptions.cs @@ -1,4 +1,4 @@ -namespace server.Exceptions; +namespace Server.Exceptions; public class ServerConfigurationException : Exception { diff --git a/src/embeddingsearch/JSONModels.cs b/src/Server/JSONModels.cs similarity index 95% rename from src/embeddingsearch/JSONModels.cs rename to src/Server/JSONModels.cs index ee96461..c47827a 100644 --- a/src/embeddingsearch/JSONModels.cs +++ b/src/Server/JSONModels.cs @@ -1,4 +1,4 @@ -namespace embeddingsearch; +namespace Server; public class JSONEntity { diff --git a/src/embeddingsearch/Probmethods.cs b/src/Server/Probmethods.cs similarity index 98% rename from src/embeddingsearch/Probmethods.cs rename to src/Server/Probmethods.cs index 793b2b2..ae59d92 100644 --- a/src/embeddingsearch/Probmethods.cs +++ b/src/Server/Probmethods.cs @@ -2,7 +2,7 @@ using System.Numerics.Tensors; -namespace embeddingsearch; +namespace Server; public class Probmethods diff --git a/src/Server/Program.cs b/src/Server/Program.cs index e56fd12..fd5c79e 100644 --- a/src/Server/Program.cs +++ b/src/Server/Program.cs @@ -1,4 +1,4 @@ -using server; +using Server; var builder = WebApplication.CreateBuilder(args); diff --git a/src/embeddingsearch/Searchdomain.cs b/src/Server/Searchdomain.cs similarity index 99% rename from src/embeddingsearch/Searchdomain.cs rename to src/Server/Searchdomain.cs index 86967c4..3cd49f5 100644 --- a/src/embeddingsearch/Searchdomain.cs +++ b/src/Server/Searchdomain.cs @@ -17,8 +17,9 @@ using Mysqlx.Resultset; using System.Collections.Immutable; using System.Text.Json; using System.Numerics.Tensors; +using Server; -namespace embeddingsearch; +namespace Server; public class Searchdomain { diff --git a/src/Server/SearchdomainManager.cs b/src/Server/SearchdomainManager.cs index 1d7ea37..30fb0c3 100644 --- a/src/Server/SearchdomainManager.cs +++ b/src/Server/SearchdomainManager.cs @@ -1,11 +1,10 @@ -using embeddingsearch; using MySql.Data.MySqlClient; using System.Data.Common; using OllamaSharp; using Microsoft.IdentityModel.Tokens; -using server.Exceptions; +using Server.Exceptions; -namespace server; +namespace Server; public class SearchdomainManager { diff --git a/src/Server/Server.csproj b/src/Server/Server.csproj index 948f4cb..ffd8e38 100644 --- a/src/Server/Server.csproj +++ b/src/Server/Server.csproj @@ -8,11 +8,20 @@ + + + + + + + + + - - - + + + diff --git a/src/cli/Program.cs b/src/cli/Program.cs index 4abf221..3b7124a 100644 --- a/src/cli/Program.cs +++ b/src/cli/Program.cs @@ -1,5 +1,4 @@ using System.Drawing.Printing; -using embeddingsearch; using Microsoft.Extensions.AI; using OllamaSharp; using OllamaSharp.Models; @@ -11,6 +10,7 @@ using Org.BouncyCastle.Asn1.X509.Qualified; using Microsoft.Identity.Client; using System.Text.Json.Serialization; using System.Text.Json; +using Server; // ParserSettings parserSettings = new() // { diff --git a/src/cli/cli.csproj b/src/cli/cli.csproj index c5cf93d..96ee69e 100644 --- a/src/cli/cli.csproj +++ b/src/cli/cli.csproj @@ -14,6 +14,7 @@ + diff --git a/src/embeddingsearch/embeddingsearch.csproj b/src/embeddingsearch/embeddingsearch.csproj deleted file mode 100644 index 5e8c534..0000000 --- a/src/embeddingsearch/embeddingsearch.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - - - - -