ollama-client 0.2.5 → 0.2.7

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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +336 -91
  4. data/RELEASE_NOTES_v0.2.6.md +41 -0
  5. data/docs/AREAS_FOR_CONSIDERATION.md +325 -0
  6. data/docs/EXAMPLE_REORGANIZATION.md +412 -0
  7. data/docs/FEATURES_ADDED.md +12 -1
  8. data/docs/GETTING_STARTED.md +361 -0
  9. data/docs/INTEGRATION_TESTING.md +170 -0
  10. data/docs/NEXT_STEPS_SUMMARY.md +114 -0
  11. data/docs/PERSONAS.md +383 -0
  12. data/docs/QUICK_START.md +195 -0
  13. data/docs/TESTING.md +392 -170
  14. data/docs/TEST_CHECKLIST.md +450 -0
  15. data/examples/README.md +62 -63
  16. data/examples/basic_chat.rb +33 -0
  17. data/examples/basic_generate.rb +29 -0
  18. data/examples/mcp_executor.rb +39 -0
  19. data/examples/mcp_http_executor.rb +45 -0
  20. data/examples/tool_calling_parsing.rb +59 -0
  21. data/examples/tool_dto_example.rb +0 -0
  22. data/exe/ollama-client +128 -1
  23. data/lib/ollama/agent/planner.rb +7 -2
  24. data/lib/ollama/chat_session.rb +101 -0
  25. data/lib/ollama/client.rb +41 -35
  26. data/lib/ollama/config.rb +9 -4
  27. data/lib/ollama/document_loader.rb +1 -1
  28. data/lib/ollama/embeddings.rb +61 -28
  29. data/lib/ollama/errors.rb +1 -0
  30. data/lib/ollama/mcp/http_client.rb +149 -0
  31. data/lib/ollama/mcp/stdio_client.rb +146 -0
  32. data/lib/ollama/mcp/tools_bridge.rb +72 -0
  33. data/lib/ollama/mcp.rb +31 -0
  34. data/lib/ollama/options.rb +3 -1
  35. data/lib/ollama/personas.rb +287 -0
  36. data/lib/ollama/version.rb +1 -1
  37. data/lib/ollama_client.rb +17 -5
  38. metadata +22 -48
  39. data/examples/advanced_complex_schemas.rb +0 -366
  40. data/examples/advanced_edge_cases.rb +0 -241
  41. data/examples/advanced_error_handling.rb +0 -200
  42. data/examples/advanced_multi_step_agent.rb +0 -341
  43. data/examples/advanced_performance_testing.rb +0 -186
  44. data/examples/chat_console.rb +0 -143
  45. data/examples/complete_workflow.rb +0 -245
  46. data/examples/dhan_console.rb +0 -843
  47. data/examples/dhanhq/README.md +0 -236
  48. data/examples/dhanhq/agents/base_agent.rb +0 -74
  49. data/examples/dhanhq/agents/data_agent.rb +0 -66
  50. data/examples/dhanhq/agents/orchestrator_agent.rb +0 -120
  51. data/examples/dhanhq/agents/technical_analysis_agent.rb +0 -252
  52. data/examples/dhanhq/agents/trading_agent.rb +0 -81
  53. data/examples/dhanhq/analysis/market_structure.rb +0 -138
  54. data/examples/dhanhq/analysis/pattern_recognizer.rb +0 -192
  55. data/examples/dhanhq/analysis/trend_analyzer.rb +0 -88
  56. data/examples/dhanhq/builders/market_context_builder.rb +0 -67
  57. data/examples/dhanhq/dhanhq_agent.rb +0 -829
  58. data/examples/dhanhq/indicators/technical_indicators.rb +0 -158
  59. data/examples/dhanhq/scanners/intraday_options_scanner.rb +0 -492
  60. data/examples/dhanhq/scanners/swing_scanner.rb +0 -247
  61. data/examples/dhanhq/schemas/agent_schemas.rb +0 -61
  62. data/examples/dhanhq/services/base_service.rb +0 -46
  63. data/examples/dhanhq/services/data_service.rb +0 -118
  64. data/examples/dhanhq/services/trading_service.rb +0 -59
  65. data/examples/dhanhq/technical_analysis_agentic_runner.rb +0 -411
  66. data/examples/dhanhq/technical_analysis_runner.rb +0 -420
  67. data/examples/dhanhq/test_tool_calling.rb +0 -538
  68. data/examples/dhanhq/test_tool_calling_verbose.rb +0 -251
  69. data/examples/dhanhq/utils/instrument_helper.rb +0 -32
  70. data/examples/dhanhq/utils/parameter_cleaner.rb +0 -28
  71. data/examples/dhanhq/utils/parameter_normalizer.rb +0 -45
  72. data/examples/dhanhq/utils/rate_limiter.rb +0 -23
  73. data/examples/dhanhq/utils/trading_parameter_normalizer.rb +0 -72
  74. data/examples/dhanhq_agent.rb +0 -964
  75. data/examples/dhanhq_tools.rb +0 -1663
  76. data/examples/multi_step_agent_with_external_data.rb +0 -368
  77. data/examples/structured_outputs_chat.rb +0 -72
  78. data/examples/structured_tools.rb +0 -89
  79. data/examples/test_dhanhq_tool_calling.rb +0 -375
  80. data/examples/test_tool_calling.rb +0 -160
  81. data/examples/tool_calling_direct.rb +0 -124
  82. data/examples/tool_calling_pattern.rb +0 -269
  83. data/exe/dhan_console +0 -4
