deepseek 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 823ad4a8bdbaf752fc67f3feb383b82af8e6db6e6326ccb91a706bc7ace1c03a
4
+ data.tar.gz: e6ed60fcd0459a4b7a3e97e549fb7fe353990386469373c0d23fb0e814cb088d
5
+ SHA512:
6
+ metadata.gz: 588915292147e72f42aec939c8f7ccec5afe3d56562470186855d356f8c4079f28329399e833e8f5a7c6b634de66be3dfb1e86ab42a24e62cba9844b263766b4
7
+ data.tar.gz: a4f648e7ca329f565ed43b280910437cc9ed3e3e8623e310075f3edc68524fb1a367e5ce0a8a0ffbacafecb8c4f62ba052cbb760af13734676b8db842636acaf
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/standardrb/standard
3
+ ruby_version: 3.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-01-26
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Adrián Mugnolo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Deepseek
2
+
3
+ A Ruby client for accessing the DeepSeek API.
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ ```bash
10
+ bundle add deepseek
11
+ ```
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by
14
+ executing:
15
+
16
+ ```bash
17
+ gem install deepseek
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```ruby
23
+ client = Deepseek::Client.new("your-api-key")
24
+
25
+ response = client.chat_completions(
26
+ model: "deepseek-chat",
27
+ messages: [{role: "user", content: "Hello, world!"}]
28
+ )
29
+ ```
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
34
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
35
+ prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To
38
+ release a new version, update the version number in `version.rb`, and then run
39
+ `bundle exec rake release`, which will create a git tag for the version, push
40
+ git commits and the created tag, and push the `.gem` file to
41
+ [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at
46
+ https://github.com/xymbol/deepseek-ruby.
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT
51
+ License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[test standard]
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+
5
+ module Deepseek
6
+ DEFAULT_URL = "https://api.deepseek.com"
7
+ BETA_URL = "https://api.deepseek.com/beta"
8
+
9
+ class Client
10
+ def initialize(api_key = nil, url = DEFAULT_URL)
11
+ @api_key = api_key || ENV.fetch("DEEPSEEK_API_KEY")
12
+ @url = url
13
+ end
14
+
15
+ def self.beta
16
+ new(nil, BETA_URL)
17
+ end
18
+
19
+ def chat_completions(params)
20
+ handle_response(conn.post("chat/completions", params))
21
+ end
22
+
23
+ def fim_completions(params)
24
+ handle_response(conn.post("completions", params))
25
+ end
26
+
27
+ def models
28
+ handle_response(conn.get("models"))
29
+ end
30
+
31
+ def user_balance
32
+ handle_response(conn.get("user/balance"))
33
+ end
34
+
35
+ private
36
+
37
+ def conn
38
+ @conn ||= Faraday.new(url: @url) do |conn|
39
+ conn.request :json
40
+ conn.response :json
41
+ conn.headers["Authorization"] = "Bearer #{@api_key}"
42
+ conn.headers["Content-Type"] = "application/json"
43
+ conn.adapter Faraday.default_adapter
44
+ end
45
+ end
46
+
47
+ def handle_response(response)
48
+ if response.status == 200
49
+ response.body
50
+ else
51
+ raise Deepseek::Error, "Request failed with status #{response.status}: #{response.body}"
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deepseek
4
+ VERSION = "0.1.0"
5
+ end
data/lib/deepseek.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "deepseek/version"
4
+ require_relative "deepseek/client"
5
+
6
+ module Deepseek
7
+ class Error < StandardError; end
8
+ end
9
+
10
+ DeepSeek = Deepseek
data/sig/deepseek.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Deepseek
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: deepseek
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Adrián Mugnolo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-01-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.12'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.12.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.12'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.12.2
33
+ description: DeepSeek is a Chinese artificial intelligence company which develops
34
+ open-source large language models.
35
+ email:
36
+ - adrian@mugnolo.com
37
+ executables: []
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - ".standard.yml"
42
+ - CHANGELOG.md
43
+ - LICENSE.txt
44
+ - README.md
45
+ - Rakefile
46
+ - lib/deepseek.rb
47
+ - lib/deepseek/client.rb
48
+ - lib/deepseek/version.rb
49
+ - sig/deepseek.rbs
50
+ homepage: https://github.com/xymbol/deepseek-ruby
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ homepage_uri: https://github.com/xymbol/deepseek-ruby
55
+ source_code_uri: https://github.com/xymbol/deepseek-ruby
56
+ changelog_uri: https://github.com/xymbol/deepseek-ruby/blob/main/CHANGELOG.md
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 3.3.7
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubygems_version: 3.5.22
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: A Ruby client for accessing the DeepSeek API
76
+ test_files: []