tiktoken_ruby 0.0.1-arm64-darwin

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: 8a4182b92c79feaaf48cbfd5ce091d236feb2f5f270c5ec120227400e926e761
4
+ data.tar.gz: 2b5461a05e44abbbdc0da362b04e6ff533e3fa4a7f85375c474c388e37fa3ee2
5
+ SHA512:
6
+ metadata.gz: ea2c9d70cb19c51e9f593d803fe74db4fcc8cfc990df60214605cf58bffd4fbd99c47ad06083d5546434bc04626302f88d6a8cc65e2651320acea7648433f785
7
+ data.tar.gz: b94d2bda0d5806e24a5d1baf80cbe08185e8f7a526e6c441487bafad9dd2f8cd53c0b421e81d068499c07427a192c64cef72b5cfe1288df9f12e51d016d96a95
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.6
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in tiktoken_ruby.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rake-compiler"
11
+ gem "rb_sys"
12
+
13
+ gem "rspec", "~> 3.0"
14
+
15
+ gem "standard", "~> 1.3"
16
+ gem 'pry', '~> 0.14.2'
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tiktoken_ruby (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ coderay (1.1.3)
11
+ diff-lcs (1.5.0)
12
+ json (2.6.3)
13
+ language_server-protocol (3.17.0.3)
14
+ method_source (1.0.0)
15
+ parallel (1.22.1)
16
+ parser (3.2.1.1)
17
+ ast (~> 2.4.1)
18
+ pry (0.14.2)
19
+ coderay (~> 1.1)
20
+ method_source (~> 1.0)
21
+ rainbow (3.1.1)
22
+ rake (13.0.6)
23
+ rake-compiler (1.2.1)
24
+ rake
25
+ rb_sys (0.9.68)
26
+ regexp_parser (2.7.0)
27
+ rexml (3.2.5)
28
+ rspec (3.12.0)
29
+ rspec-core (~> 3.12.0)
30
+ rspec-expectations (~> 3.12.0)
31
+ rspec-mocks (~> 3.12.0)
32
+ rspec-core (3.12.1)
33
+ rspec-support (~> 3.12.0)
34
+ rspec-expectations (3.12.2)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.12.0)
37
+ rspec-mocks (3.12.4)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.12.0)
40
+ rspec-support (3.12.0)
41
+ rubocop (1.48.1)
42
+ json (~> 2.3)
43
+ parallel (~> 1.10)
44
+ parser (>= 3.2.0.0)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.8, < 3.0)
47
+ rexml (>= 3.2.5, < 4.0)
48
+ rubocop-ast (>= 1.26.0, < 2.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 2.4.0, < 3.0)
51
+ rubocop-ast (1.27.0)
52
+ parser (>= 3.2.1.0)
53
+ rubocop-performance (1.16.0)
54
+ rubocop (>= 1.7.0, < 2.0)
55
+ rubocop-ast (>= 0.4.0)
56
+ ruby-progressbar (1.13.0)
57
+ standard (1.25.1)
58
+ language_server-protocol (~> 3.17.0.2)
59
+ rubocop (= 1.48.1)
60
+ rubocop-performance (= 1.16.0)
61
+ unicode-display_width (2.4.2)
62
+
63
+ PLATFORMS
64
+ arm64-darwin-22
65
+ x86_64-linux
66
+
67
+ DEPENDENCIES
68
+ pry (~> 0.14.2)
69
+ rake (~> 13.0)
70
+ rake-compiler
71
+ rb_sys
72
+ rspec (~> 3.0)
73
+ standard (~> 1.3)
74
+ tiktoken_ruby!
75
+
76
+ BUNDLED WITH
77
+ 2.4.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 IAPark
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,34 @@
1
+ # tiktoken_ruby
2
+
3
+ [Tiktoken](https://github.com/openai/tiktoken) is BPE tokenizer from OpenAI used with their GPT models.
4
+ This is a wrapper around it aimed primarily at enabling accurate counts of GPT model tokens used.
5
+
6
+ ## Installation
7
+
8
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_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.
9
+
10
+ Install the gem and add to the application's Gemfile by executing:
11
+
12
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
13
+
14
+ If bundler is not being used to manage dependencies, install the gem by executing:
15
+
16
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
17
+
18
+ ## Usage
19
+
20
+ TODO: Write usage instructions here
21
+
22
+ ## Development
23
+
24
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
25
+
26
+ 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).
27
+
28
+ ## Contributing
29
+
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tiktoken_ruby.
31
+
32
+ ## License
33
+
34
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "standard/rake"
6
+ require "rake/extensiontask"
7
+ require "rb_sys/extensiontask"
8
+
9
+ GEMSPEC = Gem::Specification.load("tiktoken_ruby.gemspec")
10
+
11
+ RbSys::ExtensionTask.new("tiktoken_ruby", GEMSPEC) do |ext|
12
+ ext.lib_dir = "lib/tiktoken_ruby"
13
+ end
14
+
15
+ RSpec::Core::RakeTask.new(:spec)
16
+
17
+
18
+ task :native, [:platform] do |_t, platform:|
19
+ sh "bundle", "exec", "rb-sys-dock", "--platform", platform, "--build"
20
+ end
21
+
22
+ task build: :compile
23
+
24
+ task default: %i[compile spec standard]
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Tiktoken::Encoding
4
+ def self.method_missing(method)
5
+ Tiktoken::Encoding.new(Tiktoken::BpeFactory.send(method))
6
+ end
7
+
8
+ def initialize(ext_base_bpe)
9
+ @ext_base_bpe = ext_base_bpe
10
+ end
11
+
12
+ def encode_ordinary(text)
13
+ @ext_base_bpe.encode_ordinary(text)
14
+ end
15
+
16
+ def encode(text, allowed_special: [])
17
+ @ext_base_bpe.encode(text, allowed_special)
18
+ end
19
+
20
+ def decode(tokens)
21
+ @ext_base_bpe.decode(tokens)
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tiktoken
4
+ VERSION = "0.0.1"
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "tiktoken_ruby/version"
4
+ require_relative "tiktoken_ruby/encoding.rb"
5
+ require_relative "tiktoken_ruby/tiktoken_ruby"
6
+
7
+ module Tiktoken
8
+ class Error < StandardError; end
9
+ end
@@ -0,0 +1,4 @@
1
+ module TiktokenRuby
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tiktoken_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: arm64-darwin
6
+ authors:
7
+ - IAPark
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-03-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Unofficial Ruby wrapper for Tiktoken by way of the unofficial rust bindings
14
+ email:
15
+ - isaac.a.park@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".rspec"
21
+ - ".standard.yml"
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - lib/tiktoken_ruby.rb
28
+ - lib/tiktoken_ruby/2.7/tiktoken_ruby.bundle
29
+ - lib/tiktoken_ruby/3.0/tiktoken_ruby.bundle
30
+ - lib/tiktoken_ruby/3.1/tiktoken_ruby.bundle
31
+ - lib/tiktoken_ruby/3.2/tiktoken_ruby.bundle
32
+ - lib/tiktoken_ruby/encoding.rb
33
+ - lib/tiktoken_ruby/version.rb
34
+ - sig/tiktoken_ruby.rbs
35
+ homepage: https://github.com/IAPark/tiktoken_ruby
36
+ licenses:
37
+ - MIT
38
+ metadata:
39
+ homepage_uri: https://github.com/IAPark/tiktoken_ruby
40
+ source_code_uri: https://github.com/IAPark/tiktoken_ruby
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '2.7'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 3.3.dev
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 3.3.11
58
+ requirements: []
59
+ rubygems_version: 3.4.4
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Ruby wrapper for Tiktoken
63
+ test_files: []