@@ -0,0 +1,412 @@
1
+ # Example Reorganization Proposal
2
+
3
+ This document proposes how to reorganize examples to keep `ollama-client` focused on the transport layer while providing clear guidance for agent developers.
4
+
5
+ ## Decision: Separate Examples Repository
6
+
7
+ **Recommendation:** Move all non-trivial examples to a separate repository (`ollama-agent-examples` or similar).
8
+
9
+ **Rationale:**
10
+ - Examples rot faster than APIs
11
+ - Agent examples pull in agent-runtime dependencies
12
+ - Tool examples imply opinions about tool design
13
+ - The client becomes bloated with domain-specific code
14
+ - New users confuse client vs agent responsibilities
15
+
16
+ ## What Stays in `ollama-client` Repo
17
+
18
+ ### Minimal Examples (Keep)
19
+
20
+ These examples demonstrate **client usage only**, not agent behavior:
21
+
22
+ #### ✅ `examples/basic_generate.rb` (NEW - Create)
23
+ **Purpose:** Demonstrate basic `/generate` usage with schema.
24
+
25
+ **Content:**
26
+ ```ruby
27
+ #!/usr/bin/env ruby
28
+ # frozen_string_literal: true
29
+
30
+ require "ollama_client"
31
+
32
+ client = Ollama::Client.new
33
+
34
+ schema = {
35
+ "type" => "object",
36
+ "required" => ["status"],
37
+ "properties" => {
38
+ "status" => { "type" => "string" }
39
+ }
40
+ }
41
+
42
+ result = client.generate(
43
+ prompt: "Output a JSON object with a single key 'status' and value 'ok'.",
44
+ schema: schema
45
+ )
46
+
47
+ puts result["status"] # => "ok"
48
+ ```
49
+
50
+ **Why keep:** Minimal, demonstrates core client functionality.
51
+
52
+ ---
53
+
54
+ #### ✅ `examples/basic_chat.rb` (NEW - Create)
55
+ **Purpose:** Demonstrate basic `/chat` usage.
56
+
57
+ **Content:**
58
+ ```ruby
59
+ #!/usr/bin/env ruby
60
+ # frozen_string_literal: true
61
+
62
+ require "ollama_client"
63
+
64
+ client = Ollama::Client.new
65
+
66
+ response = client.chat_raw(
67
+ messages: [{ role: "user", content: "Say hello." }],
68
+ allow_chat: true
69
+ )
70
+
71
+ puts response.message.content
72
+ ```
73
+
74
+ **Why keep:** Minimal, demonstrates chat API.
75
+
76
+ ---
77
+
78
+ #### ✅ `examples/tool_calling_parsing.rb` (NEW - Create, or rename existing)
79
+ **Purpose:** Demonstrate tool-call **parsing** (not execution).
80
+
81
+ **Content:**
82
+ ```ruby
83
+ #!/usr/bin/env ruby
84
+ # frozen_string_literal: true
85
+
86
+ require "ollama_client"
87
+
88
+ client = Ollama::Client.new
89
+
90
+ tool = Ollama::Tool.new(
91
+ type: "function",
92
+ function: Ollama::Tool::Function.new(
93
+ name: "get_weather",
94
+ description: "Get weather for a location",
95
+ parameters: Ollama::Tool::Function::Parameters.new(
96
+ type: "object",
97
+ properties: {
98
+ location: Ollama::Tool::Function::Parameters::Property.new(
99
+ type: "string",
100
+ description: "The city name"
101
+ )
102
+ },
103
+ required: %w[location]
104
+ )
105
+ )
106
+ )
107
+
108
+ response = client.chat_raw(
109
+ messages: [{ role: "user", content: "What's the weather in Paris?" }],
110
+ tools: tool,
111
+ allow_chat: true
112
+ )
113
+
114
+ # Parse tool calls (but don't execute)
115
+ if response.message.tool_calls
116
+ response.message.tool_calls.each do |call|
117
+ puts "Tool: #{call['function']['name']}"
118
+ puts "Args: #{JSON.parse(call['function']['arguments'])}"
119
+ end
120
+ end
121
+ ```
122
+
123
+ **Why keep:** Demonstrates tool-call parsing, not execution.
124
+
125
+ ---
126
+
127
+ #### ✅ `examples/tool_dto_example.rb` (KEEP - Already minimal)
128
+ **Purpose:** Demonstrates Tool DTO serialization.
129
+
130
+ **Why keep:** Demonstrates client API, not agent behavior.
131
+
132
+ ---
133
+
134
+ ### README Updates
135
+
136
+ Update `README.md` to include:
137
+
138
+ 1. **Minimal examples inline** (as shown above)
139
+ 2. **Link to separate examples repo:**
140
+ ```markdown
141
+ ## Full Agent Examples
142
+
143
+ For complete agent examples (trading agents, coding agents, RAG agents, etc.),
144
+ see: [ollama-agent-examples](https://github.com/shubhamtaywade82/ollama-agent-examples)
145
+ ```
146
+
147
+ ---
148
+
149
+ ## What Moves to Separate Repository
150
+
151
+ ### Agent Examples (Move)
152
+
153
+ All examples that demonstrate **agent behavior**, not just client usage:
154
+
155
+ #### ❌ Move: `examples/dhanhq/` (ENTIRE DIRECTORY)
156
+ - `dhanhq/agents/` - Agent implementations
157
+ - `dhanhq/analysis/` - Domain-specific analysis
158
+ - `dhanhq/builders/` - Domain-specific builders
159
+ - `dhanhq/indicators/` - Domain-specific indicators
160
+ - `dhanhq/scanners/` - Domain-specific scanners
161
+ - `dhanhq/services/` - Domain-specific services
162
+ - `dhanhq/utils/` - Domain-specific utilities
163
+
164
+ **Why move:** Entirely domain-specific, pulls in DhanHQ dependencies, demonstrates agent patterns, not client usage.
165
+
166
+ ---
167
+
168
+ #### ❌ Move: `examples/dhan_console.rb`
169
+ **Why move:** Full agent console with planning, tool execution, domain logic.
170
+
171
+ ---
172
+
173
+ #### ❌ Move: `examples/dhanhq_agent.rb`
174
+ **Why move:** Complete agent implementation.
175
+
176
+ ---
177
+
178
+ #### ❌ Move: `examples/dhanhq_tools.rb`
179
+ **Why move:** Domain-specific tool implementations.
180
+
181
+ ---
182
+
183
+ #### ❌ Move: `examples/test_dhanhq_tool_calling.rb`
184
+ **Why move:** Tests agent behavior, not client parsing.
185
+
186
+ ---
187
+
188
+ #### ❌ Move: `examples/multi_step_agent_e2e.rb`
189
+ **Why move:** Demonstrates agent loops, convergence, state management.
190
+
191
+ ---
192
+
193
+ #### ❌ Move: `examples/multi_step_agent_with_external_data.rb`
194
+ **Why move:** Demonstrates agent workflows with external data.
195
+
196
+ ---
197
+
198
+ #### ❌ Move: `examples/advanced_multi_step_agent.rb`
199
+ **Why move:** Complex agent workflows, not client usage.
200
+
201
+ ---
202
+
203
+ #### ❌ Move: `examples/advanced_error_handling.rb`
204
+ **Why move:** Agent-level error handling patterns, not client error handling.
205
+
206
+ ---
207
+
208
+ #### ❌ Move: `examples/advanced_edge_cases.rb`
209
+ **Why move:** Agent-level edge cases, not client edge cases.
210
+
211
+ ---
212
+
213
+ #### ❌ Move: `examples/advanced_complex_schemas.rb`
214
+ **Why move:** Domain-specific schemas (financial, code review, research), not client schema validation.
215
+
216
+ ---
217
+
218
+ #### ❌ Move: `examples/advanced_performance_testing.rb`
219
+ **Why move:** Agent performance testing, not client performance.
220
+
221
+ ---
222
+
223
+ #### ❌ Move: `examples/complete_workflow.rb`
224
+ **Why move:** Complete agent workflow, not client usage.
225
+
226
+ ---
227
+
228
+ #### ❌ Move: `examples/chat_console.rb`
229
+ **Why move:** Full interactive console, not minimal client demo.
230
+
231
+ ---
232
+
233
+ #### ❌ Move: `examples/chat_session_example.rb`
234
+ **Why move:** Demonstrates ChatSession usage patterns, not core client.
235
+
236
+ ---
237
+
238
+ #### ❌ Move: `examples/ollama_chat.rb`
239
+ **Why move:** Interactive chat demo, not minimal client demo.
240
+
241
+ ---
242
+
243
+ #### ❌ Move: `examples/personas_example.rb`
244
+ **Why move:** Agent persona patterns, not client usage.
245
+
246
+ ---
247
+
248
+ #### ❌ Move: `examples/structured_outputs_chat.rb`
249
+ **Why move:** Agent-level structured output patterns, not client schema validation.
250
+
251
+ ---
252
+
253
+ #### ❌ Move: `examples/structured_tools.rb`
254
+ **Why move:** Agent-level tool organization, not client tool parsing.
255
+
256
+ ---
257
+
258
+ #### ❌ Move: `examples/test_tool_calling.rb`
259
+ **Why move:** Tests tool execution, not client parsing.
260
+
261
+ ---
262
+
263
+ #### ❌ Move: `examples/tool_calling_direct.rb`
264
+ **Why move:** Demonstrates tool execution patterns, not client parsing.
265
+
266
+ ---
267
+
268
+ #### ❌ Move: `examples/tool_calling_pattern.rb`
269
+ **Why move:** Demonstrates agent tool routing patterns, not client parsing.
270
+
271
+ ---
272
+
273
+ #### ❌ Move: `examples/ollama-api.md`
274
+ **Why move:** Documentation, not example code.
275
+
276
+ ---
277
+
278
+ ## Proposed Separate Repository Structure
279
+
280
+ ```
281
+ ollama-agent-examples/
282
+ ├── README.md
283
+ │ └── Links back to ollama-client, explains this is for agent examples
284
+ ├── basic/
285
+ │ ├── simple_tool_calling.rb
286
+ │ ├── multi_step_agent.rb
287
+ │ └── chat_session.rb
288
+ ├── trading/
289
+ │ ├── dhanhq/
290
+ │ │ ├── agents/
291
+ │ │ ├── analysis/
292
+ │ │ ├── scanners/
293
+ │ │ └── ...
294
+ │ └── README.md
295
+ ├── coding/
296
+ │ ├── code_review_agent.rb
297
+ │ └── refactoring_agent.rb
298
+ ├── rag/
299
+ │ ├── document_qa.rb
300
+ │ └── semantic_search.rb
301
+ ├── advanced/
302
+ │ ├── multi_step_workflows.rb
303
+ │ ├── error_handling_patterns.rb
304
+ │ └── performance_testing.rb
305
+ └── tools/
306
+ ├── structured_tools.rb
307
+ └── tool_routing_patterns.rb
308
+ ```
309
+
310
+ ---
311
+
312
+ ## Migration Plan
313
+
314
+ ### Phase 1: Create Minimal Examples
315
+ 1. Create `examples/basic_generate.rb`
316
+ 2. Create `examples/basic_chat.rb`
317
+ 3. Create `examples/tool_calling_parsing.rb` (or rename existing minimal one)
318
+ 4. Keep `examples/tool_dto_example.rb`
319
+
320
+ ### Phase 2: Update README
321
+ 1. Add inline minimal examples to README
322
+ 2. Add link to separate examples repo (create placeholder if needed)
323
+ 3. Add "What this gem is NOT" section
324
+
325
+ ### Phase 3: Create Separate Repository
326
+ 1. Create `ollama-agent-examples` repository
327
+ 2. Move all agent examples
328
+ 3. Update README in examples repo to link back to `ollama-client`
329
+ 4. Update `ollama-client` README to link to examples repo
330
+
331
+ ### Phase 4: Clean Up
332
+ 1. Remove moved examples from `ollama-client`
333
+ 2. Update `examples/README.md` to reflect minimal examples only
334
+ 3. Update any documentation that references moved examples
335
+
336
+ ---
337
+
338
+ ## Benefits of This Separation
339
+
340
+ ### For `ollama-client`:
341
+ - ✅ Stays focused on transport layer
342
+ - ✅ Examples don't rot as quickly
343
+ - ✅ No domain-specific dependencies
344
+ - ✅ Clearer boundaries for contributors
345
+ - ✅ Easier to maintain
346
+
347
+ ### For Agent Developers:
348
+ - ✅ Examples can be opinionated
349
+ - ✅ Can include agent-runtime dependencies
350
+ - ✅ Can demonstrate real-world patterns
351
+ - ✅ Can evolve independently
352
+ - ✅ Clear separation of concerns
353
+
354
+ ### For Users:
355
+ - ✅ Don't confuse client vs agent
356
+ - ✅ Clear learning path
357
+ - ✅ Can find examples relevant to their domain
358
+ - ✅ Client stays stable while examples evolve
359
+
360
+ ---
361
+
362
+ ## README Section to Add
363
+
364
+ Add this section to `README.md`:
365
+
366
+ ```markdown
367
+ ## 🚫 What This Gem IS NOT
368
+
369
+ This gem is **NOT**:
370
+ - ❌ A chatbot UI framework
371
+ - ❌ A domain-specific agent implementation
372
+ - ❌ A tool execution engine
373
+ - ❌ A memory store
374
+ - ❌ A promise of full Ollama API coverage (focuses on agent workflows)
375
+
376
+ **Domain tools and application logic live outside this gem.**
377
+
378
+ ## 📚 Examples
379
+
380
+ ### Minimal Examples (In This Repo)
381
+
382
+ See `examples/` for minimal client usage examples:
383
+ - `basic_generate.rb` - Basic `/generate` usage
384
+ - `basic_chat.rb` - Basic `/chat` usage
385
+ - `tool_calling_parsing.rb` - Tool-call parsing (no execution)
386
+ - `tool_dto_example.rb` - Tool DTO serialization
387
+
388
+ ### Full Agent Examples (Separate Repo)
389
+
390
+ For complete agent examples (trading agents, coding agents, RAG agents, multi-step workflows, etc.),
391
+ see: [ollama-agent-examples](https://github.com/shubhamtaywade82/ollama-agent-examples)
392
+
393
+ This separation keeps `ollama-client` focused on the transport layer while providing
394
+ comprehensive examples for agent developers.
395
+ ```
396
+
397
+ ---
398
+
399
+ ## Summary
400
+
401
+ **Keep in `ollama-client`:**
402
+ - ✅ `examples/basic_generate.rb` (create)
403
+ - ✅ `examples/basic_chat.rb` (create)
404
+ - ✅ `examples/tool_calling_parsing.rb` (create or rename)
405
+ - ✅ `examples/tool_dto_example.rb` (keep)
406
+
407
+ **Move to `ollama-agent-examples`:**
408
+ - ❌ Everything else in `examples/`
409
+
410
+ **Update:**
411
+ - ✅ `README.md` - Add minimal examples inline, link to separate repo
412
+ - ✅ `examples/README.md` - Reflect minimal examples only
@@ -43,7 +43,18 @@ client = Ollama::Client.new(config: config)
43
43
  **Usage**:
44
44
  ```ruby
45
45
  options = Ollama::Options.new(temperature: 0.7, top_p: 0.95)
46
- client.generate(prompt: "...", schema: {...}, options: options.to_h)
46
+ # Use with chat() - chat() accepts options parameter
47
+ client.chat(
48
+ messages: [{ role: "user", content: "..." }],
49
+ format: {...},
50
+ options: options.to_h,
51
+ allow_chat: true
52
+ )
53
+
54
+ # Note: generate() doesn't accept options - use config instead
55
+ # config = Ollama::Config.new
56
+ # config.temperature = 0.7
57
+ # client = Ollama::Client.new(config: config)
47
58
  ```
48
59
 
49
60
  **Files Added**: