Skip to content

Commit fbbdf1a

Browse files
committed
v0.49.10 - working ollama_generate_stream
1 parent d907b4c commit fbbdf1a

33 files changed

+1263
-1339
lines changed

apps/interactive.chat.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ shutdown() {
1818
echo "$(ollama_messages_count) Messages:"
1919
echo
2020
echo '```json'
21-
ollama_messages
21+
ollama_messages | jq
2222
echo '```'
2323
exit 0
2424
}
@@ -42,22 +42,20 @@ echo '- To view message history type: /messages'
4242
ollama_messages_clear
4343

4444
# Add System Prompt
45-
ollama_messages_add 'system' 'You are a helpful assistant'
45+
ollama_messages_add -r 'system' -c 'You are a helpful assistant'
4646

4747
while true; do
4848
echo
4949
echo "[$(ollama_messages_count) messages in history]"
5050
echo -n '>>> '
5151
read -r prompt
52-
if [ "$prompt" == '/messages' ]; then
52+
if [[ "$prompt" == '/messages' || "$prompt" == '/msgs' ]]; then
5353
echo "$(ollama_messages_count) messages:"; echo
5454
ollama_messages | jq
5555
continue
5656
fi;
5757
echo
58-
ollama_messages_add 'user' "$prompt" # Add user prompt to history
59-
response=$(ollama_chat "$model" "$prompt") # Get response from model
60-
#response=$(OLLAMA_LIB_DEBUG=1 ollama_chat "$model" "$prompt") # Get response from model, in debug mode
61-
printf '%s\n' "$response"
62-
ollama_messages_add "assistant" "$response" # Add model response to history
58+
ollama_messages_add -r 'user' -c "$prompt" # Add user prompt to history
59+
ollama_chat -m "$model"
60+
6361
done

apps/interactive.generate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ while true; do
3737
echo -n '>>> '
3838
read -r prompt
3939
echo
40-
ollama_generate_stream "$model" "$prompt"
40+
ollama_generate_stream -m "$model" -p "$prompt"
4141
echo
4242
done

demos/_is_valid_json.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# _is_valid_json
22

3-
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.9
3+
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.10
44

55
| test | result | return |
66
|------|--------|--------|

demos/_is_valid_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# _is_valid_model
22

3-
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.9
3+
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.10
44

55
| test | output | return | result |
66
|------|--------|--------|--------|

demos/about.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# ollama_lib_about, ollama_lib_version
22

3-
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.9
3+
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.10
44

55
## Demo
66

77
```bash
88
ollama_lib_version
99
```
10-
0.45.9
10+
0.45.10
1111

1212
```bash
1313
ollama_lib_about
@@ -16,7 +16,7 @@ ollama_lib_about
1616
A Bash Library to interact with Ollama
1717
1818
OLLAMA_LIB_NAME : Ollama Bash Lib
19-
OLLAMA_LIB_VERSION : 0.45.9
19+
OLLAMA_LIB_VERSION : 0.45.10
2020
OLLAMA_LIB_URL : https://github.com/attogram/ollama-bash-lib
2121
OLLAMA_LIB_DISCORD : https://discord.gg/BGQJCbYVBa
2222
OLLAMA_LIB_LICENSE : MIT

demos/help.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# help via -h and --help
22

3-
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.9
3+
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.10
44
## Testing -h for all functions (first argument)
55

66
`ollama_api_get -h`
@@ -191,9 +191,9 @@ Generate a completion from a model as a stream of text.
191191
-p <prompt> Prompt text. If omitted, the function reads from STDIN.
192192
-h Show this help and exit.
193193
-v Show version information and exit.
194-
195-
This function calls 'ollama_generate_stream_json' and pipes the output to 'jq' to extract the 'response' field from each JSON object, providing a continuous stream of text.
196-
It is ideal for displaying real-time generation in interactive scripts.
194+
195+
This function calls ollama_generate_stream_json and pipes the output to jq to extract the response field from each JSON object, providing a continuous stream of text.
196+
It is ideal for displaying real-time generation in interactive scripts.
197197
```
198198

