Compare commits

..

No commits in common. "0b62e06646513af0480d283de33a59e17e9ee228" and "dce0db03850b4bf3ff2c5c4b731c8296a0173877" have entirely different histories.

21 changed files with 28 additions and 313 deletions

View File

@ -1,6 +1,6 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.9'
id 'org.springframework.boot' version '4.0.1'
id 'io.spring.dependency-management' version '1.1.7'
}
@ -43,21 +43,16 @@ configurations {
}
}
ext {
set('springAiVersion', "1.1.2")
}
dependencies {
// From Spring Initalizr
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.ai:spring-ai-advisors-vector-store'
implementation 'org.springframework.ai:spring-ai-starter-model-ollama'
implementation 'org.springframework.ai:spring-ai-starter-vector-store-pgvector'
implementation 'org.hibernate.orm:hibernate-vector:6.6.39.Final'
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
implementation 'org.springframework.boot:spring-boot-starter-jackson'
implementation 'org.springframework.boot:spring-boot-starter-flyway'
runtimeOnly 'org.postgresql:postgresql'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
testImplementation 'org.springframework.boot:spring-boot-starter-jackson-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
@ -72,7 +67,7 @@ dependencies {
implementation 'org.commonmark:commonmark:0.27.0'
implementation 'org.jsoup:jsoup:1.21.2'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.20.1'
implementation 'tools.jackson.dataformat:jackson-dataformat-yaml:3.0.3'
implementation 'io.minio:minio:8.6.0'
@ -96,12 +91,6 @@ dependencies {
testFixturesImplementation 'org.hamcrest:hamcrest:3.0'
}
dependencyManagement {
imports {
mavenBom "org.springframework.ai:spring-ai-bom:${springAiVersion}"
}
}
tasks.register('integrationTest', Test) {
description = 'Run integration tests.'
group = 'verification'

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

View File

@ -4,17 +4,17 @@ import app.mealsmadeeasy.api.IntegrationTestsExtension;
import app.mealsmadeeasy.api.user.User;
import app.mealsmadeeasy.api.user.UserCreateException;
import app.mealsmadeeasy.api.user.UserService;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.Cookie;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import tools.jackson.databind.ObjectMapper;
import java.util.Map;
import java.util.UUID;
@ -51,7 +51,7 @@ public class AuthControllerTests {
}
}
private MockHttpServletRequestBuilder getLoginRequest(String username, String password) throws Exception {
private MockHttpServletRequestBuilder getLoginRequest(String username, String password) {
final Map<String, Object> body = Map.of(
"username", username,
"password", password

View File

@ -9,12 +9,11 @@ import app.mealsmadeeasy.api.image.spec.ImageUpdateInfoSpec;
import app.mealsmadeeasy.api.user.User;
import app.mealsmadeeasy.api.user.UserCreateException;
import app.mealsmadeeasy.api.user.UserService;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.DynamicPropertyRegistry;
@ -24,6 +23,7 @@ import org.testcontainers.containers.MinIOContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
import tools.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.InputStream;

View File

@ -14,13 +14,11 @@ import app.mealsmadeeasy.api.recipe.star.RecipeStarService;
import app.mealsmadeeasy.api.user.User;
import app.mealsmadeeasy.api.user.UserCreateException;
import app.mealsmadeeasy.api.user.UserService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.http.MediaType;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
@ -29,6 +27,7 @@ import org.testcontainers.containers.MinIOContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
import tools.jackson.databind.ObjectMapper;
import java.io.InputStream;
import java.util.UUID;
@ -224,7 +223,7 @@ public class RecipeControllerTests {
.andExpect(jsonPath("$.content[*].id").value(hasItems(r0.getId(), r1.getId(), r2.getId())));
}
private String getUpdateBody() throws JsonProcessingException {
private String getUpdateBody() {
final RecipeUpdateSpec spec = new RecipeUpdateSpec();
spec.setTitle("Updated Test Recipe");
spec.setPreparationTime(15);

View File

@ -3,17 +3,16 @@ package app.mealsmadeeasy.api.signup;
import app.mealsmadeeasy.api.IntegrationTestsExtension;
import app.mealsmadeeasy.api.user.UserCreateException.Type;
import app.mealsmadeeasy.api.user.UserService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import tools.jackson.databind.ObjectMapper;
import java.util.Map;
import java.util.UUID;
@ -37,8 +36,7 @@ public class SignUpControllerTests {
@Autowired
private UserService userService;
private MockHttpServletRequestBuilder getCheckUsernameRequest(String usernameToCheck)
throws JsonProcessingException {
private MockHttpServletRequestBuilder getCheckUsernameRequest(String usernameToCheck) {
final Map<String, Object> body = Map.of("username", usernameToCheck);
return MockMvcRequestBuilders.get("/sign-up/check-username")
.content(this.objectMapper.writeValueAsString(body))
@ -63,7 +61,7 @@ public class SignUpControllerTests {
}
private MockHttpServletRequestBuilder getCheckEmailRequest(String emailToCheck) throws JsonProcessingException {
private MockHttpServletRequestBuilder getCheckEmailRequest(String emailToCheck) {
final Map<String, Object> body = Map.of("email", emailToCheck);
return MockMvcRequestBuilders.get("/sign-up/check-email")
.content(this.objectMapper.writeValueAsString(body))

View File

@ -1,58 +0,0 @@
package app.mealsmadeeasy.api;
import app.mealsmadeeasy.api.recipe.RecipeEmbeddingEntity;
import app.mealsmadeeasy.api.recipe.RecipeEntity;
import app.mealsmadeeasy.api.recipe.RecipeRepository;
import app.mealsmadeeasy.api.recipe.RecipeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import java.time.OffsetDateTime;
import java.util.List;
@Component
@ConditionalOnProperty(name = "backfill.recipe-embeddings.enabled", havingValue = "true")
public class BackfillRecipeEmbeddings implements ApplicationRunner {
private static final Logger logger = LoggerFactory.getLogger(BackfillRecipeEmbeddings.class);
private final RecipeRepository recipeRepository;
private final RecipeService recipeService;
private final EmbeddingModel embeddingModel;
public BackfillRecipeEmbeddings(
RecipeRepository recipeRepository,
RecipeService recipeService,
EmbeddingModel embeddingModel
) {
this.recipeRepository = recipeRepository;
this.recipeService = recipeService;
this.embeddingModel = embeddingModel;
}
@Override
public void run(ApplicationArguments args) {
final List<RecipeEntity> recipeEntities = this.recipeRepository.findAllByEmbeddingIsNull();
for (final RecipeEntity recipeEntity : recipeEntities) {
logger.info("Calculating embedding for {}", recipeEntity);
final String renderedMarkdown = this.recipeService.getRenderedMarkdown(recipeEntity);
final String toEmbed = "<h1>" + recipeEntity.getTitle() + "</h1>" + renderedMarkdown;
final float[] embedding = this.embeddingModel.embed(toEmbed);
final RecipeEmbeddingEntity recipeEmbedding = new RecipeEmbeddingEntity();
recipeEmbedding.setRecipe(recipeEntity);
recipeEmbedding.setEmbedding(embedding);
recipeEmbedding.setTimestamp(OffsetDateTime.now());
recipeEntity.setEmbedding(recipeEmbedding);
this.recipeRepository.save(recipeEntity);
}
this.recipeRepository.flush();
}
}

View File

@ -8,14 +8,14 @@ import app.mealsmadeeasy.api.recipe.RecipeService;
import app.mealsmadeeasy.api.recipe.spec.RecipeCreateSpec;
import app.mealsmadeeasy.api.user.User;
import app.mealsmadeeasy.api.user.UserService;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.dataformat.yaml.YAMLFactory;
import java.io.FileInputStream;
import java.io.InputStream;

View File

@ -1,12 +1,10 @@
package app.mealsmadeeasy.api.recipe;
import app.mealsmadeeasy.api.image.ImageException;
import app.mealsmadeeasy.api.recipe.body.RecipeSearchBody;
import app.mealsmadeeasy.api.recipe.comment.RecipeComment;
import app.mealsmadeeasy.api.recipe.comment.RecipeCommentCreateBody;
import app.mealsmadeeasy.api.recipe.comment.RecipeCommentService;
import app.mealsmadeeasy.api.recipe.comment.RecipeCommentView;
import app.mealsmadeeasy.api.recipe.spec.RecipeAiSearchSpec;
import app.mealsmadeeasy.api.recipe.spec.RecipeUpdateSpec;
import app.mealsmadeeasy.api.recipe.star.RecipeStar;
import app.mealsmadeeasy.api.recipe.star.RecipeStarService;
@ -15,7 +13,6 @@ import app.mealsmadeeasy.api.recipe.view.RecipeExceptionView;
import app.mealsmadeeasy.api.recipe.view.RecipeInfoView;
import app.mealsmadeeasy.api.sliceview.SliceViewService;
import app.mealsmadeeasy.api.user.User;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.jetbrains.annotations.Nullable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
@ -26,7 +23,6 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@ -37,20 +33,17 @@ public class RecipeController {
private final RecipeStarService recipeStarService;
private final RecipeCommentService recipeCommentService;
private final SliceViewService sliceViewService;
private final ObjectMapper objectMapper;
public RecipeController(
RecipeService recipeService,
RecipeStarService recipeStarService,
RecipeCommentService recipeCommentService,
SliceViewService sliceViewService,
ObjectMapper objectMapper
SliceViewService sliceViewService
) {
this.recipeService = recipeService;
this.recipeStarService = recipeStarService;
this.recipeCommentService = recipeCommentService;
this.sliceViewService = sliceViewService;
this.objectMapper = objectMapper;
}
@ExceptionHandler(RecipeException.class)
@ -111,23 +104,6 @@ public class RecipeController {
return ResponseEntity.ok(this.sliceViewService.getSliceView(slice));
}
@PostMapping
public ResponseEntity<Map<String, Object>> searchRecipes(
@RequestBody(required = false) RecipeSearchBody recipeSearchBody,
@AuthenticationPrincipal User user
) {
if (recipeSearchBody.getType() == RecipeSearchBody.Type.AI_PROMPT) {
final RecipeAiSearchSpec spec = this.objectMapper.convertValue(
recipeSearchBody.getData(),
RecipeAiSearchSpec.class
);
final List<RecipeInfoView> results = this.recipeService.aiSearch(spec, user);
return ResponseEntity.ok(Map.of("results", results));
} else {
throw new IllegalArgumentException("Invalid recipeSearchBody type: " + recipeSearchBody.getType());
}
}
@PostMapping("/{username}/{slug}/star")
public ResponseEntity<RecipeStar> addStar(
@PathVariable String username,

View File

@ -1,63 +0,0 @@
package app.mealsmadeeasy.api.recipe;
import jakarta.persistence.*;
import org.hibernate.annotations.Array;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;
import org.jetbrains.annotations.Nullable;
import java.time.OffsetDateTime;
@Entity
@Table(name = "recipe_embedding")
public class RecipeEmbeddingEntity {
@Id
private Integer id;
@OneToOne(fetch = FetchType.LAZY, optional = false)
@MapsId
@JoinColumn(name = "recipe_id")
private RecipeEntity recipe;
@JdbcTypeCode(SqlTypes.VECTOR)
@Array(length = 1024)
@Nullable
private float[] embedding;
@Column(nullable = false)
private OffsetDateTime timestamp;
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public RecipeEntity getRecipe() {
return this.recipe;
}
public void setRecipe(RecipeEntity recipe) {
this.recipe = recipe;
}
public float[] getEmbedding() {
return this.embedding;
}
public void setEmbedding(float[] embedding) {
this.embedding = embedding;
}
public OffsetDateTime getTimestamp() {
return this.timestamp;
}
public void setTimestamp(OffsetDateTime timestamp) {
this.timestamp = timestamp;
}
}

View File

@ -78,9 +78,6 @@ public final class RecipeEntity implements Recipe {
@JoinColumn(name = "main_image_id")
private S3ImageEntity mainImage;
@OneToOne(mappedBy = "recipe", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
private RecipeEmbeddingEntity embedding;
@Override
public Integer getId() {
return this.id;
@ -241,12 +238,4 @@ public final class RecipeEntity implements Recipe {
this.mainImage = image;
}
public RecipeEmbeddingEntity getEmbedding() {
return this.embedding;
}
public void setEmbedding(RecipeEmbeddingEntity embedding) {
this.embedding = embedding;
}
}

View File

@ -41,34 +41,4 @@ public interface RecipeRepository extends JpaRepository<RecipeEntity, Long> {
@Query("SELECT r FROM Recipe r WHERE r.isPublic OR r.owner = ?1 OR ?1 MEMBER OF r.viewers")
Slice<RecipeEntity> findAllViewableBy(UserEntity viewer, Pageable pageable);
List<RecipeEntity> findAllByEmbeddingIsNull();
@Query(
nativeQuery = true,
value = """
WITH distances AS (SELECT recipe_id, embedding <=> cast(?1 AS vector) AS distance FROM recipe_embedding)
SELECT r.* FROM distances d
INNER JOIN recipe r ON r.id = d.recipe_id
WHERE d.distance < ?2 AND (
r.is_public = TRUE
OR r.owner_id = ?3
OR exists(SELECT 1 FROM recipe_viewer v WHERE v.recipe_id = r.id AND v.viewer_id = ?3)
)
ORDER BY d.distance;
"""
)
List<RecipeEntity> searchByEmbeddingAndViewableBy(float[] queryEmbedding, float similarity, Integer viewerId);
@Query(
nativeQuery = true,
value = """
WITH distances AS (SELECT recipe_id, embedding <=> cast(?1 AS vector) AS distance FROM recipe_embedding)
SELECT r.* FROM distances d
INNER JOIN recipe r ON r.id = d.recipe_id
WHERE d.distance < ?2 AND r.is_public = TRUE
ORDER BY d.distance;
"""
)
List<RecipeEntity> searchByEmbeddingAndIsPublic(float[] queryEmbedding, float similarity);
}

View File

@ -1,13 +1,11 @@
package app.mealsmadeeasy.api.recipe;
import app.mealsmadeeasy.api.image.ImageException;
import app.mealsmadeeasy.api.recipe.spec.RecipeAiSearchSpec;
import app.mealsmadeeasy.api.recipe.spec.RecipeCreateSpec;
import app.mealsmadeeasy.api.recipe.spec.RecipeUpdateSpec;
import app.mealsmadeeasy.api.recipe.view.FullRecipeView;
import app.mealsmadeeasy.api.recipe.view.RecipeInfoView;
import app.mealsmadeeasy.api.user.User;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
import org.springframework.data.domain.Pageable;
@ -37,8 +35,6 @@ public interface RecipeService {
List<Recipe> getRecipesViewableBy(User viewer);
List<Recipe> getRecipesOwnedBy(User owner);
List<RecipeInfoView> aiSearch(RecipeAiSearchSpec searchSpec, @Nullable User viewer);
Recipe update(String username, String slug, RecipeUpdateSpec spec, User modifier)
throws RecipeException, ImageException;
@ -57,7 +53,4 @@ public interface RecipeService {
@Contract("_, _, null -> null")
@Nullable Boolean isOwner(String username, String slug, @Nullable User viewer);
@ApiStatus.Internal
String getRenderedMarkdown(RecipeEntity entity);
}

View File

@ -6,7 +6,6 @@ import app.mealsmadeeasy.api.image.ImageService;
import app.mealsmadeeasy.api.image.S3ImageEntity;
import app.mealsmadeeasy.api.image.view.ImageView;
import app.mealsmadeeasy.api.markdown.MarkdownService;
import app.mealsmadeeasy.api.recipe.spec.RecipeAiSearchSpec;
import app.mealsmadeeasy.api.recipe.spec.RecipeCreateSpec;
import app.mealsmadeeasy.api.recipe.spec.RecipeUpdateSpec;
import app.mealsmadeeasy.api.recipe.star.RecipeStarRepository;
@ -14,10 +13,8 @@ import app.mealsmadeeasy.api.recipe.view.FullRecipeView;
import app.mealsmadeeasy.api.recipe.view.RecipeInfoView;
import app.mealsmadeeasy.api.user.User;
import app.mealsmadeeasy.api.user.UserEntity;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.security.access.AccessDeniedException;
@ -37,20 +34,17 @@ public class RecipeServiceImpl implements RecipeService {
private final RecipeStarRepository recipeStarRepository;
private final ImageService imageService;
private final MarkdownService markdownService;
private final EmbeddingModel embeddingModel;
public RecipeServiceImpl(
RecipeRepository recipeRepository,
RecipeStarRepository recipeStarRepository,
ImageService imageService,
MarkdownService markdownService,
EmbeddingModel embeddingModel
MarkdownService markdownService
) {
this.recipeRepository = recipeRepository;
this.recipeStarRepository = recipeStarRepository;
this.imageService = imageService;
this.markdownService = markdownService;
this.embeddingModel = embeddingModel;
}
@Override
@ -99,9 +93,7 @@ public class RecipeServiceImpl implements RecipeService {
));
}
@Override
@ApiStatus.Internal
public String getRenderedMarkdown(RecipeEntity entity) {
private String getRenderedMarkdown(RecipeEntity entity) {
if (entity.getCachedRenderedText() == null) {
entity.setCachedRenderedText(this.markdownService.renderAndCleanMarkdown(entity.getRawText()));
entity = this.recipeRepository.save(entity);
@ -199,20 +191,6 @@ public class RecipeServiceImpl implements RecipeService {
return List.copyOf(this.recipeRepository.findAllByOwner((UserEntity) owner));
}
@Override
public List<RecipeInfoView> aiSearch(RecipeAiSearchSpec searchSpec, @Nullable User viewer) {
final float[] queryEmbedding = this.embeddingModel.embed(searchSpec.getPrompt());
final List<RecipeEntity> results;
if (viewer == null) {
results = this.recipeRepository.searchByEmbeddingAndIsPublic(queryEmbedding, 0.5f);
} else {
results = this.recipeRepository.searchByEmbeddingAndViewableBy(queryEmbedding, 0.5f, viewer.getId());
}
return results.stream()
.map(recipeEntity -> this.getInfoView(recipeEntity, viewer))
.toList();
}
@Override
@PreAuthorize("@recipeSecurity.isOwner(#username, #slug, #modifier)")
public Recipe update(String username, String slug, RecipeUpdateSpec spec, User modifier)

View File

@ -1,30 +0,0 @@
package app.mealsmadeeasy.api.recipe.body;
import java.util.Map;
public class RecipeSearchBody {
public enum Type {
AI_PROMPT
}
private Type type;
private Map<String, Object> data;
public Type getType() {
return this.type;
}
public void setType(Type type) {
this.type = type;
}
public Map<String, Object> getData() {
return this.data;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
}

View File

@ -1,15 +0,0 @@
package app.mealsmadeeasy.api.recipe.spec;
public class RecipeAiSearchSpec {
private String prompt;
public String getPrompt() {
return this.prompt;
}
public void setPrompt(String prompt) {
this.prompt = prompt;
}
}

View File

@ -1,7 +1,6 @@
package app.mealsmadeeasy.api.security;
import app.mealsmadeeasy.api.jwt.JwtService;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.JwtException;
import jakarta.servlet.FilterChain;
@ -19,6 +18,7 @@ import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import tools.jackson.databind.ObjectMapper;
import java.io.IOException;

View File

@ -33,7 +33,7 @@ public class SecurityConfiguration {
}
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) {
httpSecurity.authorizeHttpRequests(requests -> requests.anyRequest().permitAll());
httpSecurity.csrf(AbstractHttpConfigurer::disable);
httpSecurity.cors(Customizer.withDefaults());

View File

@ -16,6 +16,3 @@ app.mealsmadeeasy.api.minio.endpoint=http://${MINIO_HOST:localhost}:${MINIO_PORT
app.mealsmadeeasy.api.minio.accessKey=${MINIO_ROOT_USER}
app.mealsmadeeasy.api.minio.secretKey=${MINIO_ROOT_PASSWORD}
app.mealsmadeeasy.api.images.bucketName=images
# AI
spring.ai.vectorstore.pgvector.dimensions=1024

View File

@ -1 +0,0 @@
CREATE EXTENSION vector;

View File

@ -1,7 +0,0 @@
CREATE TABLE recipe_embedding (
recipe_id INT NOT NULL,
timestamp TIMESTAMPTZ(6) NOT NULL,
embedding VECTOR(1024),
PRIMARY KEY (recipe_id),
FOREIGN KEY (recipe_id) REFERENCES recipe ON DELETE CASCADE
);