deepseek-rails 0.1.0 → 0.3.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: 96548579565e97fa0e450061a14fd4f819f960e6aa5b221d1ca1489994cfc729
4
- data.tar.gz: 1d343e832da359be4f8709d28e4fcee7b3b3dc56ec265b1de344b52e99337a7f
3
+ metadata.gz: 181f2ead64127e55925a653f8e2fa1fae5f29a9c915afdedcf4ac6428a723002
4
+ data.tar.gz: 51fd9ea8f06539d47cb7b25f190b08e0b59c5b31713befdbf857439239435971
5
5
  SHA512:
6
- metadata.gz: afc5fda0e77eb2252dd8fcd8371c4cdf1db4d716c05d1d8bc48783df0aab9d789f55ac0a187022085ec1c7e3b15a112cf56f3fb7118bad03b10ac83a4caacbbe
7
- data.tar.gz: 72bc1b5869a277db1d05b3886c490933a3009801a955e20cc223f231d474e767839407a3b3fdc1371d4c8cf565c9cbaf2dfcbe2146fc17ec9d8253754eff9279
6
+ metadata.gz: ed883603f93b873228c68ae96818df0d7d8945f25f745e2854eec66a6610fb7c8d61fe8d0ea8df9545e03541bd7208ac356867d0f2a2245549afba10050f1232
7
+ data.tar.gz: 222df004de41e954bf851282c942cf1aeccf6d6a9558d43014b9f4eb5ea68160125a729d4481c5f8ea05f73c730e4afaace74fd9b3104ae68db0612f41342c9c
data/lib/deepseek.rb CHANGED
@@ -1,23 +1,29 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
3
  module Deepseek
4
- VERSION = "0.1.0"
4
+ VERSION = "0.3.0"
5
+ class << self
6
+ attr_accessor :configuration
7
+ end
5
8
  class Client
6
- BASE_URI = URI('https://api.deepseek.com')
7
9
  def initialize
8
10
  end
9
11
 
10
12
  def chat(parameters:)
11
- uri = BASE_URI + '/chat/completions'
13
+ base_uri = URI(Deepseek.configuration.base_uri || "https://api.deepseek.com")
14
+ uri = base_uri + '/chat/completions'
12
15
  request = Net::HTTP::Post.new(uri, headers)
13
16
  request.body = parameters.to_json
14
17
 
15
18
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
16
19
  http.request(request)
17
20
  end
18
- JSON.parse(response.body)
21
+ if response.is_a?(Net::HTTPSuccess)
22
+ raise DeepseekClientError, "empty response" if response.body.empty?
23
+ JSON.parse(response.body)
24
+ end
19
25
 
20
- rescue StandardError => e
26
+ rescue Net::ReadTimeout => e
21
27
  raise DeepseekClientError, e.message
22
28
  end
23
29
 
@@ -33,11 +39,9 @@ module Deepseek
33
39
  class DeepseekClientError < StandardError; end
34
40
 
35
41
  class Configuration
36
- attr_accessor :api_key
37
- end
38
-
39
- class << self
40
- attr_accessor :configuration
42
+ attr_accessor :api_key, :base_uri
43
+ def initialize
44
+ end
41
45
  end
42
46
 
43
47
  def self.configure
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deepseek-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - amr elhewi
@@ -17,8 +17,6 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - README.md
21
- - deepseek-rails.gemspec
22
20
  - lib/deepseek.rb
23
21
  homepage: https://github.com/amrelhewy09/deepseek-rails
24
22
  licenses:
data/README.md DELETED
@@ -1,39 +0,0 @@
1
- # Deepseek::Rails
2
-
3
- TODO: Delete this and the text below, and describe your gem
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/deepseek/rails`. To experiment with that code, run `bin/console` for an interactive prompt.
6
-
7
- ## Installation
8
-
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
- Install the gem and add to the application's Gemfile by executing:
12
-
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
-
15
- If bundler is not being used to manage dependencies, install the gem by executing:
16
-
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Development
24
-
25
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
-
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
-
29
- ## Contributing
30
-
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/deepseek-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/deepseek-rails/blob/master/CODE_OF_CONDUCT.md).
32
-
33
- ## License
34
-
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
-
37
- ## Code of Conduct
38
-
39
- Everyone interacting in the Deepseek::Rails project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/deepseek-rails/blob/master/CODE_OF_CONDUCT.md).
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/deepseek"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "deepseek-rails"
7
- spec.version = Deepseek::VERSION
8
- spec.authors = ["amr elhewi"]
9
- spec.email = ["amrelhewi@gmail.com"]
10
-
11
- spec.summary = "Deepseek wrapper for ruby"
12
- spec.homepage = "https://github.com/amrelhewy09/deepseek-rails"
13
- spec.license = "MIT"
14
- spec.required_ruby_version = ">= 3.0.0"
15
-
16
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
-
18
- spec.metadata["homepage_uri"] = spec.homepage
19
- spec.metadata["source_code_uri"] = "https://github.com/amrelhewy09/deepseek-rails"
20
- spec.metadata["changelog_uri"] = "https://github.com/amrelhewy09/deepseek-rails"
21
-
22
- # Specify which files should be added to the gem when it is released.
23
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
- gemspec = File.basename(__FILE__)
25
- spec.files = Dir.glob("lib/**/*") + ["deepseek-rails.gemspec", "README.md"]
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
29
-
30
- # Uncomment to register a new dependency of your gem
31
- # spec.add_dependency "example-gem", "~> 1.0"
32
-
33
- # For more information and examples about making a new gem, check out our
34
- # guide at: https://bundler.io/guides/creating_gem.html
35
- end