199199
`ogs -h`
@@ -206,9 +206,9 @@ Generate a completion from a model as a stream of text.
206206
-p <prompt> Prompt text. If omitted, the function reads from STDIN.
207207
-h Show this help and exit.
208208
-v Show version information and exit.
209-
210-
This function calls 'ollama_generate_stream_json' and pipes the output to 'jq' to extract the 'response' field from each JSON object, providing a continuous stream of text.
211-
It is ideal for displaying real-time generation in interactive scripts.
209+
210+
This function calls ollama_generate_stream_json and pipes the output to jq to extract the response field from each JSON object, providing a continuous stream of text.
211+
It is ideal for displaying real-time generation in interactive scripts.
212212
```
213213

214214
`ollama_messages -h`

demos/list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ollama_list, ollama_list_json
22

3-
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.9
3+
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.10
44

55
```
66
ollama_list

demos/messages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ollama_messages, ollama_messages_add, ollama_messages_count
22

3-
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.9
3+
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.10
44
```
55
66
ollama_messages_count: 0

demos/ollama_api_get.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ollama_api_get
22

3-
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.9
3+
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.10
44

55
## Setup
66

@@ -42,12 +42,12 @@ result: output: {"version":"0.0.0"}
4242
```
4343
ollama_api_get
4444
45-
[DEBUG] 11:55:01:409480000: ollama_api_get: []
46-
[DEBUG] 11:55:01:414775000: _call_curl: [GET] []
47-
[DEBUG] 11:55:01:419964000: _call_curl: OLLAMA_LIB_API: https://ollama.com
48-
[DEBUG] 11:55:01:424745000: _call_curl: Turbo Mode
49-
[DEBUG] 11:55:01:429227000: _call_curl: args: -s -N --max-time 300 -H Content-Type: application/json -w \n%{http_code} -H Authorization: Bearer [REDACTED] -X GET https://ollama.com
50-
[DEBUG] 11:55:01:627673000: ollama_api_get: success
45+
[DEBUG] 15:42:18:678496000: ollama_api_get: []
46+
[DEBUG] 15:42:18:686076000: _call_curl: [GET] []
47+
[DEBUG] 15:42:18:693193000: _call_curl: OLLAMA_LIB_API: https://ollama.com
48+
[DEBUG] 15:42:18:699871000: _call_curl: Turbo Mode
49+
[DEBUG] 15:42:18:706233000: _call_curl: args: -s -N --max-time 300 -H Content-Type: application/json -w \n%{http_code} -H Authorization: Bearer [REDACTED] -X GET https://ollama.com
50+
[DEBUG] 15:42:18:915624000: ollama_api_get: success
5151
result: lines: 394
5252
result: output:
5353
@@ -63,12 +63,12 @@ result: output:
6363
```
6464
ollama_api_get -P "/api/version"
6565
66-
[DEBUG] 11:55:01:645622000: ollama_api_get: [/api/version]
67-
[DEBUG] 11:55:01:652041000: _call_curl: [GET] [/api/version]
68-
[DEBUG] 11:55:01:657541000: _call_curl: OLLAMA_LIB_API: https://ollama.com
69-
[DEBUG] 11:55:01:662766000: _call_curl: Turbo Mode
70-
[DEBUG] 11:55:01:668977000: _call_curl: args: -s -N --max-time 300 -H Content-Type: application/json -w \n%{http_code} -H Authorization: Bearer [REDACTED] -X GET https://ollama.com/api/version
71-
[DEBUG] 11:55:01:841990000: ollama_api_get: success
66+
[DEBUG] 15:42:18:938927000: ollama_api_get: [/api/version]
67+
[DEBUG] 15:42:18:945998000: _call_curl: [GET] [/api/version]
68+
[DEBUG] 15:42:18:952887000: _call_curl: OLLAMA_LIB_API: https://ollama.com
69+
[DEBUG] 15:42:18:959185000: _call_curl: Turbo Mode
70+
[DEBUG] 15:42:18:965375000: _call_curl: args: -s -N --max-time 300 -H Content-Type: application/json -w \n%{http_code} -H Authorization: Bearer [REDACTED] -X GET https://ollama.com/api/version
71+
[DEBUG] 15:42:19:160717000: ollama_api_get: success
7272
result: lines: 1
7373
result: output: {"version":"0.0.0"}
7474
```

demos/ollama_app_vars.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ollama_app_vars
22

3-
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.9
3+
A [demo](../README.md#demos) of [Ollama Bash Lib](https://github.com/attogram/ollama-bash-lib) v0.45.10
44

55
```
66
OLLAMA_AUTH : # Enables authentication between the Ollama client and server

0 commit comments

Comments
 (0)