Skip to main content

Get context response

Receives the next response from the model according to the message history

Function GetContextResponse(Val URL, Val Model, Val Messages, Val AdditionalParameters = "", Val AdditionalHeaders = "") Export

ParameterCLI optionTypeRequiredDescription
URL--urlStringOllama server URL
Model--modelStringModels name
Messages--msgsArray of StructureMessages log. See GetContextMessageStructure
AdditionalParameters--optionsStructure Of KeyAndValueAdditional parameters. See GetRequestParametersStructure
AdditionalHeaders--headersMap Of KeyAndValueAdditional request headers, if necessary

Returns: Map Of KeyAndValue - Processing result


tip

Method at API documentation: Generate a chat completion


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

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

Model = "tinyllama";

MessagesArray = New Array;

Question1 = OPI_Ollama.GetContextMessageStructure("user", "What is 1C:Enterprise?");
Question2 = OPI_Ollama.GetContextMessageStructure("user", "When the first version was released?"); // Question without specifics

// Adding the first question to the context
MessagesArray.Add(Question1);

Response1 = OPI_Ollama.GetContextResponse(URL, Model, MessagesArray, , AdditionalHeaders);

MessagesArray.Add(Response1["message"]); // Add response to first question in context
MessagesArray.Add(Question2); // Add second question in context

Response2 = OPI_Ollama.GetContextResponse(URL, Model, MessagesArray, , AdditionalHeaders);

MessagesArray.Add(Response2["message"]);

// ...
    oint ollama GetContextResponse \
--url ""https://hut.openintegrations.dev/ollama"" \
--model ""tinyllama"" \
--msgs ""[{'role':'user','content':'Hello!'}]"" \
--options ""/tmp/jslyarye.ngt.json"" \
--headers "{'Authorization':'***'}"
Result
{
"model": "tinyllama",
"created_at": "2025-09-16T00:16:33.602488485Z",
"message": {
"role": "assistant",
"content": "Yes, the first version of 1C:Enterprise was released in 2005. However, the platform has undergone several major versions since then, each bringing new features and improvements to the software. The latest version available as of writing is 14, which was released in April 2021. The upgrade process involves downloading and installing updates that enhance functionality, fix bugs, and improve performance, as well as adding new features and capabilities based on customer feedback and market trends."
},
"done_reason": "stop",
"done": true,
"total_duration": 14043467332,
"load_duration": 16572316,
"prompt_eval_count": 233,
"prompt_eval_duration": 5708390784,
"eval_count": 106,
"eval_duration": 8311980284
}