llm_hub 0.1.0 → 0.2.0

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: 8dd3ffff8762625d2ab27200f05b3e6e2d1c4b79aa458a1497d208eda656db38
4
- data.tar.gz: 9e98d2e9bf3a1afb8d071e7740a4aef5c10bfb719f03ac51745609c3dd382a55
3
+ metadata.gz: c791bf83c85b80125da4cf8a71eab51d804f21f0f29d128f27710c6bd0e9c621
4
+ data.tar.gz: 244a67dd97fd68b97a345971a7e806520c83f6906f9d50362ad2dc8b29086253
5
5
  SHA512:
6
- metadata.gz: 5a353fcd5c607bd96c30dbdb41103d92cf042c04c04d7b2a1f3982961f52f2e3d60241cf02237f1ac93bfab76e80c6e724ea50e830633e22f5f5bd2d426bf184
7
- data.tar.gz: '08262623da034f3091866f2c0e3e983731145091016533f902af1d7e8140de0e24f1c3480dd9e5d35752f4ed6eeb497694329823b914bfb5056a3461e7852bf4'
6
+ metadata.gz: a64411fb25ba585dffc8251414231871ff173d89a16e06c4c0b0d6c8bf00fcb859bcf5f7ff0bec7c653ca5249fa48b1d70e03ee507dbc82851d1f4b8c02a3e5c
7
+ data.tar.gz: 89e38e3d90d585b56809a5fb7e18f4e7257fa4f8675e7172a622ef56f222175b2d68b1b60f73a8f6e50a391b121e8e7523f014fe0af79c98e4f57881d7c35eef
data/.rubocop.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 3.1
3
+ NewCops: enable
4
+ SuggestExtensions: false
3
5
 
4
6
  Style/StringLiterals:
5
7
  EnforcedStyle: single_quotes
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2025-05-30
4
+
5
+ - Updated description in README.md
6
+
7
+ - Updated RuboCop configuration and fixed all offenses.
8
+
3
9
  ## [0.1.0] - 2025-05-30
4
10
 
