-
Notifications
You must be signed in to change notification settings - Fork 0
Installation instructions
HarpIA Model Gateway can run using a local Python installation or a Docker container.
-
Create a Python environment and activate it:
python3 -m venv .venv source ./.venv/bin/activate -
Install Poetry.
-
Install the dependencies:
poetry install --no-root
-
Create a configuration file. Create a copy of the config_TEMPLATE.py file and edit it to choose the models that will be provided. Follow the instructions in the file.
-
Test an answer provider by sending a single message on a terminal, as in this example (replace
./config/config1.pywith the path to your configuration file, and replaceECHOwith the name of an answer provider as defined in the configuration file):python run_gateway.py --config=./config/config1.py cli --provider="ECHO" -
Start the server (replace
42774with the desired port):python run_gateway.py --config=./config/config1.py server --host=0.0.0.0 --port=42774
Temporarily, only during the installation until everything is working,
--debugmay be added to the end of the command to enable debugging messages during the setup. -
While the server is running, send a test request (replace change the port and the name of the answer provider accordingly):
curl -X POST http://localhost:42774/send -H "Content-Type: application/json" -d '{"query": "this is a test", "answer_provider": "ECHO"}'It should print a JSON response. In the example above, one of the lines will be
"text": "THIS IS A TEST"(i.e. the query converted to uppercase by the answer provider ECHO).
-
Install Docker.
-
Build the Docker image:
docker build -t harpia-model-gateway:1.0 -f containers/prod/Dockerfile . -
Create a configuration file. Create a copy of the config_TEMPLATE.py file and edit it to choose the models that will be provided. Follow the instructions in the file.
IMPORTANT: If you use Ollama or any other model that requires accessing
localhostaddresses:- Define a virtual name for the host's localhost that will be accessible from the container (e.g.
ollamaserver); - Use that address in your configuration file (e.g.
"ollama_address": "http://ollamaserver:11434/api"); - In the remaining steps, add
--add-host=ollamaserver:host-gateway(replacingollamaserverwith the chosen name). The commands will look likedocker run --add-host=ollamaserver:host-gateway --rm [...]. - Make sure that the communication between the containers is not blocked by firewalls or system settings.
- Standalone Ollama blocks external connections by default, preventing the communication with HarpIA Model Gateway's container. Either configure Ollama server to allow external connections by setting
OLLAMA_HOSTto0.0.0.0, or run Ollama from its Docker image.
- Define a virtual name for the host's localhost that will be accessible from the container (e.g.
-
Test an answer provider by sending a single message on a terminal, as in this example (replace
./config/config1.pywith the path to your configuration file, and replaceECHOwith the name of an answer provider as defined in the configuration file):docker run --rm -it --name harpia-gateway -v './config/config1.py':/cfg.py harpia-model-gateway:1.0 --config=/cfg.py cli --provider="ECHO"
-
Start the server (replace
./config/config1.pywith the path to your configuration file, optionally replace all instances of42774with the desired port):docker run --rm -d --name harpia-gateway -v './config/config1.py':/cfg.py -p 42774:42774 harpia-model-gateway:1.0 --config=/cfg.py server --host=0.0.0.0 --port=42774Temporarily, only during the installation until everything is working,
--debugmay be added to the end of the command to enable debugging messages during the setup, and-dcan be removed to keep the container in the foreground (which allows killing it with Ctrl+C).If the configuration file reads environment variables (such as API keys), they can be defined after
docker run:docker run -e FIRSTVAR=firstvalue -e SECONDVAR=secondvalue --rm [...]
-
While the server is running, send a test request (replace change the port and the name of the answer provider accordingly):
curl -X POST http://localhost:42774/send -H "Content-Type: application/json" -d '{"query": "this is a test", "answer_provider": "ECHO"}'It should print a JSON response. In the example above, one of the lines will be
"text": "THIS IS A TEST"(i.e. the query converted to uppercase by the answer provider ECHO).