forked from TheoKanning/openai-java
-
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.
Fixes TheoKanning#469: Pass dimensions in EmbeddingRequest
- Loading branch information
1 parent
48694ba
commit 9a9ae7b
Showing
5 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
api/src/main/java/com/theokanning/openai/embedding/EmbeddingModel.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,59 @@ | ||
package com.theokanning.openai.embedding; | ||
|
||
/** | ||
* Enum to represent the available OpenAI embedding models | ||
*/ | ||
public enum EmbeddingModel { | ||
|
||
TEXT_EMBEDDING_ADA_002("text-embedding-ada-002", 2), | ||
TEXT_EMBEDDING_V3_SMALL("text-embedding-3-small", 3), | ||
TEXT_EMBEDDING_V3_LARGE("text-embedding-3-large", 3), | ||
; | ||
|
||
private final String modelName; | ||
private final Integer generation; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param modelName the value of the enum | ||
*/ | ||
EmbeddingModel(String modelName, Integer generation) { | ||
this.modelName = modelName; | ||
this.generation = generation; | ||
} | ||
|
||
/** | ||
* Method to return enum from a string value. | ||
* | ||
* @param value the value to convert to an enum | ||
* @return the enum value | ||
*/ | ||
public static EmbeddingModel fromValue(String value) { | ||
for (EmbeddingModel b : EmbeddingModel.values()) { | ||
if (b.modelName.equals(value)) { | ||
return b; | ||
} | ||
} | ||
throw new IllegalArgumentException("Unexpected value '" + value + "'"); | ||
} | ||
|
||
/** | ||
* Method to return the value of the enum. | ||
* | ||
* @return the value of the enum | ||
*/ | ||
public Integer getGeneration() { | ||
return generation; | ||
} | ||
|
||
/** | ||
* Method to return the value of the enum. | ||
* | ||
* @return the value of the enum | ||
*/ | ||
@Override | ||
public String toString() { | ||
return modelName; | ||
} | ||
} |
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