-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from BlackyDrum/embedding-functions
Embedding functions
- Loading branch information
Showing
15 changed files
with
317 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
#include "ChromaDB/Embeddings/EmbeddingFunction.h" | ||
|
||
namespace chromadb { | ||
|
||
class CohereEmbeddingFunction : public EmbeddingFunction | ||
{ | ||
public: | ||
/* | ||
* @brief Construct a new CohereEmbeddingFunction object | ||
* | ||
* @param apiKey The API key | ||
* @param model The model to use (optional) | ||
* @param inputType The input type (optional) | ||
* @param baseUrl The base URL of the server (optional) | ||
* @param path The path of the endpoint (optional) | ||
*/ | ||
CohereEmbeddingFunction(const std::string& apiKey, const std::string& model = "embed-english-v3.0", const std::string& inputType = "classification", const std::string & baseUrl = "api.cohere.com", const std::string & path = "/v1/embed"); | ||
|
||
/* | ||
* @brief Generate the embeddings of the documents | ||
* | ||
* @param documents The documents to generate the embeddings | ||
* | ||
* @return std::vector<std::vector<double>> The embeddings of the documents | ||
* | ||
* @throw ChromaException if something goes wrong | ||
*/ | ||
std::vector<std::vector<double>> Generate(const std::vector<std::string>& documents); | ||
|
||
private: | ||
std::string m_InputType; | ||
}; | ||
|
||
} // namespace chromadb |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include "ChromaDB/Embeddings/EmbeddingFunction.h" | ||
|
||
namespace chromadb { | ||
|
||
class TogetherAIEmbeddingFunction : public EmbeddingFunction | ||
{ | ||
public: | ||
/* | ||
* @brief Construct a new TogetherAIEmbeddingFunction object | ||
* | ||
* @param apiKey The API key | ||
* @param model The model to use (optional) | ||
* @param baseUrl The base URL of the server (optional) | ||
* @param path The path of the endpoint (optional) | ||
*/ | ||
TogetherAIEmbeddingFunction(const std::string& apiKey, const std::string& model = "togethercomputer/m2-bert-80M-8k-retrieval", const std::string& baseUrl = "api.together.xyz", const std::string& path = "/v1/embeddings"); | ||
|
||
/* | ||
* @brief Generate the embeddings of the documents | ||
* | ||
* @param documents The documents to generate the embeddings | ||
* | ||
* @return std::vector<std::vector<double>> The embeddings of the documents | ||
* | ||
* @throw ChromaException if something goes wrong | ||
*/ | ||
std::vector<std::vector<double>> Generate(const std::vector<std::string>& documents); | ||
}; | ||
|
||
} // namespace chromadb |
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,36 @@ | ||
#pragma once | ||
|
||
#include "ChromaDB/Embeddings/EmbeddingFunction.h" | ||
|
||
namespace chromadb { | ||
|
||
class VoyageAIEmbeddingFunction : public EmbeddingFunction | ||
{ | ||
public: | ||
/* | ||
* @brief Construct a new VoyageAIEmbeddingFunction object | ||
* | ||
* @param apiKey The API key | ||
* @param model The model to use (optional) | ||
* @param inputType The input type (optional) | ||
* @param baseUrl The base URL of the server (optional) | ||
* @param path The path of the endpoint (optional) | ||
*/ | ||
VoyageAIEmbeddingFunction(const std::string& apiKey, const std::string& model = "voyage-2", const std::string& inputType = "document", const std::string& baseUrl = "api.voyageai.com", const std::string& path = "/v1/embeddings"); | ||
|
||
/* | ||
* @brief Generate the embeddings of the documents | ||
* | ||
* @param documents The documents to generate the embeddings | ||
* | ||
* @return std::vector<std::vector<double>> The embeddings of the documents | ||
* | ||
* @throw ChromaException if something goes wrong | ||
*/ | ||
std::vector<std::vector<double>> Generate(const std::vector<std::string>& documents); | ||
|
||
private: | ||
std::string m_InputType; | ||
}; | ||
|
||
} // namespace chromadb |
12 changes: 12 additions & 0 deletions
12
include/ChromaDB/Exceptions/External/EmbeddingProviderConnectionException.h
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,12 @@ | ||
#pragma once | ||
|
||
#include "ChromaDB/Exceptions/ChromaException.h" | ||
|
||
namespace chromadb { | ||
|
||
class EmbeddingProviderConnectionException : public ChromaException | ||
{ | ||
using ChromaException::ChromaException; | ||
}; | ||
|
||
} // namespace chromadb |
12 changes: 12 additions & 0 deletions
12
include/ChromaDB/Exceptions/External/EmbeddingProviderRequestException.h
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,12 @@ | ||
#pragma once | ||
|
||
#include "ChromaDB/Exceptions/ChromaException.h" | ||
|
||
namespace chromadb { | ||
|
||
class EmbeddingProviderRequestException : public ChromaException | ||
{ | ||
using ChromaException::ChromaException; | ||
}; | ||
|
||
} // namespace chromadb |
Oops, something went wrong.