zakar 0.0.1
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 +7 -0
- data/lib/zakar.rb +32 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 609667a521e9640e951fec20c82176c61050a145aa2b655eac5fbbdb3e2d7b3c
|
|
4
|
+
data.tar.gz: c26802b480298d631ad840c1e3abfddd66219d2a96e02c3d5ace749a59e40fdf
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ae195a4a8d501c6a429407818da277d89e34ad5d1ad23edeffe587cd575b116a135e4483fb9f88ff452d61ddff79c6409bce3fbbf95917307bdc0d3159224b92
|
|
7
|
+
data.tar.gz: c7cb17cd12d6178419c275b54c8efe1384d5bd2e5c245a2c692b706b486a794792566925c3a1856772e64b2ac508c1e4d7b5d8642834d0fc5707590134fecf8b
|
data/lib/zakar.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Zakar
|
|
2
|
+
require 'http'
|
|
3
|
+
require 'json'
|
|
4
|
+
DALLE2 = "https://api.openai.com/v1/images/generations"
|
|
5
|
+
GPT3 = "https://api.openai.com/v1/engines/davinci/completions"
|
|
6
|
+
class OpenAI
|
|
7
|
+
def initialize(apikey)
|
|
8
|
+
@apikey = apikey
|
|
9
|
+
@headers = {
|
|
10
|
+
"Content-Type"=> "application/json",
|
|
11
|
+
"Authorization"=> "Bearer #{apikey}"
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
def DallE2(filename, description, size:"1024x1024")
|
|
15
|
+
req = HTTP.post(DALLE2,:headers=>@headers,:body=>JSON({
|
|
16
|
+
"prompt"=>description,
|
|
17
|
+
"n"=>1,"size"=>size
|
|
18
|
+
}))
|
|
19
|
+
image = HTTP.get(JSON(req.body)["data"].to_s.match(/"url"=>"(.*)"/m)[1])
|
|
20
|
+
a = File.new("#{filename}.jpg", "w")
|
|
21
|
+
a.write(image.body)
|
|
22
|
+
a.close()
|
|
23
|
+
end
|
|
24
|
+
def GPT3(description)
|
|
25
|
+
req = HTTP.post(GPT3, :headers=>@headers, :body=>JSON({
|
|
26
|
+
"prompt"=>description, "stop"=>nil,
|
|
27
|
+
"n"=>1,"temperature"=>0.5,"max_tokens"=>100
|
|
28
|
+
}))
|
|
29
|
+
puts JSON(req.body)["choices"].to_s.match(/"text"=>"(.*)",/m).to_s.split('"text"=>"')[1].gsub('\n\n', "\n")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: zakar
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Komodo
|
|
8
|
+
- Flame
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: |
|
|
15
|
+
Zakar is a small, unofficial openAI API Wrapper for GPT-3 and DALL-E2.
|
|
16
|
+
Inspired by the greatest son of Allah named "Zakar".
|
|
17
|
+
email:
|
|
18
|
+
executables: []
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- lib/zakar.rb
|
|
23
|
+
homepage: https://rubygems.org/gems/zakar
|
|
24
|
+
licenses:
|
|
25
|
+
- MIT
|
|
26
|
+
metadata: {}
|
|
27
|
+
post_install_message:
|
|
28
|
+
rdoc_options: []
|
|
29
|
+
require_paths:
|
|
30
|
+
- lib
|
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '0'
|
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
requirements: []
|
|
42
|
+
rubygems_version: 3.1.2
|
|
43
|
+
signing_key:
|
|
44
|
+
specification_version: 4
|
|
45
|
+
summary: Unofficial openAI API Wrapper for GPT-3 and DALL-E2.
|
|
46
|
+
test_files: []
|