qodex-rails 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qodex/rails/version.rb +1 -1
- data/lib/qodex-rails/middleware.rb +14 -5
- data/lib/qodex-rails/version.rb +1 -1
- data/qodex-rails-0.1.1.gem +0 -0
- data/qodex-rails-0.1.2.gem +0 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b11d2adaab0ce0578b59e97eb0126db77c6e3ea9e574a26993fc98e5390a6625
|
4
|
+
data.tar.gz: 87c38a3060afe958a318c551447b930d8f59b6f8a4d26a3ee70aec9fc77e20b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ceb75b0590a4b51efc355c35851ed649d3222671196987c8807192484291305b8ce899360ee428b06f4af86261be3464c8df0ae0ccb1cb44953de38a5b264542
|
7
|
+
data.tar.gz: 4e66c0e6157973b8c3e278d5ca7ed91473ddcf77367ea9c0c1b5f151f3f04749d642e19059e9763f4b763aafc8ff15aa19c4e4e737341753d2a5e82b87cba62d
|
data/lib/qodex/rails/version.rb
CHANGED
@@ -10,6 +10,15 @@ module QodexRails
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(env)
|
13
|
+
# Exit early if collection_name or api_key are not configured
|
14
|
+
unless QodexRails.configuration.collection_name && QodexRails.configuration.api_key
|
15
|
+
Rails.logger.warn "QodexRails: collection_name or api_key not configured. Skipping middleware."
|
16
|
+
return @app.call(env)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Print the initializer keys to the output
|
20
|
+
Rails.logger.info "QodexRails Initializer Keys: Collection Name: #{QodexRails.configuration.collection_name}, API Key: #{QodexRails.configuration.api_key}"
|
21
|
+
|
13
22
|
start_time = Time.now
|
14
23
|
|
15
24
|
# Capture the request details
|
@@ -30,7 +39,7 @@ module QodexRails
|
|
30
39
|
api_key: QodexRails.configuration.api_key,
|
31
40
|
apis: [{
|
32
41
|
body: response_body,
|
33
|
-
body_type:
|
42
|
+
body_type: 'none-type',
|
34
43
|
request_type: request.request_method,
|
35
44
|
timestamp: Time.now.to_i,
|
36
45
|
url: request.url,
|
@@ -50,16 +59,16 @@ module QodexRails
|
|
50
59
|
|
51
60
|
def extract_body(response)
|
52
61
|
body = ""
|
53
|
-
response.each { |part| body << part }
|
62
|
+
response.each { |part| body << part } if response.respond_to?(:each)
|
54
63
|
body
|
55
64
|
end
|
56
65
|
|
57
66
|
def extract_headers(headers)
|
58
|
-
headers.map { |name, value| { name: name, value: value } }
|
67
|
+
headers.map { |name, value| { name: name, value: value } } if headers.respond_to?(:map)
|
59
68
|
end
|
60
69
|
|
61
70
|
def send_to_api(logs)
|
62
|
-
uri = URI("
|
71
|
+
uri = URI("https://api.app.qodex.ai/api/v1/collections/create_with_folder/#{QodexRails.configuration.api_key}")
|
63
72
|
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
64
73
|
request.body = JSON.generate(logs)
|
65
74
|
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
@@ -67,7 +76,7 @@ module QodexRails
|
|
67
76
|
end
|
68
77
|
|
69
78
|
# Optionally log the response from the external API
|
70
|
-
Rails.logger.info "API Response: #{response.body}" if response
|
79
|
+
Rails.logger.info "URI: #{uri}, API Response: #{response.body}" if response
|
71
80
|
end
|
72
81
|
end
|
73
82
|
end
|
data/lib/qodex-rails/version.rb
CHANGED
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qodex-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sid
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Intercept your rails application to power Qodex.ai AI copilot.
|
14
14
|
email:
|
@@ -31,6 +31,8 @@ files:
|
|
31
31
|
- lib/qodex/rails.rb
|
32
32
|
- lib/qodex/rails/version.rb
|
33
33
|
- qodex-rails-0.1.0.gem
|
34
|
+
- qodex-rails-0.1.1.gem
|
35
|
+
- qodex-rails-0.1.2.gem
|
34
36
|
- sig/qodex/rails.rbs
|
35
37
|
homepage: https://qodex.ai
|
36
38
|
licenses:
|