This example demonstrates how to use langchain and langchain-openai in Python to connect to the adl-server.
It sends a simple "Hello" message to the ADL Server's OpenAI-compatible chat completions endpoint.
- Docker and Docker Compose installed.
- Python 3.8 or higher.
pippackage manager.
First, start the ADL Server using Docker Compose in the parent directory:
docker-compose up -dThis will start the ADL Server on port 8080.
- Ideally, create a virtual environment:
python3 -m venv .venv
source .venv/bin/activate # On Windows, use .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtExecute the main script:
python main.pyThe script will:
- Load environment variables.
- Initialize a
ChatOpenAIclient pointing tohttp://localhost:8080/v1(the ADL Server address). - Send a "Hello" message.
- Print the response from the server.
You should see output similar to:
Connecting to ADL Server at http://localhost:8080/v1...
Sending message: 'Hello'
--------------------
Response from ADL Server:
Hello there! How can I help you today?
--------------------