Skip to content

DennSel/ai-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 AI Chat Service laboration

A Spring Boot lab of a middleware service bridging users and LLMs.


Overview

AI Chat Service acts as a smart bridge between your frontend and LLM providers. It manages AI personalities, maintains per-session conversation memory, and exposes a clean REST API for chat interactions — all with built-in resilience via automatic retry.


Features

Feature Description
🤖 Multiple AI Personalities Switch between Assistant, Coder, and Riddler
💾 Session-Based Memory Automatic conversation context management
🔄 Automatic Retry Exponential backoff for resilience
📚 OpenAPI / Swagger UI Interactive API documentation out of the box

Prerequisites

  • Java 21+ (tested with Java 25)
  • Maven 3.6+
  • OpenRouter API keyGet one here

Getting Started

1. Configure your API key

In IntelliJ IDEA:

  1. Go to RunEdit Configurations...
  2. Select AiLabApplication
  3. Under Environment Variables, add:
    OPENROUTER_API_KEY=your-api-key-here
    
  4. Click ApplyOK

2. Run the application

Open AiLabApplication.java and click Run

The application starts on http://localhost:8080


Usage

🖥️ Chat Interface (AI created)

http://localhost:8080/

Browser-based chat UI with automatic session management.

📖 Swagger UI

http://localhost:8080/swagger-ui/index.html

Interactive API documentation with a built-in test interface.


API Reference

POST /api/v1/chat

Request

{
  "personality": "coder",
  "messages": "How do I write a for-loop in Java?"
}

Response

{
  "reply": "A for-loop in Java looks like this: for(int i=0; i<10; i++){}",
  "sessionId": "abc-123-def-456"
}

Personality Options

Value Behavior
assistant Helpful general-purpose assistant
coder Programming teacher
riddler Responds with riddles

Project Structure

ai-lab/
├── src/main/java/org/example/ailab/
│   ├── controller/          # REST controllers
│   ├── service/             # Business logic & AI client
│   ├── dto/                 # Data transfer objects
│   ├── configuration/       # Spring configuration
│   └── exception/           # Global exception handler
├── src/main/resources/
│   ├── application.properties  # App configuration
│   └── static/              # Web files (index.html)
└── src/test/java/           # Tests

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors