|
1 | 1 | # XMPP LLM Bridge |
2 | 2 |
|
| 3 | +[](https://github.com/mykolabilyi/xmpp-llm-bridge/releases) [](https://xcfile.dev) |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +XMPP LLM Bridge is a Go service that connects XMPP chat networks with OpenAI's Large Language Models, enabling AI-powered conversations through XMPP clients. The service acts as an intelligent bot that can participate in XMPP conversations by processing incoming messages through OpenAI's API and responding with contextually relevant replies. |
| 8 | + |
| 9 | +### Key Features |
| 10 | + |
| 11 | +- **XMPP Integration**: Full XMPP client implementation using mellium.im/xmpp library with SASL authentication |
| 12 | +- **OpenAI LLM Integration**: Seamlessly forwards chat messages to OpenAI's API and returns responses |
| 13 | +- **Configurable**: YAML-based configuration with environment variable overrides |
| 14 | +- **Docker Ready**: Containerized deployment with multi-stage builds |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +The XMPP LLM Bridge can be deployed in several ways. All methods require three essential environment variables: |
| 19 | + |
| 20 | +- `XMPP_JID`: Your bot's XMPP account (e.g., `bot@example.com`) |
| 21 | +- `XMPP_PASSWORD`: Password for the XMPP account |
| 22 | +- `OPENAI_API_KEY`: Your OpenAI API key |
| 23 | + |
| 24 | +### Quick Start with Docker |
| 25 | + |
| 26 | +Pull and run the latest image: |
| 27 | + |
| 28 | +```bash |
| 29 | +docker run \ |
| 30 | + -e XMPP_JID=bot@example.com \ |
| 31 | + -e XMPP_PASSWORD=your_password \ |
| 32 | + -e OPENAI_API_KEY=sk-your-openai-key \ |
| 33 | + ghcr.io/mykolabilyi/xmpp-llm-bridge:latest |
| 34 | +``` |
| 35 | + |
| 36 | +### Docker Compose (Recommended) |
| 37 | + |
| 38 | +Use this `docker-compose.yml`: |
| 39 | + |
| 40 | +```yaml |
| 41 | +services: |
| 42 | + bridge: |
| 43 | + image: ghcr.io/mykolabilyi/xmpp-llm-bridge:latest |
| 44 | + environment: |
| 45 | + - XMPP_JID=bot@example.com |
| 46 | + - XMPP_PASSWORD=your_password |
| 47 | + - OPENAI_API_KEY=sk-your-openai-key |
| 48 | + restart: unless-stopped |
| 49 | +``` |
| 50 | +
|
| 51 | +Start the service: |
| 52 | +
|
| 53 | +```bash |
| 54 | +docker compose up -d |
| 55 | +``` |
| 56 | + |
| 57 | +## Development |
| 58 | + |
| 59 | +### Architecture |
| 60 | + |
| 61 | +The service implements a hexagonal architecture pattern: |
| 62 | + |
| 63 | +- **Core Business Logic**: Located in `/internal/app/` with dependency injection via context-based providers |
| 64 | +- **Ports**: Interfaces in `/internal/ports/` define contracts for external services |
| 65 | +- **Adapters**: External integrations in `/internal/adapters/` handle XMPP, OpenAI, and HTTP communications |
| 66 | +- **Entities**: Domain models in `/internal/entities/` represent core data structures |
| 67 | + |
| 68 | +The application runs two concurrent services: |
| 69 | + |
| 70 | +1. **XMPP Client**: Handles incoming chat messages and processes them through the LLM |
| 71 | +2. **HTTP Server**: Provides health check endpoint on port 8080 for monitoring |
| 72 | + |
3 | 73 | ## Tasks |
4 | 74 |
|
| 75 | +[xc] is recommended to simplify running tasks |
| 76 | + |
5 | 77 | ### run |
6 | 78 |
|
7 | 79 | ```sh |
8 | 80 | go run cmd/app/main.go |
9 | 81 | ``` |
10 | 82 |
|
11 | | -### build-image |
| 83 | +### image-build |
12 | 84 |
|
13 | 85 | run: once |
14 | 86 | Inputs: TAG |
15 | 87 | Environment: TAG=dev |
16 | 88 |
|
17 | 89 | ```sh |
18 | | -docker build -t ghcr.io/mykolabilyi/xmpp-llm-bridge:$TAG . |
| 90 | +docker compose build |
19 | 91 | ``` |
20 | 92 |
|
21 | | -### run-image |
| 93 | +### image-run |
22 | 94 |
|
23 | 95 | Inputs: TAG |
24 | 96 | Environment: TAG=dev |
25 | | -Requires: build-image |
26 | 97 |
|
27 | 98 | ```sh |
28 | | -docker run --rm --name xmpp-llm-bridge-dev \ |
29 | | - -e XMPP_JID=$XMPP_JID \ |
30 | | - -e XMPP_PASSWORD=$XMPP_PASSWORD \ |
31 | | - -p 8080:8080 \ |
32 | | - ghcr.io/mykolabilyi/xmpp-llm-bridge:$TAG |
| 99 | +docker compose up |
33 | 100 | ``` |
| 101 | + |
| 102 | +[xc]: https://xcfile.dev/ |
0 commit comments