Nik Afiq 520f5d1ffb
Some checks failed
CI / build-ai-gateway (push) Has been cancelled
CI / build-ha-gateway (push) Has been cancelled
CI / build-discord-bot (push) Has been cancelled
CI / test (push) Has been cancelled
feat: add ai-gateway microservice with gRPC API for AI logic
- Implemented new gRPC service `AIService` in `proto/ai/v1/ai.proto` for handling natural language queries.
- Generated Go code for the gRPC service and messages in `gen/ai/v1/`.
- Created `services/ai-gateway/` directory structure with necessary files for the service.
- Added configuration loading and structured logging.
- Implemented domain logic for intent parsing and interaction with Home Assistant.
- Established outbound adapters for Ollama and Home Assistant with mTLS support.
- Updated `go.work` to include the new service and maintain existing dependencies.
- Modified `discord-bot` to use the new `ai-gateway` for AI interactions.
- Added deployment manifest for Kubernetes and CI/CD configuration for building and deploying the service.
2026-04-21 21:52:28 +09:00

34 lines
1.1 KiB
Go

package domain
import (
"fmt"
"strings"
)
const systemPrompt = `You are a home automation assistant. Respond with a single JSON object and nothing else.
Schema:
{
"intent": "turn_on_light" | "turn_off_light" | "list_lights" | "none",
"entity": "<entity_id_or_friendly_name_or_empty>",
"params": { "<key>": "<value>" },
"reply": "<short human-readable reply>"
}
Rules:
- Always include all four fields.
- Return only valid JSON. No markdown, no code fences, no extra prose.
- Use "none" for non-actionable requests.
- If the user asks what lights exist, use "list_lights".
- Prefer returning the exact entity_id when it is obvious from the known light list.
- TODO: switch discovery is intentionally omitted until ha-gateway switch support is ready.`
// BuildPrompt combines the system instructions, known lights, and the user request.
func BuildPrompt(userText string, knownLights []string) string {
lightLines := "- none known"
if len(knownLights) > 0 {
lightLines = strings.Join(knownLights, "\n")
}
return fmt.Sprintf("%s\n\nKnown lights:\n%s\n\nUser request: %s", systemPrompt, lightLines, userText)
}