Skip to content

Commit

Permalink
organize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
kszapsza committed Jan 5, 2025
1 parent 76807ba commit c364d46
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package io.github.kszapsza.springairag.adapter.application;

import io.github.kszapsza.springairag.adapter.llm.ChatProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import io.github.kszapsza.springairag.adapter.llm.ChatProperties;

@Configuration
@EnableConfigurationProperties(ChatProperties.class)
public class ApplicationConfiguration {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.kszapsza.springairag.adapter.db.realestate;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.jpa.repository.JpaRepository;

import java.math.BigDecimal;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package io.github.kszapsza.springairag.adapter.db.realestate;

import java.io.IOException;
import java.util.List;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.kszapsza.springairag.domain.realestate.RealEstateFeeder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import io.github.kszapsza.springairag.domain.realestate.RealEstateFeeder;
import java.io.IOException;
import java.util.List;

@Component
public class RealEstateRepositoryFeeder implements RealEstateFeeder {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package io.github.kszapsza.springairag.adapter.llm;

import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Map;

@ConfigurationProperties(prefix = "app.chat")
public record ChatProperties(
Embedding embedding,
SystemPrompt systemPrompt) {
Embedding embedding,
SystemPrompt systemPrompt) {

public record Embedding(String document) {
}
public record Embedding(String document) {
}

public record SystemPrompt(
String resource,
Map<String, Object> placeholders) {
}
public record SystemPrompt(
String resource,
Map<String, Object> placeholders) {
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.github.kszapsza.springairag.adapter.llm;

import java.util.List;

import org.springframework.ai.document.Document;

import java.util.List;

public interface EmbeddingDocumentsProvider {
List<Document> provideData();
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package io.github.kszapsza.springairag.adapter.llm.classpath;

import java.util.List;

import io.github.kszapsza.springairag.adapter.llm.EmbeddingDocumentsProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.document.Document;
import org.springframework.ai.reader.JsonReader;
import org.springframework.core.io.Resource;

import io.github.kszapsza.springairag.adapter.llm.EmbeddingDocumentsProvider;
import java.util.List;

public class ClasspathEmbeddingDocumentsProvider implements EmbeddingDocumentsProvider {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package io.github.kszapsza.springairag.adapter.llm.classpath;

import io.github.kszapsza.springairag.adapter.llm.EmbeddingDocumentsProvider;
import io.github.kszapsza.springairag.adapter.llm.SystemPromptTemplateProvider;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;

import io.github.kszapsza.springairag.adapter.llm.EmbeddingDocumentsProvider;
import io.github.kszapsza.springairag.adapter.llm.SystemPromptTemplateProvider;

@Configuration
class ClasspathResourcesConfiguration {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package io.github.kszapsza.springairag.adapter.llm.classpath;

import io.github.kszapsza.springairag.adapter.llm.SystemPromptTemplateProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.chat.prompt.SystemPromptTemplate;
import org.springframework.core.io.Resource;

import io.github.kszapsza.springairag.adapter.llm.SystemPromptTemplateProvider;

public class ClasspathSystemPromptTemplateProvider implements SystemPromptTemplateProvider {

private static final Logger logger = LoggerFactory.getLogger(ClasspathSystemPromptTemplateProvider.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package io.github.kszapsza.springairag.adapter.llm.function;

import java.util.function.Function;

import io.github.kszapsza.springairag.adapter.db.realestate.RealEstateRepository;
import io.github.kszapsza.springairag.adapter.llm.function.realestate.RealEstateSearchFunction;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;

import io.github.kszapsza.springairag.adapter.db.realestate.RealEstateRepository;
import io.github.kszapsza.springairag.adapter.llm.function.realestate.RealEstateSearchFunction;
import java.util.function.Function;

@Configuration
class FunctionConfiguration {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package io.github.kszapsza.springairag.adapter.llm.function.realestate;

import java.math.BigDecimal;
import java.util.List;
import java.util.function.Function;

import io.github.kszapsza.springairag.adapter.db.realestate.RealEstateEntity;
import io.github.kszapsza.springairag.adapter.db.realestate.RealEstateRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.github.kszapsza.springairag.adapter.db.realestate.RealEstateEntity;
import io.github.kszapsza.springairag.adapter.db.realestate.RealEstateRepository;
import java.math.BigDecimal;
import java.util.List;
import java.util.function.Function;

public class RealEstateSearchFunction
implements Function<RealEstateSearchFunction.Request, RealEstateSearchFunction.Response> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.github.kszapsza.springairag.adapter.llm.memory;

import java.util.List;

import io.github.kszapsza.springairag.domain.chat.ChatMessage;
import io.github.kszapsza.springairag.domain.chat.memory.ChatMemoryPort;
import io.github.kszapsza.springairag.domain.chat.memory.ConversationId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.chat.memory.ChatMemory;
Expand All @@ -10,9 +11,7 @@
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.stereotype.Component;

import io.github.kszapsza.springairag.domain.chat.ChatMessage;
import io.github.kszapsza.springairag.domain.chat.memory.ChatMemoryPort;
import io.github.kszapsza.springairag.domain.chat.memory.ConversationId;
import java.util.List;

@Component
public class ChatMemoryProvider implements ChatMemoryPort {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package io.github.kszapsza.springairag.adapter.llm.openai;

import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor.CHAT_MEMORY_CONVERSATION_ID_KEY;
import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor.CHAT_MEMORY_RETRIEVE_SIZE_KEY;

import java.util.List;
import java.util.Optional;

import io.github.kszapsza.springairag.domain.chat.ChatPort;
import io.github.kszapsza.springairag.domain.chat.ChatRequest;
import io.github.kszapsza.springairag.domain.chat.ChatResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.chat.client.ChatClient;
Expand All @@ -14,9 +11,11 @@
import org.springframework.ai.chat.prompt.ChatOptions;
import org.springframework.stereotype.Component;

import io.github.kszapsza.springairag.domain.chat.ChatPort;
import io.github.kszapsza.springairag.domain.chat.ChatRequest;
import io.github.kszapsza.springairag.domain.chat.ChatResponse;
import java.util.List;
import java.util.Optional;

import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor.CHAT_MEMORY_CONVERSATION_ID_KEY;
import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor.CHAT_MEMORY_RETRIEVE_SIZE_KEY;

@Component
public class OpenAiChatAdapter implements ChatPort {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.kszapsza.springairag.adapter.llm.openai;

import java.util.List;

import io.github.kszapsza.springairag.adapter.llm.ChatProperties;
import io.github.kszapsza.springairag.adapter.llm.SystemPromptTemplateProvider;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor;
Expand All @@ -17,8 +17,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.github.kszapsza.springairag.adapter.llm.ChatProperties;
import io.github.kszapsza.springairag.adapter.llm.SystemPromptTemplateProvider;
import java.util.List;

@Configuration
class OpenAiChatConfiguration {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package io.github.kszapsza.springairag.adapter.llm.openai;

import io.github.kszapsza.springairag.adapter.llm.EmbeddingDocumentsProvider;
import io.github.kszapsza.springairag.domain.embedding.EmbeddingsFeeder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.stereotype.Component;

import io.github.kszapsza.springairag.adapter.llm.EmbeddingDocumentsProvider;
import io.github.kszapsza.springairag.domain.embedding.EmbeddingsFeeder;

@Component
public class OpenAiEmbeddingsFeeder implements EmbeddingsFeeder {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package io.github.kszapsza.springairag.adapter.rest;

import io.github.kszapsza.springairag.domain.chat.ChatPort;
import io.github.kszapsza.springairag.domain.chat.ChatRequest;
import io.github.kszapsza.springairag.domain.chat.ChatResponse;
import io.github.kszapsza.springairag.domain.chat.memory.ConversationId;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
Expand All @@ -10,13 +16,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.github.kszapsza.springairag.domain.chat.ChatPort;
import io.github.kszapsza.springairag.domain.chat.ChatRequest;
import io.github.kszapsza.springairag.domain.chat.ChatResponse;
import io.github.kszapsza.springairag.domain.chat.memory.ConversationId;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;

@RestController
@RequestMapping("/api/chat")
public class ChatController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
package io.github.kszapsza.springairag.adapter.rest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.github.kszapsza.springairag.domain.chat.ChatMessage;
import io.github.kszapsza.springairag.domain.chat.ChatMessageType;
import io.github.kszapsza.springairag.domain.chat.memory.ChatMemoryPort;
import io.github.kszapsza.springairag.domain.chat.memory.ConversationId;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

@RestController
@RequestMapping("/api/conversation")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.github.kszapsza.springairag.domain.chat.memory;

import java.util.List;

import io.github.kszapsza.springairag.domain.chat.ChatMessage;

import java.util.List;

public interface ChatMemoryPort {

void add(ConversationId conversationId, ChatMessage message);
Expand Down

0 comments on commit c364d46

Please sign in to comment.