deepseek-rails 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 96548579565e97fa0e450061a14fd4f819f960e6aa5b221d1ca1489994cfc729
4
+ data.tar.gz: 1d343e832da359be4f8709d28e4fcee7b3b3dc56ec265b1de344b52e99337a7f
5
+ SHA512:
6
+ metadata.gz: afc5fda0e77eb2252dd8fcd8371c4cdf1db4d716c05d1d8bc48783df0aab9d789f55ac0a187022085ec1c7e3b15a112cf56f3fb7118bad03b10ac83a4caacbbe
7
+ data.tar.gz: 72bc1b5869a277db1d05b3886c490933a3009801a955e20cc223f231d474e767839407a3b3fdc1371d4c8cf565c9cbaf2dfcbe2146fc17ec9d8253754eff9279
data/README.md ADDED
@@ -0,0 +1,39 @@
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).
@@ -0,0 +1,35 @@
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
data/lib/deepseek.rb ADDED
@@ -0,0 +1,47 @@
1
+ require 'net/http'
2
+ require 'json'
3
+ module Deepseek
4
+ VERSION = "0.1.0"
5
+ class Client
6
+ BASE_URI = URI('https://api.deepseek.com')
7
+ def initialize
8
+ end
9
+
10
+ def chat(parameters:)
11
+ uri = BASE_URI + '/chat/completions'
12
+ request = Net::HTTP::Post.new(uri, headers)
13
+ request.body = parameters.to_json
14
+
15
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
16
+ http.request(request)
17
+ end
18
+ JSON.parse(response.body)
19
+
20
+ rescue StandardError => e
21
+ raise DeepseekClientError, e.message
22
+ end
23
+
24
+ private
25
+
26
+ def headers
27
+ {
28
+ 'Content-Type' => 'application/json',
29
+ 'Authorization' => "Bearer #{Deepseek.configuration.api_key}"
30
+ }
31
+ end
32
+ end
33
+ class DeepseekClientError < StandardError; end
34
+
35
+ class Configuration
36
+ attr_accessor :api_key
37
+ end
38
+
39
+ class << self
40
+ attr_accessor :configuration
41
+ end
42
+
43
+ def self.configure
44
+ self.configuration ||= Configuration.new
45
+ yield(configuration)
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: deepseek-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - amr elhewi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-01-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - amrelhewi@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.md
21
+ - deepseek-rails.gemspec
22
+ - lib/deepseek.rb
23
+ homepage: https://github.com/amrelhewy09/deepseek-rails
24
+ licenses:
25
+ - MIT
26
+ metadata:
27
+ allowed_push_host: https://rubygems.org
28
+ homepage_uri: https://github.com/amrelhewy09/deepseek-rails
29
+ source_code_uri: https://github.com/amrelhewy09/deepseek-rails
30
+ changelog_uri: https://github.com/amrelhewy09/deepseek-rails
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 3.0.0
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubygems_version: 3.5.3
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Deepseek wrapper for ruby
50
+ test_files: []