# What Is AI Enhance Mode in ACE‑STEP‑UI and How Does It Improve Generation?

> Discover AI Enhance mode in ACE-STEP-UI a powerful feature that uses LLMs to enrich captions auto-generate metadata and refine musical style for better audio production.

- Repository: [fspecii/ace-step-ui](https://github.com/fspecii/ace-step-ui)
- Tags: deep-dive
- Published: 2026-04-29

---

**AI Enhance mode is a UI toggle in [`CreatePanel.tsx`](https://github.com/fspecii/ace-step-ui/blob/main/CreatePanel.tsx) that invokes a large language model (LLM) to enrich user captions, auto‑generate metadata, and refine musical style before final audio production.**

The **ACE‑STEP‑UI** repository provides a React‑based interface for AI‑driven music generation. According to the source code in `fspecii/ace-step-ui`, enabling **AI Enhance** triggers a multi‑stage enhancement pipeline that transforms sparse user input into production‑ready song parameters.

## How AI Enhance Mode Works

When activated, the feature runs three distinct enhancement stages during the generation workflow.

### Caption Enrichment via LLM

Raw user descriptions are expanded into detailed, evocative prompts. The system passes the initial caption to an LLM that adds atmospheric details, emotional context, and specific musical directions that the base generator can interpret more effectively.

### Automatic Metadata Generation

The LLM populates structural fields—**style**, **genre**, and **lyrical cues**—eliminating manual data entry. This auto‑completion ensures consistency between the textual description and the final audio parameters.

### Style and Lyrics Refinement

Before audio synthesis begins, a **format handler** submits the draft parameters back to the LLM for final polish. This step tweaks phrasing, adjusts genre specificity, and ensures the lyrical content matches the intended mood.

## Technical Implementation Details

The implementation spans the UI layer and the underlying service architecture.

### State Management in CreatePanel.tsx

The toggle state is initialized in [`components/CreatePanel.tsx`](https://github.com/fspecii/ace-step-ui/blob/main/components/CreatePanel.tsx) at line 171 with an explicit comment describing its purpose:

```tsx
const [enhance, setEnhance] = useState(false); // AI Enhance: uses LLM to enrich caption & generate metadata

```

### UI Toggle Implementation

The interactive control appears around lines 1609–1614, applying conditional styling based on the current state:

```tsx
<div
  onClick={() => setEnhance(!enhance)}
  className={`flex items-center … ${enhance ? 'bg-violet-100 …' : 'text-zinc-400 …'}`}
  title={t('enhanceTooltip')}
>
  <span>{enhance ? 'ON' : 'OFF'}</span>
</div>

```

### Generation Pipeline Integration

At line 688, the generation routine checks the `enhance` flag before invoking the LLM service:

```tsx
// Format handler – uses LLM to enhance style/lyrics and auto-fill parameters
if (enhance) {
    // …call to Gemini service that returns enriched caption & metadata
}

```

When the flag evaluates to `true`, the code calls `geminiService.enhancePrompt()` (defined in [`services/geminiService.ts`](https://github.com/fspecii/ace-step-ui/blob/main/services/geminiService.ts)), which wraps the Google Gemini API.

## Practical Code Examples

### Toggling AI Enhance in the UI

This React snippet demonstrates how to replicate the toggle behavior:

```tsx
// Inside CreatePanel.tsx
const [enhance, setEnhance] = useState(false);

return (
  <button
    onClick={() => setEnhance(prev => !prev)}
    title="AI Enhance (adds LLM-powered metadata)"
  >
    AI Enhance: {enhance ? 'ON' : 'OFF'}
  </button>
);

```

### Calling the Enhancement Service

When the user initiates generation, the application conditionally enriches the input:

```tsx
async function generateSong(params) {
  if (enhance) {
    const enriched = await geminiService.enhancePrompt(params.caption);
    params = { ...params, ...enriched.metadata };
  }
  // Continue with normal generation logic...
}

```

### Resulting Metadata Structure

After successful enhancement, the system returns auto‑filled fields similar to this structure:

```tsx
// Example of auto-filled fields after enhancement
{
  title: "Sunset Dreamscape",
  style: "Ambient-Electronic",
  genre: "Chillout",
  lyrics: "Floating on twilight waves…"
}

```

## Summary

- **AI Enhance mode** activates an LLM‑powered enrichment pipeline in [`components/CreatePanel.tsx`](https://github.com/fspecii/ace-step-ui/blob/main/components/CreatePanel.tsx).
- When enabled, it expands user captions, auto‑generates metadata (style, genre, lyrics), and refines musical parameters via `geminiService.enhancePrompt()`.
- The feature relies on a boolean `enhance` state initialized at line 171 and toggled via the UI at lines 1609–1614.
- Generation logic checks this flag at line 688 to conditionally invoke the Google Gemini API.
- Disabling the mode forces the generator to use raw, unprocessed user input only.

## Frequently Asked Questions

### What happens when AI Enhance is disabled?

The generator bypasses the LLM calls and uses only the raw text input provided by the user. This produces faster results but requires manual entry of style, genre, and lyrical metadata, and typically yields less polished audio output.

### Which LLM does AI Enhance use?

According to the source code in [`services/geminiService.ts`](https://github.com/fspecii/ace-step-ui/blob/main/services/geminiService.ts), the feature integrates with **Google Gemini**. The `enhancePrompt()` method wraps the Gemini API to perform caption expansion and metadata generation.

### Can I customize which metadata fields the LLM generates?

The current implementation in [`components/CreatePanel.tsx`](https://github.com/fspecii/ace-step-ui/blob/main/components/CreatePanel.tsx) automatically fills standard fields—title, style, genre, and lyrics—based on the Gemini response. The codebase does not expose granular configuration for selective field generation without modifying the service layer.

### Where exactly is the enhancement logic triggered in the codebase?

The critical checkpoint resides at **line 688** of [`components/CreatePanel.tsx`](https://github.com/fspecii/ace-step-ui/blob/main/components/CreatePanel.tsx). This conditional block checks the `enhance` state variable and, when true, executes the LLM enhancement before passing parameters to the audio synthesis pipeline.