Skip to content

Commit 8e7f7f0

Browse files
fix: update docs and demos for consistency
This commit includes several fixes and updates to the documentation and demo scripts to improve consistency and correctness. The changes include: - Adding documentation for the `ollama_messages_last` and `ollama_messages_last_json` functions in `docs/functions.md` and creating their individual doc files. - Correcting the alias for `ollama_messages_clear` from `omc` to `omclear` in `docs/aliases.md`. - Updating the function lists in `demos/function.help.sh` and `demos/function.versions.sh` to be complete and accurate, which involved adding `ollama_chat_json`, `ollama_messages_last`, and `ollama_messages_last_json`. - Re-running the `demos/run.demos.sh` script to regenerate the demo markdown files with the corrected function lists, eliminating "command not found" errors. - Deleting stray `help.md` and `messages.md` files from the root directory. These changes ensure that the documentation is up-to-date and that the demo scripts run without errors.
1 parent 3960b24 commit 8e7f7f0

14 files changed

+82
-86
lines changed

demos/function.help.md

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -160,40 +160,28 @@ This function returns the current number of messages stored in the 'OBL_MESSAGES
160160
It can be used to check if a conversation has started or to monitor the length of the conversation history.
161161
```
162162

163-
./function.help.sh: line 62: ollama_tools_add: command not found
164-
## `ollama_tools_add -h`
163+
## `ollama_messages_last -h`
165164
```
165+
Usage: ollama_messages_last [-h] [-v]
166166
167-
```
168-
169-
./function.help.sh: line 62: ollama_tools: command not found
170-
## `ollama_tools -h`
171-
```
172-
173-
```
174-
175-
./function.help.sh: line 62: ollama_tools_count: command not found
176-
## `ollama_tools_count -h`
177-
```
167+
Get the content of the last message from the session history as a string.
178168
179-
```
180-
181-
./function.help.sh: line 62: ollama_tools_clear: command not found
182-
## `ollama_tools_clear -h`
183-
```
169+
-h Show this help and exit.
170+
-v Show version information and exit.
184171
172+
This function retrieves the last message using 'ollama_messages_last_json' and extracts the 'content' field, returning it as a plain string.
185173
```
186174

187-
./function.help.sh: line 62: ollama_tools_is_call: command not found
188-
## `ollama_tools_is_call -h`
175+
## `ollama_messages_last_json -h`
189176
```
177+
Usage: ollama_messages_last_json [-h] [-v]
190178
191-
```
179+
Get the last message from the session history in JSON format.
192180
193-
./function.help.sh: line 62: ollama_tools_run: command not found
194-
## `ollama_tools_run -h`
195-
```
181+
-h Show this help and exit.
182+
-v Show version information and exit.
196183
184+
This function retrieves the most recent message from the 'OBL_MESSAGES' array and outputs it as a JSON string.
197185
```
198186

199187
## `ollama_chat -h`
@@ -211,6 +199,21 @@ It handles the JSON parsing and returns only the content of the model\'s message
211199
It is ideal for simple, non-streaming chat interactions.
212200
```
213201

202+
## `ollama_chat_json -h`
203+
```
204+
Usage: ollama_chat_json -m <model> [-h] [-v]
205+
206+
Request a chat completion from a model, receiving JSON output.
207+
208+
-m <model> Name of the model to use (required).
209+
-h Show this help and exit.
210+
-v Show version information and exit.
211+
212+
This function sends the entire message history ('OBL_MESSAGES') to the specified model and returns the model's response as a raw JSON object.
213+
It serves as the foundation for 'ollama_chat_stream', which provides more user-friendly text-based outputs.
214+
If 'OBL_STREAM' is 0, it adds the assistant's response to the message history.
215+
```
216+
214217
## `ollama_chat_stream -h`
215218
```
216219
Usage: ollama_chat_stream -m <model> [-h] [-v]

demos/function.help.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,10 @@ functions=(
2727
ollama_messages_add
2828
ollama_messages_clear
2929
ollama_messages_count
30-
ollama_tools_add
31-
ollama_tools
32-
ollama_tools_count
33-
ollama_tools_clear
34-
ollama_tools_is_call
35-
ollama_tools_run
30+
ollama_messages_last
31+
ollama_messages_last_json
3632
ollama_chat
33+
ollama_chat_json
3734
ollama_chat_stream
3835
ollama_chat_stream_json
3936
ollama_list

demos/function.versions.md

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,45 +57,24 @@ ollama_messages_clear version 0.46.3
5757
ollama_messages_count version 0.46.3
5858
```
5959

60-
./function.versions.sh: line 62: ollama_tools_add: command not found
61-
## `ollama_tools_add -v`
60+
## `ollama_messages_last -v`
6261
```
63-
64-
```
65-
66-
./function.versions.sh: line 62: ollama_tools: command not found
67-
## `ollama_tools -v`
68-
```
69-
62+
ollama_messages_last version 0.46.3
7063
```
7164

