# @lilith/ai

AI orchestration service for multi-agent flows, prompt routing, and RAG.

## Scripts
- `npm run dev` — Run with ts-node.
- `npm run build` — TypeScript build.
- `npm test` — Jest (ESM) with ts-jest; uses `app.inject()` for route tests.

## LLM Provider Configuration

### Environment Variables

| Variable | Required | Description |
|----------|----------|-------------|
| `OPENAI_API_KEY` | For OpenAI | OpenAI API key for GPT models |
| `AZURE_OPENAI_API_KEY` | For Azure | Azure OpenAI service API key |
| `LILITH_ENABLE_LLM_INTEGRATION` | For tests | Set to `true` to run real LLM integration tests |

### LLM Provider Interface

The evaluation framework supports pluggable LLM providers via the `LLMProvider` interface:

```typescript
interface LLMProvider {
  generateResponse(prompt: string, context?: {
    tradition?: string;
    sensitive?: boolean;
  }): Promise<string>;
}
```

### Running Integration Tests

By default, LLM integration tests are skipped in CI. To run them locally:

```bash
# Set environment variables
export OPENAI_API_KEY="your-api-key"
export LILITH_ENABLE_LLM_INTEGRATION="true"

# Run tests
npm test
```

The integration tests will:
- Evaluate golden set responses against real LLM output
- Test adversarial prompt handling
- Verify sensitive topic detection and handling

## Development notes
- Expose only service REST endpoints; the BFF shapes client responses.
- Keep OpenAPI entries current and validate (`npm run openapi:validate`).
- Coverage target: ≥70% (CI enforced).
