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 = "tinyllama";

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 "tinyllama" \
--input "['Why is the sky blue?','Why is the grass green?']" \
--headers "{'Authorization':'***'}"
Result
{
"model": "tinyllama",
"embeddings": [
[
0.006567801,
0.017120766,
-0.021233078,
-0.00071872346,
-0.008213052,
-0.001771016,
0.03765172,
-0.04352719,
0.019900957,
0.0134296445,
0.0016286174,
0.0056792665,
-0.003862323,
0.00542662,
0.000581516,
0.028417204,
0.005597418,
-0.0061729737,
-0.013061436,
0.012481694,
0.0062368955,
0.01467892,
0.008914758,
0.019255377,
-0.013752533,
-0.017215604,
0.007988796,
-0.009675451,
-0.009591684,
-0.010658318,
-0.050292917,
-0.06933649,
0.02217853,
0.011071725,
0.002628688,
0.06139993,
0.020888343,
-0.00075766706,
-0.016858619,
0.021615649,
-0.0014523858,
0.029499304,
0.0016150207,
-0.0110375,
-0.031718228,
-0.0047946484,
-0.015021475,
-0.021662567,
-0.019978186,
0.012649324,
0.026452394,
-0.012192569,
-0.01574544,
-0.0141633665,
0.01589783,
-0.008814906,
0.019047515,
0.014005591,
0.018277107,
0.0027028804,
-0.014426378,
-0.040070668,
0.009694338,
-0.0060418397,
0.0042678732,
0.0127479145,
0.003752015,
-0.02211856,
-0.00479138,
0.005974252,
-0.037253555,
0.0008083566,
-0.0031136523,
-0.030845378,
0.010942472,
0.025139084,
-0.00165144,
-0.016407365,
0.0020046276,
0.00014505222,
0.013110961,
0.018136261,
0.015896736,
0.01758994,
0.0068580583,
0.0068650576,
0.0045976713,
-0.0010780791,
-0.0039052044,
0.013587107,
-0.025456522,
0.010030832,
-0.00016159813,
0.025927372,
0.008783384,
-0.021077346,
-0.02474387,
0.0061034793,
-0.003990975,
-0.01315375,
0.00446011,
0.01724706,
-0.013162027,
0.0065136547,
-0.0043413267,
0.00590098,
-0.01829046,
0.011613089,
0.031036222,
0.011892632,
0.027967649,
-0.0031644995,
0.06676259,
-0.0068227155,
0.000621177,
0.0024983408,
-0.023144135,
-0.0031124877,
0.0045454237,
-0.015090792,
-0.025370236,
0.009406088,
-0.0149791865,
-0.00016507473,
-0.02823981,
0.012637605,
-0.00068884,
0.004953009,
0.020397333,
-0.005005641,
-0.035857968,
-0.0167443,
-0.007977171,
-0.0041365717,
-0.0030276233,
-0.036033098,
0.022056058,
0.02876913,
-0.011989511,
0.0072020018,
0.020037673,
-0.0034762,
-0.0097052455,
-0.035286386,
0.0060704523,
-0.016847983,
...