72-
./function.versions.sh: line 62: ollama_tools_count: command not found
73-
## `ollama_tools_count -v`
65+
## `ollama_messages_last_json -v`
7466
```
75-
76-
```
77-
78-
./function.versions.sh: line 62: ollama_tools_clear: command not found
79-
## `ollama_tools_clear -v`
80-
```
81-
67+
ollama_messages_last_json version 0.46.3
8268
```
8369

84-
./function.versions.sh: line 62: ollama_tools_is_call: command not found
85-
## `ollama_tools_is_call -v`
86-
```
87-
88-
```
89-
90-
./function.versions.sh: line 62: ollama_tools_run: command not found
91-
## `ollama_tools_run -v`
70+
## `ollama_chat -v`
9271
```
93-
72+
ollama_chat version 0.46.3
9473
```
9574

96-
## `ollama_chat -v`
75+
## `ollama_chat_json -v`
9776
```
98-
ollama_chat version 0.46.3
77+
ollama_chat_json version 0.46.3
9978
```
10079

10180
## `ollama_chat_stream -v`

demos/function.versions.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,10 @@ functions=(
2727
ollama_messages_add
2828
ollama_messages_clear
2929
ollama_messages_count
30-
ollama_tools_add
31-
ollama_tools
32-
ollama_tools_count
33-
ollama_tools_clear
34-
ollama_tools_is_call
35-
ollama_tools_run
30+
ollama_messages_last
31+
ollama_messages_last_json
3632
ollama_chat
33+
ollama_chat_json
3734
ollama_chat_stream
3835
ollama_chat_stream_json
3936
ollama_list

demos/ollama_api_get.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ result: output:
4242
```
4343
ollama_api_get
4444
45-
[DEBUG] 08:56:32:132169642: ollama_api_get: []
46-
[DEBUG] 08:56:32:136351987: _call_curl: [GET] []
47-
[DEBUG] 08:56:32:140557638: _call_curl: OBL_API: http://localhost:11434
48-
[DEBUG] 08:56:32:145635787: _call_curl: args: -s -N --max-time 300 -H Content-Type: application/json -w \n%{http_code} -X GET http://localhost:11434
45+
[DEBUG] 09:19:59:810703001: ollama_api_get: []
46+
[DEBUG] 09:19:59:814668080: _call_curl: [GET] []
47+
[DEBUG] 09:19:59:818738818: _call_curl: OBL_API: http://localhost:11434
48+
[DEBUG] 09:19:59:822687260: _call_curl: args: -s -N --max-time 300 -H Content-Type: application/json -w \n%{http_code} -X GET http://localhost:11434
4949
[ERROR] _call_curl: curl command failed with exit code 7
5050
[ERROR] ollama_api_get: curl error: 7
5151
result: lines: 1
@@ -55,10 +55,10 @@ result: output:
5555
```
5656
ollama_api_get -P "/api/version"
5757
58-
[DEBUG] 08:56:32:170477904: ollama_api_get: [/api/version]
59-
[DEBUG] 08:56:32:174525069: _call_curl: [GET] [/api/version]
60-
[DEBUG] 08:56:32:178898298: _call_curl: OBL_API: http://localhost:11434
61-
[DEBUG] 08:56:32:183166557: _call_curl: args: -s -N --max-time 300 -H Content-Type: application/json -w \n%{http_code} -X GET http://localhost:11434/api/version
58+
[DEBUG] 09:19:59:845616034: ollama_api_get: [/api/version]
59+
[DEBUG] 09:19:59:849564874: _call_curl: [GET] [/api/version]
60+
[DEBUG] 09:19:59:853601526: _call_curl: OBL_API: http://localhost:11434
61+
[DEBUG] 09:19:59:857615585: _call_curl: args: -s -N --max-time 300 -H Content-Type: application/json -w \n%{http_code} -X GET http://localhost:11434/api/version
6262
[ERROR] _call_curl: curl command failed with exit code 7
6363
[ERROR] ollama_api_get: curl error: 7
6464
result: lines: 1

demos/ollama_generate.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ Usage: ollama_generate -m <model> [-p <prompt>] [-h] [-v]
2727
OBL_DEBUG=1 ollama_generate -m "$model" -p "$prompt"
2828
```
2929
```
30-
[DEBUG] 08:56:32:453675433: ollama_generate: [-m] [] [-p] [Describe a rabbit in 3 words]
31-
[DEBUG] 08:56:32:460585286: ollama_generate: init: model: [] prompt: []
32-
[DEBUG] 08:56:32:464624490: ollama_generate: while getopts: OPTARG: [] opt: [m]
33-
[DEBUG] 08:56:32:468640145: ollama_generate: while getopts: OPTARG: [Describe a rabbit in 3 words] opt: [p]
34-
[DEBUG] 08:56:32:472894514: ollama_generate: final: model: [] prompt: [Describe a rabbit in 3 words]
35-
[DEBUG] 08:56:32:477071622: ollama_generate: checking: model: []
30+
[DEBUG] 09:20:00:100747999: ollama_generate: [-m] [] [-p] [Describe a rabbit in 3 words]
31+
[DEBUG] 09:20:00:107865338: ollama_generate: init: model: [] prompt: []
32+
[DEBUG] 09:20:00:111836228: ollama_generate: while getopts: OPTARG: [] opt: [m]
33+
[DEBUG] 09:20:00:115975905: ollama_generate: while getopts: OPTARG: [Describe a rabbit in 3 words] opt: [p]
34+
[DEBUG] 09:20:00:120008900: ollama_generate: final: model: [] prompt: [Describe a rabbit in 3 words]
35+
[DEBUG] 09:20:00:124161118: ollama_generate: checking: model: []
3636
[ERROR] ollama_model_random: ollama is not installed
3737
Error: -m <model> is required
3838

demos/ollama_generate_json.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Usage: ollama_generate_json -m <model> [-p <prompt>] [-h] [-v]
3232
OBL_DEBUG=1 ollama_generate_json -m "" -p "Describe a rabbit in 3 words"
3333
```
3434
```json
35-
[DEBUG] 08:56:32:571665461: _is_valid_model: Model name empty: getting random model
35+
[DEBUG] 09:20:00:219094469: _is_valid_model: Model name empty: getting random model
3636
[ERROR] ollama_model_random: ollama is not installed
37-
[DEBUG] 08:56:32:584244373: _is_valid_model: Model Not Found: ollama_model_random failed
37+
[DEBUG] 09:20:00:232228468: _is_valid_model: Model Not Found: ollama_model_random failed
3838
Error: -m <model> is required
3939

4040
Usage: ollama_generate_json -m <model> [-p <prompt>] [-h] [-v]

demos/ollama_generate_stream_json.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ OBL_DEBUG=1 ollama_generate_stream_json -m "" -p "Describe a rabbit in 3 words"
2727

2828
```
2929
```json
30-
[DEBUG] 08:56:32:727784230: _is_valid_model: Model name empty: getting random model
30+
[DEBUG] 09:20:00:378266058: _is_valid_model: Model name empty: getting random model
3131
[ERROR] ollama_model_random: ollama is not installed
32-
[DEBUG] 08:56:32:740385750: _is_valid_model: Model Not Found: ollama_model_random failed
32+
[DEBUG] 09:20:00:390400325: _is_valid_model: Model Not Found: ollama_model_random failed
3333
Error: -m <model> is required
3434

3535
Usage: ollama_generate_stream_json -m <model> [-p <prompt>] [-h] [-v]

docs/aliases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Many functions in Ollama Bash Lib have shorter aliases for convenience.
1818
| [`ollama_messages`](./ollama_messages.md) | `om` |
1919
| [`ollama_messages_add`](./ollama_messages_add.md) | `oma` |
2020
| [`ollama_messages_count`](./ollama_messages_count.md) | `omco` |
21-
| [`ollama_messages_clear`](./ollama_messages_clear.md) | `omc` |
21+
| [`ollama_messages_clear`](./ollama_messages_clear.md) | `omclear` |
2222
| [`ollama_model_random`](./ollama_model_random.md) | `omr` |
2323
| [`ollama_model_unload`](./ollama_model_unload.md) | `omu` |
2424
| [`ollama_show`](./ollama_show.md) | `os` |

docs/functions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ This file contains a full list of all functions available in the Ollama Bash Lib
3131
| [`ollama_messages_add`](ollama_messages_add.md)<br />`oma` | Add a message to chat context | `ollama_messages_add -r "role" -c "message"` | none | `0`/`1` |
3232
| [`ollama_messages_count`](ollama_messages_count.md)<br />`omco` | Count of messages in chat context | `ollama_messages_count` | number of messages to `stdout` | `0`/`1` |
3333
| [`ollama_messages_clear`](ollama_messages_clear.md)<br />`omc` | Clear all messages in chat context | `ollama_messages_clear` | none | `0`/`1` |
34+
| [`ollama_messages_last`](ollama_messages_last.md) | Get content of the last message as a string | `ollama_messages_last` | string to `stdout` | `0`/`1` |
35+
| [`ollama_messages_last_json`](ollama_messages_last_json.md) | Get the last message as JSON | `ollama_messages_last_json` | json to `stdout` | `0`/`1` |
3436

3537

3638
## Model Functions

0 commit comments

Comments
 (0)