Skip to main content

Get embeddings

Gets the embeddings for the given entries

Function GetEmbeddings(Val URL, Val Model, Val Question, Val AdditionalParameters = "", Val AdditionalHeaders = "") Export

ParameterCLI optionTypeRequiredDescription
URL--urlStringOllama server URL
Model--modelStringModels name
Question--inputArray Of StringString or array of request strings
AdditionalParameters--optionsStructure Of KeyAndValueAdditional parameters. See GetEmbeddingsParameterStructure
AdditionalHeaders--headersMap Of KeyAndValueAdditional request headers, if necessary
Returns

Map Of KeyAndValue - Processing result

tip

Method at API documentation: Generate Embeddings


1C:Enterprise/OneScript code example
URL = "https://hut.openintegrations.dev/ollama";
Token = "12We34..."; // Authorization - not part API Ollama

StingsArray = New Array;
StingsArray.Add("Why is the sky blue?");
StingsArray.Add("Why is the grass green?");

Model = "nomic-embed-text-v2-moe";

AdditionalHeaders = New Map;
AdditionalHeaders.Insert("Authorization", StrTemplate("Bearer %1", Token));

Result = OPI_Ollama.GetEmbeddings(URL, Model, StingsArray, , AdditionalHeaders);
# JSON data can also be passed as a path to a .json file

oint ollama GetEmbeddings \
--url "https://hut.openintegrations.dev/ollama" \
--model "nomic-embed-text-v2-moe" \
--input "['Why is the sky blue?','Why is the grass green?']" \
--headers "{'Authorization':'***'}"
Result
{
"model": "nomic-embed-text-v2-moe",
"embeddings": [
[
-0.023377083,
-0.039815597,
-0.026976615,
-0.040000755,
0.037415713,
-0.045650277,
0.056364704,
0.013559645,
0.015879741,
0.0711201,
0.046037834,
-0.086130954,
0.024833031,
-0.01432908,
0.023052258,
0.04044247,
0.016339744,
-0.05005762,
-0.016876565,
-0.014787036,
0.049448553,
0.019526914,
-0.06560645,
-0.04175051,
-0.02843286,
0.05182565,
0.012752147,
-0.0016665044,
0.038716365,
0.051535368,
0.00584156,
0.0007755707,
0.022913434,
0.06392446,
-0.038003724,
-0.033234283,
-0.066329926,
-0.08037679,
0.042263642,
0.016748663,
0.01418123,
0.013457093,
0.011624278,
0.014238991,
-0.013748628,
0.051531993,
0.021072157,
0.07569989,
0.02140503,
-0.06919649,
0.0039464603,
-0.012791496,
-0.046320725,
-0.007195886,
0.007779556,
-0.06134129,
-0.01374209,
-0.040604148,
0.028345661,
-0.04747942,
0.0061556827,
0.014106248,
0.09201862,
0.0015398758,
-0.009631331,
-0.0038964436,
0.03682363,
-0.035839166,
-0.03807238,
0.055670027,
-0.0013260737,
0.025252676,
0.0037467296,
0.07565882,
-0.047345232,
-0.037063956,
-0.024034323,
0.028335493,
-0.09239901,
0.042268574,
0.011507675,
-0.044367682,
0.009322365,
-0.030236725,
0.012708565,
-0.018103514,
-0.082024276,
-0.01809269,
0.019340228,
-0.01222963,
-0.009168237,
-0.0027882208,
0.05474164,
0.025428774,
0.032191265,
-0.012124515,
0.003760471,
0.014201002,
-0.0065245545,
0.02200837,
0.03048284,
0.08725099,
0.024240285,
0.058888808,
-0.07347328,
0.0616408,
0.016072467,
-0.011010588,
0.10297248,
0.02999366,
-0.030772947,
0.00765894,
0.010290124,
-0.043413114,
0.0110719,
-0.05654556,
0.02350074,
-0.035292085,
0.014546188,
0.025833452,
0.007843072,
0.03613608,
-0.035433687,
0.0025724492,
0.011019124,
-0.00057252217,
-0.07885687,
0.046548493,
0.021734599,
0.01884446,
0.01435122,
-0.0664635,
0.0505971,
-0.028974326,
-0.01983977,
-0.05966596,
0.01958118,
-0.020545477,
-0.05370811,
0.008216748,
-0.088197105,
-0.035971634,
0.038610596,
-0.03593245,
-0.059190493,
-0.0145298075,
...