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://api.athenaeum.digital/ollama";
Token = "10KO-82..."; // 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"]);

// ...
    # JSON data can also be passed as a path to a .json file

oint ollama GetContextResponse \
--url "https://api.athenaeum.digital/ollama" \
--model "tinyllama" \
--msgs "[{'role':'user','content':'What is 1C:Enterprise?'},{'role':'assistant','content':'1C:Enterprise is a comprehensive accounting software developed and sold by HRH Software, an Austrian software company headquartered in Graz. It has been in use since the early 1980s, and currently serves millions of users worldwide. The software offers various modules such as accounts receivable, accounts payable, inventory management, order entry, project accounting, general ledger, and financial reporting. It also includes customizable solutions for businesses\u0027 specific needs, such as sales tax compliance, procurement, and expense tracking. 1C:Enterprise is known for its user-friendliness, accuracy, efficiency, and scalability.'},{'role':'user','content':'When the first version was released?'}]" \
--headers "{'Authorization':'***'}"
Result
{
"model": "tinyllama",
"created_at": "2025-05-01T06:46:43.0816524Z",
"message": {
"role": "assistant",
"content": "1C:Enterprise has been around since 2004. The first release, which is called Version 3, was released in 2005, and it brought some significant changes to the system that have remained constant through the years. The latest version, 6, was released in 2019 and is still in active development. Some of the most notable features in recent versions include:\n\n- Improved interface for users, with a more modern design and streamlined navigation\n- Enhanced reporting functionality to provide more detailed insights into business performance and key areas for improvement\n- Integration with popular accounting software such as Xero and Sage\n- Support for multilingual environments, with options for French, German, Spanish, Italian, Japanese, and Korean.\n\nOverall, 1C:Enterprise has remained a reliable and stable ERP solution for businesses for many years, and new updates and features are released regularly to keep the system up to date and relevant in today's market."
},
"done_reason": "stop",
"done": true,
"total_duration": 48411004700,
"load_duration": 14000500,
"prompt_eval_count": 194,
"prompt_eval_duration": 13206002400,
"eval_count": 216,
"eval_duration": 35186999300
}