# datyth/zaloai-challenge-lifemate architecture

> Architecture diagram of the GitHub repository datyth/zaloai-challenge-lifemate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/datyth/zaloai-challenge-lifemate
- Repository: https://github.com/datyth/zaloai-challenge-lifemate

## Overview

LifeMate is an offline Vietnamese voice-to-tool agent and challenge solution. Its main runtime turns a sample’s audio into text, builds a prompt from the request and read-only context, asks a local LLM for tool calls, validates and executes calls on the sample’s ToolEnv, then records calls and the final state hash. The repository also includes ASR and agent training-data pipelines, synthetic task generation, and evaluation. Several runtime links are supported by the CLI excerpt and source index; README-documented capabilities cover some unsampled branches.

Main entry points: [`src/lifemate/cli.py`](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/cli.py) (Inference CLI), [`src/lifemate/agent.py`](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/agent.py) (Checked agent loop), [`src/lifemate/toolenv.py`](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/toolenv.py) (Organizer ToolEnv), [`src/lifemate/docker_predict.py`](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/docker_predict.py) (Docker prediction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Inference runtime"]
  node_cli["Inference CLI<br/>[cli.py]"]
  node_asr["Gipformer ASR<br/>[asr.py]"]
  node_data["Input data<br/>[data.py]"]
  node_toolenv["Organizer ToolEnv<br/>[toolenv.py]"]
  node_submission["Submission output<br/>[submission.py]"]
  node_docker["Docker prediction<br/>[docker_predict.py]"]
end

subgraph group_agent["Agent decision layers"]
  node_context["Prompt context<br/>[context.py]"]
  node_history["History formatter<br/>[history.py]"]
  node_agentloop["Checked agent loop<br/>[agent.py]"]
  node_llm["Local chat client<br/>[llm.py]"]
  node_ensemble["Step-level voting<br/>[ensemble.py]"]
end

subgraph group_training["Training and data"]
  node_sft["Agent SFT trajectories"]
  node_asrtargets["ASR target data<br/>[asr_targets.py]"]
  node_giptrain["Gipformer training<br/>[gipformer_pt.py]"]
  node_synthbuild["Synthetic split builder"]
  node_synthcatalog["Synthetic app catalog<br/>[catalog.py]"]
  node_synthcommon["Synthetic task helpers<br/>[_common.py]"]
  node_synthhome["Home service tasks<br/>[home_services.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_metrics["Run metrics<br/>[metrics.py]"]
  node_score["Score analysis<br/>[score.py]"]
end

node_user(("Voice requester"))

node_user -->|"submits request"| node_cli
node_cli -->|"loads samples"| node_data
node_cli -->|"transcribes audio"| node_asr
node_cli -->|"builds context"| node_context
node_cli -->|"runs agent"| node_agentloop
node_cli -->|"configures client"| node_llm
node_cli -->|"selects voting"| node_ensemble
node_cli -->|"creates environment"| node_toolenv
node_cli -->|"writes results"| node_submission
node_cli -->|"computes metrics"| node_metrics
node_agentloop -->|"formats history"| node_history
node_agentloop -->|"builds prompt"| node_context
node_agentloop -->|"requests proposals"| node_llm
node_agentloop -->|"executes checked calls"| node_toolenv
node_ensemble -->|"returns winning proposal"| node_agentloop
node_docker -->|"runs agent"| node_agentloop
node_docker -->|"transcribes audio"| node_asr
node_docker -->|"uses prompt context"| node_context
node_docker -->|"creates environment"| node_toolenv
node_sft -->|"replays trajectories"| node_agentloop
node_sft -->|"loads samples"| node_data
node_sft -->|"checks gold calls"| node_toolenv
node_asrtargets -->|"provides targets"| node_giptrain
node_synthbuild -.->|"builds synthetic data"| node_synthcatalog
node_synthhome -->|"uses task helpers"| node_synthcommon
node_score -->|"scores predictions"| node_submission
node_score -->|"compares state"| node_toolenv

click node_cli "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/cli.py"
click node_asr "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/asr.py"
click node_data "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/data.py"
click node_context "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/context.py"
click node_history "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/history.py"
click node_agentloop "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/agent.py"
click node_llm "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/llm.py"
click node_ensemble "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/ensemble.py"
click node_toolenv "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/toolenv.py"
click node_submission "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/submission.py"
click node_docker "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/docker_predict.py"
click node_sft "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/scripts/data/prepare_agent_sft.py"
click node_asrtargets "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/scripts/train/asr_targets.py"
click node_giptrain "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/scripts/train/gipformer_pt.py"
click node_synthbuild "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/scripts/data/build_synth_split.py"
click node_synthcatalog "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/synth/catalog.py"
click node_synthcommon "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/synth/tasks/_common.py"
click node_synthhome "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/synth/tasks/home_services.py"
click node_metrics "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/metrics.py"
click node_score "https://github.com/datyth/zaloai-challenge-lifemate/blob/main/analysis/score.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_asr,node_data,node_toolenv,node_submission,node_docker toneBlue
class node_context,node_history,node_agentloop,node_llm,node_ensemble toneAmber
class node_sft,node_asrtargets,node_giptrain,node_synthbuild,node_synthcatalog,node_synthcommon,node_synthhome,node_user toneMint
class node_metrics,node_score toneRose
```

## Components

### Inference runtime

- [Inference CLI](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/cli.py): `src/lifemate/cli.py`
- [Gipformer ASR](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/asr.py): `src/lifemate/asr.py`
- [Input data](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/data.py): `src/lifemate/data.py`
- [Organizer ToolEnv](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/toolenv.py): `src/lifemate/toolenv.py`
- [Submission output](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/submission.py): `src/lifemate/submission.py`
- [Docker prediction](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/docker_predict.py): `src/lifemate/docker_predict.py`

### Agent decision layers

- [Prompt context](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/context.py): `src/lifemate/context.py`
- [History formatter](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/history.py): `src/lifemate/history.py`
- [Checked agent loop](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/agent.py): `src/lifemate/agent.py`
- [Local chat client](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/llm.py): `src/lifemate/llm.py`
- [Step-level voting](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/ensemble.py): `src/lifemate/ensemble.py`

### Training and data

- [Agent SFT trajectories](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/scripts/data/prepare_agent_sft.py): `scripts/data/prepare_agent_sft.py`
- [ASR target data](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/scripts/train/asr_targets.py): `scripts/train/asr_targets.py`
- [Gipformer training](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/scripts/train/gipformer_pt.py): `scripts/train/gipformer_pt.py`
- [Synthetic split builder](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/scripts/data/build_synth_split.py): `scripts/data/build_synth_split.py`
- [Synthetic app catalog](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/synth/catalog.py): `synth/catalog.py`
- [Synthetic task helpers](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/synth/tasks/_common.py): `synth/tasks/_common.py`
- [Home service tasks](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/synth/tasks/home_services.py): `synth/tasks/home_services.py`

### Evaluation

- [Run metrics](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/src/lifemate/metrics.py): `src/lifemate/metrics.py`
- [Score analysis](https://github.com/datyth/zaloai-challenge-lifemate/blob/main/analysis/score.py): `analysis/score.py`

### Other components

- **Voice requester**

## Connections

- Voice requester → Inference CLI: submits request (evidence: `README.md`)
- Inference CLI → Input data: loads samples (evidence: `src/lifemate/cli.py`)
- Inference CLI → Gipformer ASR: transcribes audio (evidence: `src/lifemate/cli.py`)
- Inference CLI → Prompt context: builds context (evidence: `src/lifemate/cli.py`)
- Inference CLI → Checked agent loop: runs agent (evidence: `src/lifemate/cli.py`)
- Inference CLI → Local chat client: configures client (evidence: `src/lifemate/cli.py`)
- Inference CLI → Step-level voting: selects voting (evidence: `src/lifemate/cli.py`)
- Inference CLI → Organizer ToolEnv: creates environment (evidence: `src/lifemate/cli.py`)
- Inference CLI → Submission output: writes results (evidence: `src/lifemate/cli.py`)
- Inference CLI → Run metrics: computes metrics (evidence: `src/lifemate/cli.py`)
- Checked agent loop → History formatter: formats history (evidence: `src/lifemate/agent.py`)
- Checked agent loop → Prompt context: builds prompt (evidence: `src/lifemate/agent.py`)
- Checked agent loop → Local chat client: requests proposals (evidence: `src/lifemate/agent.py`)
- Checked agent loop → Organizer ToolEnv: executes checked calls (evidence: `README.md`)
- Step-level voting → Checked agent loop: returns winning proposal (evidence: `src/lifemate/ensemble.py`)
- Docker prediction → Checked agent loop: runs agent (evidence: `src/lifemate/docker_predict.py`)
- Docker prediction → Gipformer ASR: transcribes audio (evidence: `src/lifemate/docker_predict.py`)
- Docker prediction → Prompt context: uses prompt context (evidence: `src/lifemate/docker_predict.py`)
- Docker prediction → Organizer ToolEnv: creates environment (evidence: `src/lifemate/docker_predict.py`)
- Agent SFT trajectories → Checked agent loop: replays trajectories (evidence: `scripts/data/prepare_agent_sft.py`)
- Agent SFT trajectories → Input data: loads samples (evidence: `scripts/data/prepare_agent_sft.py`)
- Agent SFT trajectories → Organizer ToolEnv: checks gold calls (evidence: `scripts/data/prepare_agent_sft.py`)
- ASR target data → Gipformer training: provides targets (evidence: `scripts/train/train_gipformer.py`)
- Synthetic split builder → Synthetic app catalog: builds synthetic data
- Home service tasks → Synthetic task helpers: uses task helpers (evidence: `synth/tasks/home_services.py`)
- Score analysis → Submission output: scores predictions (evidence: `analysis/score.py`)
- Score analysis → Organizer ToolEnv: compares state (evidence: `analysis/score.py`)
