Skip to content

AI Integration (Spring AI)

SREDSimplify utilizes the Spring AI framework to abstract interactions with LLM providers (primarily OpenAI).

Setup

The ChatClient bean is auto-configured via the SPRING_AI_OPENAI_API_KEY environment variable.

Prompt Engineering Strategy

The AiServiceImpl is responsible for building prompts dynamically.

  1. System Prompts: Defines the persona (e.g., "You are an expert Canadian SR&ED tax consultant").
  2. Context Injection: Retrieves FileBlob text from the PostgreSQL database and injects it into the prompt context window.
  3. Structured Outputs: Spring AI features are used to enforce JSON schema outputs, ensuring the Next.js frontend receives predictable data structures for rendering.

Timeouts

AI generation for complex T661 forms can take several minutes. Ensure that Tomcat timeouts, Spring transaction timeouts, and HTTP client timeouts are configured appropriately (typically > 5 minutes).