5
11
  - Initial release
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # LlmHub
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ This is a Ruby interface for multiple LLM providers, such as OpenAI, Anthropic, and DeepSeek.
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/llm_hub`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ It provides easy access to Completion and Embedding functionalities.
6
6
 
7
7
  ## Installation
8
8
 
@@ -6,7 +6,7 @@ require 'llm_hub'
6
6
 
7
7
  # Completion example using OpenAI's GPT-4o-mini model
8
8
  client = LlmHub::Completion::Client.new(
9
- api_key: ENV['OPENAI_API_KEY'],
9
+ api_key: ENV.fetch('OPENAI_API_KEY', nil),
10
10
  provider: :openai
11
11
  )
12
12
 
@@ -29,7 +29,7 @@ puts response[:answer] if response[:answer]
29
29
 
30
30
  # Embedding example using OpenAI's text-embedding-3-small model
31
31
  embedding_client = LlmHub::Embedding::Client.new(
32
- api_key: ENV['OPENAI_API_KEY'],
32
+ api_key: ENV.fetch('OPENAI_API_KEY', nil),
33
33
  provider: :openai
34
34
  )
35
35
 
@@ -33,7 +33,7 @@ module LlmHub
33
33
  provider_class.new(@api_key)
34
34
  end
35
35
 
36
- def with_retry(&_block)
36
+ def with_retry(&)
37
37
  retries = 0
38
38
  begin
39
39
  yield
@@ -8,12 +8,13 @@ module LlmHub
8
8
  # @return [Hash<Symbol, Class>] mapping of provider names to their classes
9
9
  PROVIDER_CLASSES = {
10
10
  openai: Providers::OpenAI,
11
- anthropic: Providers::Anthropic
11
+ anthropic: Providers::Anthropic,
12
+ deepseek: Providers::Deepseek
12
13
  }.freeze
13
14
 
14
15
  # Initialize a new completion client
15
16
  # @param api_key [String] API key for the provider (required)
16
- # @param provider [Symbol, String] Provider name (:openai, :anthropic) (required)
17
+ # @param provider [Symbol, String] Provider name (:openai, :anthropic, :deepseek) (required)
17
18
  # @see LlmHub::Common::ClientBase#initialize
18
19
  def initialize(api_key:, provider:)
19
20
  super
@@ -33,7 +33,9 @@ module LlmHub
33
33
  end
34
34
 
35
35
  def extract_answer(response_body)
36
- response_body&.dig('content')&.first&.dig('text')
36
+ content_array = response_body&.dig('content')
37
+ first_content = content_array&.first
38
+ first_content&.dig('text')
37
39
  end
38
40
 
39
41
  def extract_tokens(response_body)
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LlmHub
4
+ module Completion
5
+ module Providers
6
+ # DeepSeek completion provider
7
+ # Inherits from OpenAI provider since DeepSeek uses OpenAI-compatible API
8
+ class Deepseek < OpenAI
9
+ COMPLETIONS_URI = 'https://api.deepseek.com/v1/chat/completions'
10
+
11
+ def url
12
+ COMPLETIONS_URI
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -32,7 +32,7 @@ module LlmHub
32
32
  choices = response_body&.dig('choices')
33
33
  return nil if choices.nil? || choices.empty?
34
34
 
35
- choices[0]&.dig('message')&.dig('content')
35
+ choices[0]&.dig('message', 'content')
36
36
  end
37
37
 
38
38
  def extract_tokens(response_body)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LlmHub
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/llm_hub.rb CHANGED
@@ -18,6 +18,7 @@ require_relative 'llm_hub/common/client_base'
18
18
  require_relative 'llm_hub/completion/providers/base'
19
19
  require_relative 'llm_hub/completion/providers/openai'
20
20
  require_relative 'llm_hub/completion/providers/anthropic'
21
+ require_relative 'llm_hub/completion/providers/deepseek'
21
22
  require_relative 'llm_hub/completion/client'
22
23
 
23
24
  # Embedding providers
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm_hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - akiraNuma
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-05-29 00:00:00.000000000 Z
10
+ date: 2025-06-17 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -37,50 +37,8 @@ dependencies:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
- - !ruby/object:Gem::Dependency
41
- name: rake
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '13.0'
47
- type: :development
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '13.0'
54
- - !ruby/object:Gem::Dependency
55
- name: rspec
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '3.0'
61
- type: :development
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '3.0'
68
- - !ruby/object:Gem::Dependency
69
- name: rubocop
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '1.21'
75
- type: :development
76
- prerelease: false
77
- version_requirements: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '1.21'
82
- description: A Ruby interface for multiple LLM providers like OpenAI and Anthropic.
83
- Provides easy access to Completion and Embedding functionalities.
40
+ description: This is a Ruby interface for multiple LLM providers, such as OpenAI and
41
+ Anthropic.It provides easy access to Completion and Embedding functionalities.
84
42
  email:
85
43
  - akiran@akiranumakura.com
86
44
  executables: []
@@ -101,6 +59,7 @@ files:
101
59
  - lib/llm_hub/completion/client.rb
102
60
  - lib/llm_hub/completion/providers/anthropic.rb
103
61
  - lib/llm_hub/completion/providers/base.rb
62
+ - lib/llm_hub/completion/providers/deepseek.rb
104
63
  - lib/llm_hub/completion/providers/openai.rb
105
64
  - lib/llm_hub/config.rb
106
65
  - lib/llm_hub/embedding/client.rb
@@ -115,6 +74,7 @@ metadata:
115
74
  homepage_uri: https://github.com/akiraNuma/llm_hub
116
75
  source_code_uri: https://github.com/akiraNuma/llm_hub
117
76
  changelog_uri: https://github.com/akiraNuma/llm_hub/blob/main/CHANGELOG.md
77
+ rubygems_mfa_required: 'true'
118
78
  rdoc_options: []
119
79
  require_paths:
120
80
  - lib
@@ -131,5 +91,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
91
  requirements: []
132
92
  rubygems_version: 3.6.3
133
93
  specification_version: 4
134
- summary: A Ruby interface for multiple LLM providers like OpenAI and Anthropic.
94
+ summary: This is a Ruby interface for multiple LLM providers, such as OpenAI and Anthropic.
135
95
  test_files: []