You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-12-03 22:39:12 +02:00
110 lines
4.1 KiB
Plaintext
Vendored
110 lines
4.1 KiB
Plaintext
Vendored
---
|
|
sidebar_position: 3
|
|
description: Get context response and other functions to work with Ollama in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
|
|
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, Ollama]
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
# 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`
|
|
|
|
| Parameter | CLI option | Type | Required | Description |
|
|
|-|-|-|-|-|
|
|
| URL | --url | String | ✔ | Ollama server URL |
|
|
| Model | --model | String | ✔ | Models name |
|
|
| Messages | --msgs | Array of Structure | ✔ | Messages log. See GetContextMessageStructure |
|
|
| AdditionalParameters | --options | Structure Of KeyAndValue | ✖ | Additional parameters. See GetRequestParametersStructure |
|
|
| AdditionalHeaders | --headers | Map Of KeyAndValue | ✖ | Additional request headers, if necessary |
|
|
|
|
|
|
Returns: Map Of KeyAndValue - Processing result
|
|
|
|
<br/>
|
|
|
|
:::tip
|
|
Method at API documentation: [Generate a chat completion](https://github.com/ollama/ollama/blob/main/docs/api.md#generate-a-chat-completion)
|
|
:::
|
|
<br/>
|
|
|
|
|
|
```bsl title="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"]);
|
|
|
|
// ...
|
|
```
|
|
|
|
|
|
<Tabs>
|
|
|
|
<TabItem value="bash" label="Bash" default>
|
|
```bash
|
|
oint ollama GetContextResponse \
|
|
--url ""https://hut.openintegrations.dev/ollama"" \
|
|
--model ""tinyllama"" \
|
|
--msgs ""[{'role':'user','content':'Hello!'}]"" \
|
|
--options ""/tmp/jslyarye.ngt.json"" \
|
|
--headers "{'Authorization':'***'}"
|
|
```
|
|
</TabItem>
|
|
|
|
<TabItem value="bat" label="CMD/Bat" default>
|
|
```batch
|
|
oint ollama GetContextResponse ^
|
|
--url ""https://hut.openintegrations.dev/ollama"" ^
|
|
--model ""tinyllama"" ^
|
|
--msgs ""[{'role':'user','content':'Hello!'}]"" ^
|
|
--options ""/tmp/jslyarye.ngt.json"" ^
|
|
--headers "{'Authorization':'***'}"
|
|
```
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
|
|
```json title="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
|
|
}
|
|
```
|