Closed primaryobjects closed 2 months ago
Thanks for bringing this to my attention - I've just released version 3.1.3 with Cohere Embeddings support.
The first snippet should now be:
string apiKey = "<API_KEY>";
TornadoApi api = new([new ProviderAuthentication(LLmProviders.Cohere, apiKey)]);
float[] result = await api.Embeddings.Embeddings.GetEmbeddings(EmbeddingModel.Cohere.Gen3.Multilingual, "lorem ipsum");
To specify input_type
and truncate
:
EmbeddingResult? result = await api.Embeddings.CreateEmbedding(EmbeddingModel.Cohere.Gen3.Multilingual, "lorem ipsum", new EmbeddingRequestVendorExtensions
{
Cohere = new EmbeddingRequestVendorCohereExtensions
{
InputType = EmbeddingVendorCohereExtensionInputTypes.Classification,
Truncate = EmbeddingVendorCohereExtensionTruncation.End
}
});
Multiple inputs can be passed at once (as in your last snippet):
EmbeddingResult? result = await api.Embeddings.CreateEmbedding(EmbeddingModel.Cohere.Gen3.Multilingual, [ "lorem ipsum", "dolor sit amet" ], new EmbeddingRequestVendorExtensions
{
Cohere = new EmbeddingRequestVendorCohereExtensions
{
InputType = EmbeddingVendorCohereExtensionInputTypes.Classification,
Truncate = EmbeddingVendorCohereExtensionTruncation.End
}
});
Please let me know if you run into any further issues, thanks!
Hi, there may be an issue with the Cohere Embedding API, not providing the correct request headers. It appears to be calling
platform.openai.com
instead ofcohere
.Example of code that fails
Output
Note, You can obtain an API key from https://platform.openai.com/account/api-keys. when the provider is Cohere.
Workaround using HttpRequest
Output