llm_chain 0.5.2 → 0.5.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a926b1222ae2f5fda1d4562ade3663cf1b9d9aff0e1162f8c8c6b17ab817a27c
4
- data.tar.gz: 9a9c7ad9c081899e5ae014d0236eaf01cf93fa66fcdae2c439d18cf54e7de532
3
+ metadata.gz: 8c94520a98ace3d2bb61ca2b470af041e0f95d6818120ce01dfc5a9cfe76316b
4
+ data.tar.gz: 5155099cdf777ecaed3a30c9da1e7e200476258369ef3b976967888daf001876
5
5
  SHA512:
6
- metadata.gz: 0f6736ee81ee8cc057e7f283de27f7d7cda086a3161b2c0bd7b8b434542b9df3c52df905cbc4c561c069f47afbaa333f36f52fbbe9fac56a83fe766a165c71f2
7
- data.tar.gz: 17750148dce41dd667b24621d1e19051f9ff253213a72ef4e79ffda7d6291494c2db79a88215257f0afb69b4a857583e734e9872fa515e10d7879d5b62f139cb
6
+ metadata.gz: b37c6ed16c6b6a66d1f9c6e2a62717e576c5211aba605b98b97e5ba54b436d9a38602aabcedf34a23963ee034d6332dadefe03fa6c6a5d4d3f4941b2df9efd88
7
+ data.tar.gz: 4e5c3b6921e4f0656ea8266ca67a00dbcbc8c11736573df9172b8cb2d8821d3799f87085f31e7975d916d56c29f10a4637c6df5f102520fc2da3f5284143ef79
data/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.3] - 2025-07-05
11
+
12
+ ### Added
13
+ * **CLI Executable** (`llm-chain`) with commands:
14
+ * `chat` – one-off prompt
15
+ * `diagnose` – system diagnostics
16
+ * `tools list` – list default tools
17
+ * `repl` – interactive Read-Eval-Print Loop with in-memory history and helper slash-commands
18
+
19
+ ### Changed
20
+ * CLI autodetects Bundler only in development repo to avoid gem conflicts.
21
+
22
+ ### Fixed
23
+ * Version conflicts when running CLI inside unrelated Bundler projects.
24
+
10
25
  ## [0.5.2] - 2025-01-XX
11
26
 
12
27
  ### Added
@@ -68,7 +83,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
68
83
  ### Changed
69
84
  - Initial stable release with core functionality
70
85
 
71
- [Unreleased]: https://github.com/FuryCow/llm_chain/compare/v0.5.2...HEAD
86
+ [Unreleased]: https://github.com/FuryCow/llm_chain/compare/v0.5.3...HEAD
87
+ [0.5.3]: https://github.com/FuryCow/llm_chain/compare/v0.5.2...v0.5.3
72
88
  [0.5.2]: https://github.com/FuryCow/llm_chain/compare/v0.5.1...v0.5.2
73
89
  [0.5.1]: https://github.com/FuryCow/llm_chain/compare/v0.5.0...v0.5.1
74
90
  [0.5.0]: https://github.com/FuryCow/llm_chain/releases/tag/v0.5.0
data/README.md CHANGED
@@ -8,14 +8,16 @@
8
8
 
9
9
  LLMChain is a Ruby analog of LangChain, providing a unified interface for interacting with various LLMs, built-in tool system, and RAG (Retrieval-Augmented Generation) support.
10
10
 
11
- ## 🎉 What's New in v0.5.2
11
+ ## 🎉 What's New in v0.5.3
12
12
 
13
- - **System Diagnostics** - Built-in health checks with `LLMChain.diagnose_system`
14
- - **Configuration Validation** - Early detection of setup issues and helpful warnings
15
- - **Enhanced Error Handling** - Retry logic with exponential backoff for network requests
16
- - **Robust WebSearch** - Better timeout handling and graceful degradation
17
- - **Improved Code Extraction** - Enhanced support for various code block formats
18
- - **Debug Logging** - Structured logging with `LLM_CHAIN_DEBUG=true`
13
+ * 🖥️ **New CLI executable** `llm-chain`
14
+ * `chat` ask a one-off question from your shell
15
+ * `repl` interactive session with conversation memory and helper commands (`/help`, `/mem clear`, `/tools list`)
16
+ * `diagnose` run the built-in environment health-check
17
+ * `tools list` inspect available tools
18
+ * 🔄 **Bundler-aware loading** CLI detects if it’s executed inside the gem repo and avoids version clashes with external Gemfiles.
19
+
20
+ That’s all you need to start talking to LLMs straight from the terminal. See the **Command-line Interface** section below for usage examples.
19
21
 
20
22
  ## ✨ Key Features
21
23
 
@@ -80,6 +82,37 @@ response = chain.ask("Hello! How are you?")
80
82
  puts response
