1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-11-27 22:18:36 +02:00
Files
OpenIntegrations/docs/en/md/Ollama/Requests-processing/Get-response.mdx
Vitaly the Alpaca (bot) 50e6ac2e6d Main build (Jenkins)
2025-09-15 13:14:53 +03:00

257 lines
4.8 KiB
Plaintext
Vendored

---
sidebar_position: 2
description: Get 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 response
Generates a response for a given text query
`Function GetResponse(Val URL, Val Model, Val Question, Val AdditionalParameters = "", Val AdditionalHeaders = "") Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| URL | --url | String | ✔ | Ollama server URL |
| Model | --model | String | ✔ | Models name |
| Question | --prompt | String | ✔ | Request text |
| 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 completion](https://github.com/ollama/ollama/blob/main/docs/api.md#generate-a-completion)
:::
<br/>
```bsl title="1C:Enterprise/OneScript code example"
URL = "https://hut.openintegrations.dev/ollama";
Token = "12We34..."; // Authorization - not part API Ollama
Prompt = "What is 1C:Enterprise?";
Model = "tinyllama";
AdditionalHeaders = New Map;
AdditionalHeaders.Insert("Authorization", StrTemplate("Bearer %1", Token));
Result = OPI_Ollama.GetResponse(URL, Model, Prompt, , AdditionalHeaders);
// With paramether
Prompt = "Ollama is 22 years old and is busy saving the world. Respond using JSON";
Format = OPI_Tools.JSONToStructure("
|{
|""type"": ""object"",
|""properties"": {
| ""age"": {
| ""type"": ""integer""
| },
| ""available"": {
| ""type"": ""boolean""
| }
|},
|""required"": [
| ""age"",
| ""available""
|]
|}");
AdditionalParameters = New Structure("format", Format);
Result = OPI_Ollama.GetResponse(URL, Model, Prompt, AdditionalParameters, AdditionalHeaders);
```
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
# JSON data can also be passed as a path to a .json file
oint ollama GetResponse \
--url "https://hut.openintegrations.dev/ollama" \
--model "mario" \
--prompt "How are you?" \
--headers "{'Authorization':'***'}"
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
:: JSON data can also be passed as a path to a .json file
oint ollama GetResponse ^
--url "https://hut.openintegrations.dev/ollama" ^
--model "mario" ^
--prompt "How are you?" ^
--headers "{'Authorization':'***'}"
```
</TabItem>
</Tabs>
```json title="Result"
{
"model": "tinyllama",
"created_at": "2025-09-15T07:08:38.533673938Z",
"response": "1C:Enterprise is a comprehensive and robust accounting software application designed for small and medium-sized businesses (SMBs) that operate in the United States. It offers advanced features such as inventory management, payroll processing, financial reporting, and much more, making it an excellent choice for any business looking to streamline their operations and boost profitability. The software is available as a single product or as part of a suite, with different pricing tiers depending on the requirements of the business.",
"done": true,
"done_reason": "stop",
"context": [
529,
29989,
5205,
29989,
29958,
13,
3492,
526,
263,
8444,
319,
29902,
20255,
29889,
2,
29871,
13,
29966,
29989,
1792,
29989,
29958,
13,
5618,
338,
29871,
29896,
29907,
29901,
10399,
7734,
29973,
2,
29871,
13,
29966,
29989,
465,
22137,
29989,
29958,
13,
29896,
29907,
29901,
10399,
7734,
338,
263,
15171,
6270,
322,
16424,
3633,
292,
7047,
2280,
8688,
363,
2319,
322,
18350,
29899,
2311,
29881,
5381,
267,
313,
17061,
29933,
29879,
29897,
393,
21994,
297,
278,
3303,
3900,
29889,
739,
16688,
12862,
5680,
1316,
408,
11817,
706,
10643,
29892,
5146,
1245,
9068,
29892,
18161,
23415,
29892,
322,
1568,
901,
29892,
3907,
372,
385,
15129,
7348,
363,
738,
5381,
3063,
304,
4840,
1220,
1009,
6931,
322,
14505,
21665,
3097,
29889,
450,
7047,
338,
3625,
408,
263,
2323,
3234,
470,
408,
760,
310,
263,
9460,
29892,
411,
1422,
3691,
3277,
26485,
29879,
8679,
373,
278,
...
```