3.2 KiB
Overview
The server by default
- runs on port 5146
- Uses Swagger UI in development mode (
/swagger/index.html) - Ignores API keys when not in development mode
Installing the dependencies
Ubuntu 24.04
- Install the .NET SDK:
sudo apt update && sudo apt install dotnet-sdk-8.0 -y
Windows
Download the .NET SDK or follow these steps to use WSL:
- Install Ubuntu in WSL (
wsl --installandwsl --install -d Ubuntu) - Enter your WSL environment
wsl.exeand configure it - Update via
sudo apt update && sudo apt upgrade -y && sudo snap refresh - Continue here: Ubuntu 24.04
MySQL database setup
- Install the MySQL server:
- Linux/WSL:
sudo apt install mysql-server - Windows: MySQL Community Server
- connect to it:
sudo mysql -u root(Or from outside of WSL:mysql -u root) - Create the database:
CREATE DATABASE embeddingsearch; use embeddingsearch; - Create the user (replace "somepassword! with a secure password):
CREATE USER 'embeddingsearch'@'%' identified by "somepassword!"; GRANT ALL ON embeddingsearch.* TO embeddingsearch; FLUSH PRIVILEGES; - Create the tables using the CLI tool:
cd src/cli; dotnet buildandbin/Debug/net8.0/cli -h $mysql_ip -p $mysql_port -U $mysql_username -P $mysql_password --database --setup(replace the variables with the actual values)
Configuration
Environments
The configuration is located in src/server/ and conforms to the ASP.NET configuration design pattern, 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:
- Open
src/server/appsettings.Development.json - Change the password in the "SQL" section (
pwd=<your password goes here>;) - If your Ollama instance does not run locally, update "OllamaURL" to point at your Ollama instance.
- If you plan on using the server in production:
- Set the environment variable
DOTNET_ENVIRONMENTto something that is not "Development". (e.g. "Prod") - Rename the
appsettings.Development.json- replace "Development" with whatever you chose. (e.g. "Prod") - Set API keys in the "ApiKeys" section (generate keys using the
uuidcommand on Linux)
- Set the environment variable
API
Accessing the api
Once started, the server's API can be comfortably be viewed and manipulated via swagger.
By default it is accessible under: http://localhost:5146/swagger/index.html
To make an API request from within swagger:
- Open one of the actions ("GET" / "POST")
- Click the "Try it out" button. The input fields (if there are any for your action) should now be editable.
- Fill in the necessary information
- Click "Execute"
Restricting access
API keys do not get checked in Development environment!
Set up a non-development environment as described in Configuration>Setup to enable API key authentication.