-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: added embedding search fucntion to store
also cleaned up some code
- Loading branch information
Showing
8 changed files
with
58 additions
and
50 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...va/com/theagilemonkeys/ellmental/core/errors/EnvironmentVariableNotDeclaredException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.theagilemonkeys.ellmental.core.errors; | ||
|
||
|
||
public class EnvironmentVariableNotDeclaredException extends RuntimeException { | ||
public EnvironmentVariableNotDeclaredException(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 8 additions & 9 deletions
17
examples/simplejava/src/main/java/com/theagilemonkeys/ellmental/helloworld/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
package com.theagilemonkeys.ellmental.helloworld; | ||
|
||
import com.theagilemonkeys.ellmental.core.schema.Embedding; | ||
import com.theagilemonkeys.examplemodule.PrintHelloLibrary; | ||
import com.theagilemonkeys.ellmental.embeddingsgeneration.openai.OpenAIEmbeddingsModel; | ||
import com.theagilemonkeys.ellmental.embeddingsstore.EmbeddingsStore; | ||
import com.theagilemonkeys.ellmental.embeddingsstore.pinecone.PineconeEmbeddingsStore; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.List; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
// Step 1: generate embeddings from input string | ||
OpenAIEmbeddingsModel openAI = new OpenAIEmbeddingsModel(); | ||
Embedding embedding = openAI.generateEmbedding("Test"); | ||
|
||
|
||
EmbeddingsStore embeddingStore = new PineconeEmbeddingsStore(); | ||
|
||
Map<String, String> metadata = new HashMap<>(); | ||
metadata.put("key1", "value1"); | ||
metadata.put("key2", "value2"); | ||
|
||
|
||
// Step 2: save the generated embeddings to a store (Pinecone in this case) | ||
EmbeddingsStore embeddingStore = new PineconeEmbeddingsStore(); | ||
embeddingStore.store(embedding, metadata); | ||
|
||
PrintHelloLibrary a = new PrintHelloLibrary(); | ||
a.printHello(); | ||
// Step 3: search for the embedding in the store | ||
List<Embedding> searchEmbeddings = embeddingStore.similaritySearch(embedding, 5); | ||
|
||
System.out.println("Embedding generation and storage finished."); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters