hallucinate 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hallucinate/ai_response_generator.rb +10 -3
- data/lib/hallucinate/hallucinator.rb +2 -2
- data/lib/hallucinate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3641152c58241f8875aae5274c03ad8242099938179ccbe42910fd30206bce7
|
4
|
+
data.tar.gz: eef4bdb54605ef34cabb3646433d18556cc13c6d2e570cf5d5229bd320cd4fee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1be1ceb0f1b9404fb22e804503e512f68b1ec7d203d4fff30cb5329fa7de033bf3a576342398afceda905cc7db77bcd5f21edbefa8b3a7809251cde800f31b7
|
7
|
+
data.tar.gz: 40f01ca24d67dfb729810d05a7018edf552e5a5eb92638d7abeaf32e2ac5c0ad4989d0de3640f31463f4d13a7308b0a762e8ffdd006ed7579220f341b8272b4d
|
@@ -4,10 +4,17 @@ require "json"
|
|
4
4
|
|
5
5
|
module Hallucinate
|
6
6
|
class AIResponseGenerator
|
7
|
+
class MissingApiKeyError < StandardError; end
|
8
|
+
|
7
9
|
OPENAI_URL = "https://api.openai.com/v1/chat/completions"
|
8
10
|
|
9
|
-
def generate_response(class_name, method_name, args)
|
10
|
-
api_key =
|
11
|
+
def generate_response(class_name, method_name, *args, **kargs)
|
12
|
+
api_key = begin
|
13
|
+
Hallucinate.configuration.api_key
|
14
|
+
rescue NoMethodError
|
15
|
+
raise MissingApiKeyError
|
16
|
+
end
|
17
|
+
|
11
18
|
uri = URI(OPENAI_URL)
|
12
19
|
request = Net::HTTP::Post.new(uri)
|
13
20
|
request["Authorization"] = "Bearer #{api_key}"
|
@@ -17,7 +24,7 @@ module Hallucinate
|
|
17
24
|
messages: [
|
18
25
|
{
|
19
26
|
role: :user,
|
20
|
-
content: "Write a method named #{method_name} that would match a class #{class_name} context, knowing the value of these arguments: #{args}, and returns a result you imagine is the most appropriate. Please provide only the method's return output. I really don't want you to be verbose. ONLY respond with the returned result."
|
27
|
+
content: "Write a method named #{method_name} that would match a class #{class_name} context, knowing the value of these arguments: #{args} and #{kargs}, and returns a result you imagine is the most appropriate. Please provide only the method's return output. I really don't want you to be verbose. ONLY respond with the returned result."
|
21
28
|
}
|
22
29
|
],
|
23
30
|
max_tokens: 150
|
@@ -2,8 +2,8 @@ module Hallucinate
|
|
2
2
|
module Hallucinator
|
3
3
|
def self.included(base)
|
4
4
|
base.class_eval do
|
5
|
-
def method_missing(method_name, *args, &block)
|
6
|
-
AIResponseGenerator.new.generate_response(self.class.name, method_name, *args)
|
5
|
+
def method_missing(method_name, *args, **kargs, &block)
|
6
|
+
AIResponseGenerator.new.generate_response(self.class.name, method_name, *args, **kargs)
|
7
7
|
end
|
8
8
|
|
9
9
|
def respond_to_missing?(method_name, include_private = false)
|
data/lib/hallucinate/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hallucinate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MatthieuGC
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
requirements: []
|
59
|
-
rubygems_version: 3.4.
|
59
|
+
rubygems_version: 3.4.22
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Hallucinate is a gem that uses OpenAI's GPT to generate code that doesn't
|