ollama-client 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +7 -1
- data/docs/CLOUD.md +29 -0
- data/docs/CONSOLE_IMPROVEMENTS.md +256 -0
- data/docs/GEM_RELEASE_GUIDE.md +794 -0
- data/docs/GET_RUBYGEMS_SECRET.md +151 -0
- data/docs/QUICK_OTP_SETUP.md +80 -0
- data/docs/QUICK_RELEASE.md +106 -0
- data/docs/README.md +43 -0
- data/docs/RUBYGEMS_OTP_SETUP.md +199 -0
- data/docs/SCHEMA_FIXES.md +147 -0
- data/docs/TEST_UPDATES.md +107 -0
- data/examples/README.md +92 -0
- data/examples/advanced_complex_schemas.rb +6 -3
- data/examples/advanced_multi_step_agent.rb +2 -1
- data/examples/chat_console.rb +12 -3
- data/examples/complete_workflow.rb +14 -4
- data/examples/dhan_console.rb +103 -8
- data/examples/dhanhq/agents/technical_analysis_agent.rb +6 -1
- data/examples/dhanhq/schemas/agent_schemas.rb +2 -2
- data/examples/dhanhq_agent.rb +23 -13
- data/examples/dhanhq_tools.rb +311 -246
- data/examples/multi_step_agent_with_external_data.rb +368 -0
- data/{test_dhanhq_tool_calling.rb → examples/test_dhanhq_tool_calling.rb} +99 -6
- data/lib/ollama/agent/executor.rb +30 -30
- data/lib/ollama/client.rb +73 -80
- data/lib/ollama/dto.rb +7 -7
- data/lib/ollama/options.rb +17 -9
- data/lib/ollama/response.rb +4 -6
- data/lib/ollama/tool/function/parameters.rb +1 -0
- data/lib/ollama/version.rb +1 -1
- metadata +24 -9
- /data/{FEATURES_ADDED.md → docs/FEATURES_ADDED.md} +0 -0
- /data/{HANDLERS_ANALYSIS.md → docs/HANDLERS_ANALYSIS.md} +0 -0
- /data/{PRODUCTION_FIXES.md → docs/PRODUCTION_FIXES.md} +0 -0
- /data/{TESTING.md → docs/TESTING.md} +0 -0
- /data/{test_tool_calling.rb → examples/test_tool_calling.rb} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b126aae11a2fd7f0ff26e53e90e12222eb88e23fa6ecf622215c4a9317fe6ce
|
|
4
|
+
data.tar.gz: 2656544e1ce4bfa852dc687108bdde17084773c3a1e76c53ae9ed59d77604256
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5cbd78f768412b8e413e9222b4b0b2ef68e094280546742a0bd8191269072a6281ae4182d591e889ba3829c5b047b0e053c2410fa7734dc4cf1dfe320b527239
|
|
7
|
+
data.tar.gz: 2f1c2eafa75910646ed2300c8ad5ab312aefe56bb03d6e4797356e219543a57532058c2b2f3fc31b773caf0e7e0d26b3a71a6f9887b1a40955f5b818ffe6e227
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
- Add tag-triggered GitHub Actions release workflow for RubyGems publishing.
|
|
4
|
+
|
|
5
|
+
## [0.2.3] - 2026-01-17
|
|
6
|
+
|
|
7
|
+
- Add per-call `model:` override for `Ollama::Client#generate`.
|
|
8
|
+
- Document `generate` model override usage in README.
|
|
9
|
+
- Add spec to cover per-call `model:` in 404 error path.
|
|
10
|
+
|
|
3
11
|
## [0.2.0] - 2026-01-12
|
|
4
12
|
|
|
5
13
|
- Add `Ollama::Agent::Planner` (stateless `/api/generate`)
|
data/README.md
CHANGED
|
@@ -287,6 +287,7 @@ schema = {
|
|
|
287
287
|
# 2. Call the LLM with your schema
|
|
288
288
|
begin
|
|
289
289
|
result = client.generate(
|
|
290
|
+
model: "llama3.1:8b",
|
|
290
291
|
prompt: "Your prompt here",
|
|
291
292
|
schema: schema
|
|
292
293
|
)
|
|
@@ -877,7 +878,12 @@ ruby examples/advanced_multi_step_agent.rb
|
|
|
877
878
|
|
|
878
879
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
879
880
|
|
|
880
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
881
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
882
|
+
|
|
883
|
+
To release a new version, update `lib/ollama/version.rb` and `CHANGELOG.md`, then commit. You can:
|
|
884
|
+
|
|
885
|
+
- Run `bundle exec rake release` locally to create the tag, push commits/tags, and publish to [rubygems.org](https://rubygems.org).
|
|
886
|
+
- Push a tag `vX.Y.Z` to trigger the GitHub Actions release workflow, which builds and publishes the gem using the `RUBYGEMS_API_KEY` secret.
|
|
881
887
|
|
|
882
888
|
## Contributing
|
|
883
889
|
|
data/docs/CLOUD.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Cloud Agent Guide
|
|
2
|
+
|
|
3
|
+
This repository is a Ruby gem. It has no database and does not require
|
|
4
|
+
application secrets for the default test suite.
|
|
5
|
+
|
|
6
|
+
## Required Commands
|
|
7
|
+
- `bundle install`
|
|
8
|
+
- `bundle exec rubocop`
|
|
9
|
+
- `bundle exec rspec`
|
|
10
|
+
|
|
11
|
+
## Agent Prompt Template
|
|
12
|
+
You are operating on a Ruby gem repository.
|
|
13
|
+
Task:
|
|
14
|
+
1. Run `bundle exec rubocop`.
|
|
15
|
+
2. Fix all RuboCop offenses.
|
|
16
|
+
3. Re-run RuboCop until clean.
|
|
17
|
+
4. Run `bundle exec rspec`.
|
|
18
|
+
5. Fix all failing specs.
|
|
19
|
+
6. Re-run RSpec until green.
|
|
20
|
+
|
|
21
|
+
Rules:
|
|
22
|
+
- Do not skip failures.
|
|
23
|
+
- Do not change public APIs without reporting.
|
|
24
|
+
- Do not bump gem version unless explicitly told.
|
|
25
|
+
- Stop if blocked and explain why.
|
|
26
|
+
|
|
27
|
+
## Guardrails
|
|
28
|
+
- Keep API surface stable and backward compatible.
|
|
29
|
+
- Update specs when behavior changes.
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# Console Improvements
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Enhanced the interactive console experiences (`chat_console.rb` and `dhan_console.rb`) to provide better user feedback and cleaner output formatting.
|
|
6
|
+
|
|
7
|
+
## Chat Console (`chat_console.rb`)
|
|
8
|
+
|
|
9
|
+
### Problem
|
|
10
|
+
|
|
11
|
+
When the LLM was processing a response, the `llm>` prompt appeared immediately, making it look like it was waiting for user input. This caused confusion where users would start typing, thinking it was a prompt.
|
|
12
|
+
|
|
13
|
+
### Solution
|
|
14
|
+
|
|
15
|
+
Added a **thinking indicator** that shows while waiting for the API response:
|
|
16
|
+
|
|
17
|
+
**Before:**
|
|
18
|
+
```
|
|
19
|
+
you> Hi
|
|
20
|
+
llm> [cursor blinks here - looks like a prompt!]
|
|
21
|
+
[user types something]
|
|
22
|
+
[then response appears]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**After:**
|
|
26
|
+
```
|
|
27
|
+
you> Hi
|
|
28
|
+
... [thinking indicator in cyan]
|
|
29
|
+
llm> Hey! How can I help you?
|
|
30
|
+
you> [clear prompt for next input]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Implementation
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
def chat_response(client, messages, config)
|
|
37
|
+
content = +""
|
|
38
|
+
prompt_printed = false
|
|
39
|
+
|
|
40
|
+
# Show thinking indicator
|
|
41
|
+
print "#{COLOR_LLM}...#{COLOR_RESET}"
|
|
42
|
+
$stdout.flush
|
|
43
|
+
|
|
44
|
+
client.chat_raw(...) do |chunk|
|
|
45
|
+
token = chunk.dig("message", "content").to_s
|
|
46
|
+
next if token.empty?
|
|
47
|
+
|
|
48
|
+
# Replace thinking indicator with llm> on first token
|
|
49
|
+
unless prompt_printed
|
|
50
|
+
print "\r#{LLM_PROMPT}"
|
|
51
|
+
prompt_printed = true
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
content << token
|
|
55
|
+
print token
|
|
56
|
+
$stdout.flush
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
puts
|
|
60
|
+
content
|
|
61
|
+
end
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Key Changes:**
|
|
65
|
+
- `\r` (carriage return) replaces `...` with `llm>` when first token arrives
|
|
66
|
+
- `$stdout.flush` ensures immediate visual feedback
|
|
67
|
+
- Clear visual state: thinking → responding → ready for input
|
|
68
|
+
|
|
69
|
+
## DhanHQ Console (`dhan_console.rb`)
|
|
70
|
+
|
|
71
|
+
### Problem
|
|
72
|
+
|
|
73
|
+
Tool results were displayed as raw JSON dumps, making it hard to quickly understand:
|
|
74
|
+
- **Which tool** was called
|
|
75
|
+
- **What data** was retrieved
|
|
76
|
+
- **Key information** from the response
|
|
77
|
+
|
|
78
|
+
**Before:**
|
|
79
|
+
```
|
|
80
|
+
Tool Results:
|
|
81
|
+
- get_live_ltp
|
|
82
|
+
{
|
|
83
|
+
"action": "get_live_ltp",
|
|
84
|
+
"params": {
|
|
85
|
+
"security_id": "13",
|
|
86
|
+
"symbol": "NIFTY",
|
|
87
|
+
"exchange_segment": "IDX_I"
|
|
88
|
+
},
|
|
89
|
+
"result": {
|
|
90
|
+
"security_id": "13",
|
|
91
|
+
"exchange_segment": "IDX_I",
|
|
92
|
+
"ltp": 25694.35,
|
|
93
|
+
"ltp_data": {
|
|
94
|
+
"last_price": 25694.35
|
|
95
|
+
},
|
|
96
|
+
"symbol": "NIFTY"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Solution
|
|
102
|
+
|
|
103
|
+
Implemented **formatted, human-readable tool results** that extract and display key information:
|
|
104
|
+
|
|
105
|
+
**After:**
|
|
106
|
+
```
|
|
107
|
+
🔧 Tool Called: get_live_ltp
|
|
108
|
+
→ NIFTY (IDX_I)
|
|
109
|
+
→ Last Price: ₹25694.35
|
|
110
|
+
|
|
111
|
+
llm> The current price of NIFTY is 25694.35.
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Formatted Output by Tool
|
|
115
|
+
|
|
116
|
+
#### 1. Live LTP (`get_live_ltp`)
|
|
117
|
+
```
|
|
118
|
+
🔧 Tool Called: get_live_ltp
|
|
119
|
+
→ NIFTY (IDX_I)
|
|
120
|
+
→ Last Price: ₹25694.35
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### 2. Market Quote (`get_market_quote`)
|
|
124
|
+
```
|
|
125
|
+
🔧 Tool Called: get_market_quote
|
|
126
|
+
→ RELIANCE
|
|
127
|
+
→ LTP: ₹1457.9
|
|
128
|
+
→ OHLC: O:1458.8 H:1480.0 L:1455.1 C:1457.9
|
|
129
|
+
→ Volume: 17167161
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### 3. Historical Data (`get_historical_data`)
|
|
133
|
+
|
|
134
|
+
**Regular data:**
|
|
135
|
+
```
|
|
136
|
+
🔧 Tool Called: get_historical_data
|
|
137
|
+
→ Historical data: 30 records
|
|
138
|
+
→ Interval: 5
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**With indicators:**
|
|
142
|
+
```
|
|
143
|
+
🔧 Tool Called: get_historical_data
|
|
144
|
+
→ Technical Indicators:
|
|
145
|
+
→ Current Price: ₹25694.35
|
|
146
|
+
→ RSI(14): 56.32
|
|
147
|
+
→ MACD: 12.45
|
|
148
|
+
→ SMA(20): ₹25680.12
|
|
149
|
+
→ SMA(50): ₹25550.45
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### 4. Option Chain (`get_option_chain`)
|
|
153
|
+
```
|
|
154
|
+
🔧 Tool Called: get_option_chain
|
|
155
|
+
→ Spot: ₹25694.35
|
|
156
|
+
→ Strikes: 15
|
|
157
|
+
→ (Filtered: ATM/OTM/ITM with both CE & PE)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### 5. Expiry List (`get_expiry_list`)
|
|
161
|
+
```
|
|
162
|
+
🔧 Tool Called: get_expiry_list
|
|
163
|
+
→ Available expiries: 12
|
|
164
|
+
→ Next expiry: 2026-01-20
|
|
165
|
+
→ Expiries: 2026-01-20, 2026-01-27, 2026-02-03, 2026-02-10, 2026-02-17...
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### 6. Find Instrument (`find_instrument`)
|
|
169
|
+
```
|
|
170
|
+
🔧 Tool Called: find_instrument
|
|
171
|
+
→ Found: NIFTY
|
|
172
|
+
→ Security ID: 13
|
|
173
|
+
→ Exchange: IDX_I
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Implementation
|
|
177
|
+
|
|
178
|
+
```ruby
|
|
179
|
+
def print_formatted_result(tool_name, content)
|
|
180
|
+
result = content.dig("result") || content
|
|
181
|
+
|
|
182
|
+
case tool_name
|
|
183
|
+
when "get_live_ltp"
|
|
184
|
+
print_ltp_result(result)
|
|
185
|
+
when "get_market_quote"
|
|
186
|
+
print_quote_result(result)
|
|
187
|
+
when "get_historical_data"
|
|
188
|
+
print_historical_result(result, content)
|
|
189
|
+
# ... other tool formatters
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Each tool has a dedicated formatter that:
|
|
195
|
+
1. Extracts key information from the result
|
|
196
|
+
2. Formats it in a human-readable way
|
|
197
|
+
3. Uses color coding for better readability
|
|
198
|
+
4. Shows relevant details without overwhelming the user
|
|
199
|
+
|
|
200
|
+
## Benefits
|
|
201
|
+
|
|
202
|
+
### Chat Console
|
|
203
|
+
✅ **Clear visual feedback** - Users know when the LLM is thinking vs responding
|
|
204
|
+
✅ **No confusion** - Thinking indicator prevents accidental typing
|
|
205
|
+
✅ **Better UX** - Immediate response to user input
|
|
206
|
+
|
|
207
|
+
### DhanHQ Console
|
|
208
|
+
✅ **Instant comprehension** - See what tool was called at a glance
|
|
209
|
+
✅ **Key data highlighted** - Important values (price, volume) are prominent
|
|
210
|
+
✅ **Less noise** - No JSON clutter, just the facts
|
|
211
|
+
✅ **Consistent formatting** - Each tool type has predictable output
|
|
212
|
+
✅ **Professional appearance** - Clean, organized display with icons
|
|
213
|
+
|
|
214
|
+
## Configuration
|
|
215
|
+
|
|
216
|
+
Both consoles support environment variables:
|
|
217
|
+
|
|
218
|
+
**Chat Console:**
|
|
219
|
+
```bash
|
|
220
|
+
OLLAMA_BASE_URL=http://localhost:11434
|
|
221
|
+
OLLAMA_MODEL=llama3.1:8b
|
|
222
|
+
OLLAMA_TEMPERATURE=0.7
|
|
223
|
+
OLLAMA_SYSTEM="You are a helpful assistant"
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**DhanHQ Console:**
|
|
227
|
+
```bash
|
|
228
|
+
# All chat console vars, plus:
|
|
229
|
+
DHANHQ_CLIENT_ID=your_client_id
|
|
230
|
+
DHANHQ_ACCESS_TOKEN=your_token
|
|
231
|
+
SHOW_PLAN=true # Show planning step
|
|
232
|
+
ALLOW_NO_TOOL_OUTPUT=false # Require tool calls
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Testing
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# Test chat console with thinking indicator
|
|
239
|
+
ruby examples/chat_console.rb
|
|
240
|
+
|
|
241
|
+
# Test DhanHQ console with formatted results
|
|
242
|
+
ruby examples/dhan_console.rb
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Try queries like:
|
|
246
|
+
- "What is NIFTY price?" → See formatted LTP
|
|
247
|
+
- "Get RELIANCE quote" → See formatted quote with OHLC
|
|
248
|
+
- "Show me historical data for NIFTY" → See record count
|
|
249
|
+
- "Get option chain for NIFTY" → See filtered strikes
|
|
250
|
+
|
|
251
|
+
## Related Files
|
|
252
|
+
|
|
253
|
+
- `examples/chat_console.rb` - Simple chat with thinking indicator
|
|
254
|
+
- `examples/dhan_console.rb` - Market data with formatted tool results
|
|
255
|
+
- `examples/dhanhq_tools.rb` - Underlying DhanHQ tool implementations
|
|
256
|
+
- `docs/TESTING.md` - Testing guide
|