Skip to content

Commit d8486dc

Browse files
committed
feat: add feature
1 parent 8dc2586 commit d8486dc

4 files changed

Lines changed: 100 additions & 1 deletion

File tree

.github/copilot-instructions.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# AI Coding Agent Instructions for AIDocumentLibraryChat
2+
3+
## Architecture Overview
4+
This is a Spring Boot 3.5+ application with an embedded Angular frontend, demonstrating Spring AI 1.1+ capabilities for document/image chat, SQL generation, and function calling. It uses PostgreSQL with pgvector for vector storage and embeddings.
5+
6+
- **Backend**: REST controllers (Document, Image, Table/SQL, Function) → Services → Repositories (JPA + VectorStore) → ChatClient for AI interactions.
7+
- **Frontend**: Angular SPA for uploads, searches, and result display.
8+
- **Data Flow**: Upload content → Chunk/embed/store in vector DB → Query embed → Vector search → AI generates response with source links.
9+
- **Why this structure**: Enables RAG on personal documents/images/DBs, reducing hallucinations by grounding responses in stored content.
10+
11+
Key files: `structurizr/workspace.dsl` (C4 diagrams), `backend/src/main/resources/application.properties` (configs).
12+
13+
## Critical Workflows
14+
- **Build**: `./gradlew clean build -PwithAngular=true` (includes npm build). Add `-PuseOllama=true` for Ollama dependencies.
15+
- **Run**: `java -jar backend/build/libs/aidocumentlibrarychat.jar --spring.profiles.active=ollama` (or default for OpenAI).
16+
- **Services**: `./runPostgresql.sh` (DB), `./runOllama.sh` (local AI), `./runStructurizr.sh` (diagrams).
17+
- **Debug**: Check AI prompts/responses in logs. Use profiles to switch models. Test with `curl` to REST endpoints.
18+
19+
## Project-Specific Patterns
20+
- **AI Integration**: Use `ChatClient` with prompts for tasks (e.g., `@SystemMessage` for RAG). Embeddings via OpenAI API or ONNX transformers.
21+
- **Model Selection**: Different Ollama models per feature (e.g., `qwen2.5:32b` for docs, `llama3.2-vision` for images). Configured in `application-ollama.properties`.
22+
- **Token Management**: Set `document-token-limit`, `embedding-token-limit` per profile to control context.
23+
- **DB Migrations**: Liquibase changelogs in `backend/src/main/resources/dbchangelog/`. Separate for Ollama (includes vector setup).
24+
- **MCP Tools**: Client connects to external servers via SSE for book/movie data. Enabled with `spring.ai.mcp.client.enabled=true`.
25+
26+
Examples:
27+
- Document RAG: `DocumentService` chunks text, embeds, stores; queries use cosine similarity.
28+
- Image Search: `ImageService` generates descriptions via LLava, embeds them.
29+
- SQL Gen: `TableService` uses metadata embeddings to build queries.
30+
31+
## Conventions
32+
- Profiles: `default` (OpenAI), `ollama` (local models), `prod` (production settings).
33+
- Properties: Environment vars for API keys (e.g., `OPENAI-API-KEY`, `OLLAMA-BASE-URL`).
34+
- Testing: Unit tests with JUnit; integration via Spring Boot Test. ArchUnit for architecture checks.
35+
- Dependencies: Managed via Spring BOM; vector store via `spring-ai-starter-vector-store-pgvector`.
36+
37+
Reference: `backend/build.gradle` (dependencies), `application-ollama.properties` (model configs).
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright 2023 Sven Loesekann
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package ch.xxx.aidoclibchat.adapter.controller;
14+
15+
import org.springframework.web.bind.annotation.GetMapping;
16+
import org.springframework.web.bind.annotation.RequestMapping;
17+
import org.springframework.web.bind.annotation.RestController;
18+
19+
import ch.xxx.aidoclibchat.usecase.service.SiteSummaryService;
20+
21+
@RestController
22+
@RequestMapping("rest/site-summary")
23+
public class SiteSummaryController {
24+
private final SiteSummaryService siteSummaryService;
25+
26+
public SiteSummaryController(SiteSummaryService siteSummaryService) {
27+
this.siteSummaryService = siteSummaryService;
28+
}
29+
30+
@GetMapping("/joke-about/{topic}")
31+
public String getJokeAboutTopic(String topic) {
32+
return this.siteSummaryService.getJokeAboutTopic(topic);
33+
}
34+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright 2023 Sven Loesekann
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package ch.xxx.aidoclibchat.usecase.service;
14+
15+
import org.springframework.stereotype.Service;
16+
17+
@Service
18+
public class SiteSummaryService {
19+
public String getJokeAboutTopic(String topic) {
20+
// Placeholder implementation
21+
return "Why did the " + topic + " go to the party? Because it wanted to have a blast!";
22+
}
23+
}

backend/src/main/resources/application-ollama.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ spring.ai.ollama.chat.options.num-thread=8
5858
spring.ai.ollama.chat.options.keep_alive=1s
5959

6060
# mcp-server
61-
spring.ai.ollama.chat.options.model=qwen3:32b
61+
#spring.ai.ollama.chat.options.model=qwen3:32b
62+
#spring.ai.ollama.chat.options.num-ctx=32768
63+
64+
# summerize web pages
65+
#spring.ai.ollama.chat.options.model=qwen3-next:latest
66+
spring.ai.ollama.chat.options.model=nemotron-3-nano:30b
6267
spring.ai.ollama.chat.options.num-ctx=32768
6368

6469
#spring.ai.ollama.chat.options.model=llama3.1:70b

0 commit comments

Comments
 (0)