81
83
  ```
82
84
 
85
+ ## 🖥️ Command-line Interface (v0.5.3+)
86
+
87
+ Alongside the Ruby API, LLMChain ships with a convenient CLI executable `llm-chain`.
88
+
89
+ ### Basic commands
90
+
91
+ ```bash
92
+ # One-off question
93
+ llm-chain chat "Hello! How are you?"
94
+
95
+ # Interactive REPL with conversation memory (/help in session)
96
+ llm-chain repl
97
+
98
+ # System diagnostics (same as LLMChain.diagnose_system)
99
+ llm-chain diagnose
100
+
101
+ # List default tools
102
+ llm-chain tools list
103
+
104
+ # Show gem version
105
+ llm-chain -v
106
+ ```
107
+
108
+ The CLI is installed automatically with the gem. If your shell doesn’t find the command, make sure RubyGems’ bindir is in your `$PATH` or use Bundler-aware launch:
109
+
110
+ ```bash
111
+ bundle exec llm-chain chat "…"
112
+ ```
113
+
114
+ Set `LLM_CHAIN_DEBUG=true` to print extra logs.
115
+
83
116
  ## 🔍 System Diagnostics (v0.5.2+)
84
117
 
85
118
  Before diving into development, it's recommended to check your system configuration:
data/exe/llm-chain ADDED
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Load Bundler only if running from the development repo (Gemfile present)
5
+ if File.exist?(File.expand_path("../../Gemfile", __dir__))
6
+ begin
7
+ require "bundler/setup"
8
+ rescue LoadError
9
+ warn "[llm-chain] Bundler not available; continuing without it"
10
+ end
11
+ end
12
+
13
+ require "llm_chain"
14
+ require "optparse"
15
+ require "readline"
16
+
17
+ USAGE = <<~TEXT.freeze
18
+ Usage: llm-chain <command> [options]
19
+
20
+ Commands:
21
+ chat <prompt> Send prompt to quick_chain and print response
22
+ repl Start interactive REPL session
23
+ diagnose Run system diagnostics
24
+ tools list List registered tools in the default toolset
25
+ version Print LLMChain gem version
26
+
27
+ Environment variables:
28
+ LLM_CHAIN_DEBUG Enable verbose diagnostic logs
29
+ TEXT
30
+
31
+ # Exit with usage if no command
32
+ if ARGV.empty?
33
+ warn USAGE
34
+ exit 1
35
+ end
36
+
37
+ command = ARGV.shift
38
+
39
+ case command
40
+ when "repl"
41
+ puts "LLMChain REPL — type /help for commands, /exit to quit"
42
+ chain = LLMChain.quick_chain
43
+
44
+ loop do
45
+ line = Readline.readline("> ", true)
46
+ break if line.nil? || line.strip == "/exit" || line.strip == "/quit"
47
+
48
+ case line.strip
49
+ when "/help"
50
+ puts "/exit Exit REPL\n" \
51
+ "/mem clear Clear conversation memory\n" \
52
+ "/tools list List available tools"
53
+ next
54
+ when "/mem clear"
55
+ chain.memory.clear if chain.memory.respond_to?(:clear)
56
+ puts "[memory cleared]"
57
+ next
58
+ when "/tools list"
59
+ if chain.tools.respond_to?(:tools_description)
60
+ puts chain.tools.tools_description
61
+ else
62
+ puts "No ToolManager attached"
63
+ end
64
+ next
65
+ end
66
+
67
+ # Empty input => skip
68
+ next if line.strip.empty?
69
+
70
+ begin
71
+ response = chain.ask(line)
72
+ puts response
73
+ rescue => e
74
+ warn "Error: #{e.message}"
75
+ end
76
+ end
77
+
78
+ puts "Bye!"
79
+
80
+ when "chat"
81
+ # Collect prompt from remaining args or STDIN
82
+ prompt = if ARGV.empty?
83
+ puts "Enter prompt (end with CTRL+D):"
84
+ STDIN.read
85
+ else
86
+ ARGV.join(" ")
87
+ end
88
+ if prompt.nil? || prompt.strip.empty?
89
+ warn "No prompt provided"
90
+ exit 1
91
+ end
92
+
93
+ begin
94
+ chain = LLMChain.quick_chain
95
+ response = chain.ask(prompt)
96
+ puts "\n=== Response ===\n"
97
+ puts response
98
+ rescue Interrupt
99
+ warn "Interrupted"
100
+ rescue => e
101
+ warn "Error: #{e.message}"
102
+ exit 1
103
+ end
104
+
105
+ when "diagnose"
106
+ LLMChain.diagnose_system
107
+
108
+ when "tools"
109
+ sub = ARGV.shift
110
+ case sub
111
+ when "list"
112
+ tm = LLMChain::Tools::ToolManager.create_default_toolset
113
+ puts tm.tools_description
114
+ else
115
+ warn "Unknown tools subcommand"; warn USAGE
116
+ exit 1
117
+ end
118
+
119
+ when "version", "--version", "-v"
120
+ puts LlmChain::VERSION
121
+
122
+ else
123
+ warn "Unknown command: #{command}"
124
+ warn USAGE
125
+ exit 1
126
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LlmChain
4
- VERSION = "0.5.2"
4
+ VERSION = "0.5.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm_chain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - FuryCow
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-06-30 00:00:00.000000000 Z
11
+ date: 2025-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -111,7 +111,8 @@ dependencies:
111
111
  description:
112
112
  email:
113
113
  - dreamweaver0408@gmail.com
114
- executables: []
114
+ executables:
115
+ - llm-chain
115
116
  extensions: []
116
117
  extra_rdoc_files: []
117
118
  files:
@@ -124,6 +125,7 @@ files:
124
125
  - Rakefile
125
126
  - examples/quick_demo.rb
126
127
  - examples/tools_example.rb
128
+ - exe/llm-chain
127
129
  - lib/llm_chain.rb
128
130
  - lib/llm_chain/chain.rb
129
131
  - lib/llm_chain/client_registry.rb