Skip to content

Commit

Permalink
feat : removes deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Dec 28, 2024
1 parent dfb1aec commit 2e8664e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ AIChatResponse sentimentAnalyzer(@RequestBody AIChatRequest aiChatRequest) {
return chatService.analyzeSentiment(aiChatRequest.query());
}

// @PostMapping("/emebedding-client-conversion")
// AIChatResponse chatWithEmbeddingClient(@RequestBody AIChatRequest aiChatRequest) {
// return chatService.getEmbeddings(aiChatRequest.query());
// }
//
@PostMapping("/emebedding-client-conversion")
AIChatResponse chatWithEmbeddingClient(@RequestBody AIChatRequest aiChatRequest) {
return chatService.getEmbeddings(aiChatRequest.query());
}

@GetMapping("/output")
public ActorsFilms generate(@RequestParam(value = "actor", defaultValue = "Jr NTR") String actor) {
return chatService.generateAsBean(actor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.example.ai.model.response.AIChatResponse;
import com.example.ai.model.response.ActorsFilms;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -75,11 +76,11 @@ public AIChatResponse analyzeSentiment(String query) {
return new AIChatResponse(answer);
}

// public AIChatResponse getEmbeddings(String query) {
// List<Double> embed = embeddingClient.embed(query);
// return new AIChatResponse(embed.toString());
// }
//
public AIChatResponse getEmbeddings(String query) {
float[] embedded = embeddingModel.embed(query);
return new AIChatResponse(Arrays.toString(embedded));
}

public ActorsFilms generateAsBean(String actor) {
BeanOutputConverter<ActorsFilms> outputParser = new BeanOutputConverter<>(ActorsFilms.class);

Expand Down
4 changes: 2 additions & 2 deletions embeddingstores/neo4j-springai/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ services:
container_name: neo4j
image: neo4j:latest
ports:
- 7474:7474
- 7687:7687
- "7474:7474"
- "7687:7687"
environment:
- NEO4J_AUTH=neo4j/password
- NEO4J_apoc_export_file_enabled=true
Expand Down
2 changes: 1 addition & 1 deletion embeddingstores/neo4j-springai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<configuration>
<java>
<palantirJavaFormat>
<version>2.47.0</version>
<version>2.50.0</version>
</palantirJavaFormat>
<importOrder />
<removeUnusedImports />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public void storeEmbeddings() {
public AIChatResponse queryEmbeddingStore(String question) {
try {
// Retrieve embeddings
SearchRequest query = SearchRequest.query(question).withTopK(1);
SearchRequest query =
SearchRequest.builder().query(question).topK(1).build();
List<Document> similarDocuments = vectorStore.similaritySearch(query);

if (similarDocuments.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public void storeEmbeddings() {

public AIChatResponse queryEmbeddingStore(String question, Integer userId) {
// Retrieve embeddings
SearchRequest query = SearchRequest.query(question).withTopK(1);
var queryBuilder = SearchRequest.builder().query(question).topK(1);
if (userId != null) {
query.withFilterExpression("userId == " + userId);
queryBuilder.filterExpression("userId == " + userId);
}
List<Document> similarDocuments = vectorStore.similaritySearch(query);
List<Document> similarDocuments = vectorStore.similaritySearch(queryBuilder.build());
String relevantData =
similarDocuments.stream().map(Document::getContent).collect(Collectors.joining(System.lineSeparator()));
similarDocuments.stream().map(Document::getText).collect(Collectors.joining(System.lineSeparator()));

LOGGER.info("response from vectorStore : {} ", relevantData);
return new AIChatResponse(relevantData);
Expand Down

0 comments on commit 2e8664e

Please sign in to comment.