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 +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +6 -0
- data/README.md +2 -2
- data/examples/basic_usage.rb +2 -2
- data/lib/llm_hub/common/client_base.rb +1 -1
- data/lib/llm_hub/completion/client.rb +3 -2
- data/lib/llm_hub/completion/providers/anthropic.rb +3 -1
- data/lib/llm_hub/completion/providers/deepseek.rb +17 -0
- data/lib/llm_hub/completion/providers/openai.rb +1 -1
- data/lib/llm_hub/version.rb +1 -1
- data/lib/llm_hub.rb +1 -0
- metadata +7 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c791bf83c85b80125da4cf8a71eab51d804f21f0f29d128f27710c6bd0e9c621
|
4
|
+
data.tar.gz: 244a67dd97fd68b97a345971a7e806520c83f6906f9d50362ad2dc8b29086253
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a64411fb25ba585dffc8251414231871ff173d89a16e06c4c0b0d6c8bf00fcb859bcf5f7ff0bec7c653ca5249fa48b1d70e03ee507dbc82851d1f4b8c02a3e5c
|
7
|
+
data.tar.gz: 89e38e3d90d585b56809a5fb7e18f4e7257fa4f8675e7172a622ef56f222175b2d68b1b60f73a8f6e50a391b121e8e7523f014fe0af79c98e4f57881d7c35eef
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# LlmHub
|
2
2
|
|
3
|
-
|
3
|
+
This is a Ruby interface for multiple LLM providers, such as OpenAI, Anthropic, and DeepSeek.
|
4
4
|
|
5
|
-
|
5
|
+
It provides easy access to Completion and Embedding functionalities.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
data/examples/basic_usage.rb
CHANGED
@@ -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
|
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
|
32
|
+
api_key: ENV.fetch('OPENAI_API_KEY', nil),
|
33
33
|
provider: :openai
|
34
34
|
)
|
35
35
|
|
@@ -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')
|
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
|
data/lib/llm_hub/version.rb
CHANGED
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.
|
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-
|
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
|
-
|
41
|
-
|
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:
|
94
|
+
summary: This is a Ruby interface for multiple LLM providers, such as OpenAI and Anthropic.
|
135
95
|
test_files: []
|