llm_ruby 0.3.1 → 0.3.2

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: d377d13dd257a9b4a6def17668d3bb3badf4692f9e865faba142d5189d746519
4
- data.tar.gz: a201962fb8dd4f245face648cc433e127afcc22832cb1499da89db2bc2816d7e
3
+ metadata.gz: 44e89bad9131f49c40cf578fac3790c1e3e5f266aead751ecea606ac2a4ad5aa
4
+ data.tar.gz: 03ccc6124c9c3d92dda0828100cec0c9beb0d4bb90baa464c47640528265cc3c
5
5
  SHA512:
6
- metadata.gz: 10a190d6b7f4aa364c17d91b383a744fd490b94437ba4779c973e1f9bdc65d92f16d03c075d807d2a6aaf9509cf837736a0c48860c6ebc9d7c3dea6fb41eacd4
7
- data.tar.gz: a3e63a044316a257c1e429bf85882c86ff78d3af193a87a978e4552f3464cdb417c7ada8aaf35a3556672ea6e79196812dada4c25c2f9a624466981b195c2ad3
6
+ metadata.gz: c5bee46644a205067b9e33a749e042a971b066f978de234bec0841f89cea4aa8b3d2b42e0d890b073ad78ebd770416aaae2fbe5181e5e6926d59bd7b9c7dc58d
7
+ data.tar.gz: f35f5f988cb54f199d52e324385a0a16e1eee720585a6118d21459e4a1ad7e526f7e77618d0124ea4b35da18a0c078f6f00648cd90203bd5517806289956d2f1
data/CLAUDE.md ADDED
@@ -0,0 +1,22 @@
1
+ # LLM Ruby Development Guide
2
+
3
+ ## Build & Test Commands
4
+ - Setup: `bin/setup`
5
+ - Install locally: `bundle exec rake install`
6
+ - Run all tests: `bundle exec rake spec`
7
+ - Run single test: `bundle exec rspec spec/path/to_spec.rb:LINE_NUMBER`
8
+ - Run linter: `bundle exec rake standard`
9
+ - Interactive console: `bin/console`
10
+
11
+ ## Code Style Guidelines
12
+ - Use `frozen_string_literal: true` at the top of all Ruby files
13
+ - Follow Standard Ruby style (`standard` gem)
14
+ - Naming: snake_case for methods/variables, CamelCase for classes
15
+ - Use double quotes consistently for strings
16
+ - Explicit returns are optional (prefer implicit returns when possible)
17
+ - Class organization: constants first, then class methods, then initialize, then instance methods
18
+ - Keep methods and classes small and focused (single responsibility)
19
+ - Cover all code with tests in the `spec` directory
20
+ - API credentials should be read from environment variables
21
+ - Use proper type inflection (e.g., "llm" => "LLM", "open_ai" => "OpenAI")
22
+ - Use VCR/webmock for testing HTTP interactions
@@ -11,6 +11,7 @@ class LLM
11
11
 
12
12
  def initialize(llm:)
13
13
  @llm = llm
14
+ @logger = LLM.config.logger
14
15
  end
15
16
 
16
17
  def chat(messages, options = {})
@@ -95,7 +96,10 @@ class LLM
95
96
  end
96
97
 
97
98
  def post_url(url, **kwargs)
98
- self.class.post(url, **kwargs.merge(headers: default_headers))
99
+ @logger.debug("Request: #{kwargs.inspect}")
100
+ resp = self.class.post(url, **kwargs.merge(headers: default_headers))
101
+ @logger.debug("Response: #{resp.body}")
102
+ resp
99
103
  end
100
104
 
101
105
  def post_url_streaming(url, **kwargs, &block)
data/lib/llm/config.rb ADDED
@@ -0,0 +1,12 @@
1
+ require "logger"
2
+
3
+ class LLM
4
+ class Config
5
+ attr_accessor :logger
6
+
7
+ def initialize
8
+ @logger = ::Logger.new($stderr)
9
+ @logger.level = ::Logger::INFO
10
+ end
11
+ end
12
+ end
data/lib/llm.rb CHANGED
@@ -33,6 +33,10 @@ class LLM
33
33
  @supports_structured_outputs
34
34
  end
35
35
 
36
+ def self.config
37
+ @config ||= LLM::Config.new
38
+ end
39
+
36
40
  private
37
41
 
38
42
  attr_reader :client_class
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Gamble
@@ -51,6 +51,20 @@ dependencies:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: 2.6.0
54
+ - !ruby/object:Gem::Dependency
55
+ name: logger
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 1.6.0
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 1.6.0
54
68
  - !ruby/object:Gem::Dependency
55
69
  name: dotenv
56
70
  requirement: !ruby/object:Gem::Requirement
@@ -141,6 +155,7 @@ extra_rdoc_files: []
141
155
  files:
142
156
  - ".rspec"
143
157
  - ".standard.yml"
158
+ - CLAUDE.md
144
159
  - LICENSE.txt
145
160
  - README.md
146
161
  - Rakefile
@@ -152,6 +167,7 @@ files:
152
167
  - lib/llm/clients/gemini/response.rb
153
168
  - lib/llm/clients/open_ai.rb
154
169
  - lib/llm/clients/open_ai/response.rb
170
+ - lib/llm/config.rb
155
171
  - lib/llm/info.rb
156
172
  - lib/llm/provider.rb
157
173
  - lib/llm/response.rb