inloop-brain 0.0.4 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe0b4b770d6da5da35ea476343c02fc0849f3c3fd9a0f265319867df70f08ef0
4
- data.tar.gz: 5af8a4b92c9f0bb7bc78e0c1c7b024b0e70e00b6665e454374944aa5a725bcb1
3
+ metadata.gz: 242d32cd3085f8e0535ec5899eddde18b631e041e2fdee0f1acc9393a98e7d79
4
+ data.tar.gz: 365f246feb8a2b0049d2de32f9bcd454bcf27b7a9f8b496fc64bf6334d2220b9
5
5
  SHA512:
6
- metadata.gz: 168c3fe3446689bfe1922a9deedd46efd2a18ed31cabb942dcf7cef19e9b64229b29504b6a3fdf2c0e931e9f12aa17ad3a159665bc8134b90d7e0a35ad6c824d
7
- data.tar.gz: 63c8d32576a050bbb96de4eabe54940c161592f800495a4777d71d7921bf0a8c8a1f1b46a1c1892d90078711cb5dbdf3fef605e0ed0e1f4e49b35c7038c6597f
6
+ metadata.gz: 37294017a3413585a55476dd332a899dedd2d58d200d583a2921d1f71a0d5fb10d71d707e99d5d3591eeeb122c47c295273bf7b681229e965124d2a32f315d85
7
+ data.tar.gz: 58f8d2b73846170951ee5e66178f5ccf0f37e53c3c0081a6a615c0f5d51731d145d7994e8ef972a55327bd0666a465382c696d0f840acb346c6364854ab9108c
data/LICENSE.txt ADDED
@@ -0,0 +1,5 @@
1
+ INLOOP v0.1 License
2
+
3
+ Copyright (c) 2025 Abhishek Parolkar & inloop.studio LP
4
+
5
+ ALL RIGHTS RESERVED
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Inloop Brain
2
+
3
+ A command-line tool for interacting with the Inloop Brain Access Kit API.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ gem install inloop-brain
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ echo "What can you do?" | inloop-brain --key=YOUR_ACCESS_KEY
15
+ ```
16
+
17
+ Or
18
+
19
+ ```
20
+ echo "What can you do?" | inloop-brain -k YOUR_ACCESS_KEY > output.txt
21
+ ```
22
+
23
+ ### Environment Variables
24
+
25
+ You can customize the target host and protocol:
26
+
27
+ - `INLOOP_BRAIN_HOST`: Host to connect to (default: localhost:3000)
28
+ - `INLOOP_BRAIN_PROTOCOL`: Protocol to use (default: http)
29
+
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the Nonstandard license of inloop.studio
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/inloop-brain CHANGED
@@ -1,5 +1,112 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative "../lib/inloop-brain"
3
+ # bin/inloop-brain - A command-line tool to interact with the Brain Access Kit API
4
4
 
5
- Inloop::Brain::CLI.start(ARGV)
5
+ require 'optparse'
6
+ require 'net/http'
7
+ require 'uri'
8
+
9
+ # Parse command line options
10
+ options = {}
11
+ parser = OptionParser.new do |opts|
12
+ opts.banner = "This is brain access kit of inloop.studio\n\n Usage: inloop-brain [options]"
13
+ opts.on('-k KEY', '--key=KEY', 'Access key for the Brain Access Kit') do |key|
14
+ options[:key] = key
15
+ end
16
+ opts.on('-d', '--debug', 'Enable debug mode') do
17
+ options[:debug] = true
18
+ end
19
+ opts.on('-h', '--help', 'Display this help message') do
20
+ puts opts
21
+ exit
22
+ end
23
+ end
24
+
25
+ begin
26
+ parser.parse!
27
+ rescue OptionParser::InvalidOption => e
28
+ STDERR.puts e.message
29
+ STDERR.puts parser
30
+ exit 1
31
+ end
32
+
33
+ # Validate required parameters
34
+ unless options[:key]
35
+ STDERR.puts "Error: Missing required parameter 'key'"
36
+ STDERR.puts parser
37
+ exit 1
38
+ end
39
+
40
+ # Read input from STDIN
41
+ input = STDIN.read.strip
42
+
43
+ # Exit if no input provided
44
+ if input.empty?
45
+ STDERR.puts "Error: No input provided via STDIN"
46
+ exit 1
47
+ end
48
+
49
+ # Configure the API request
50
+ host = ENV['INLOOP_BRAIN_HOST'] || 'discovery.inloop.studio'
51
+ protocol = ENV['INLOOP_BRAIN_PROTOCOL'] || 'https'
52
+ endpoint = "/web_tools/brain_access_kit/#{options[:key]}/handle_prompt.txt"
53
+ uri = URI.parse("#{protocol}://#{host}#{endpoint}")
54
+
55
+ if options[:debug]
56
+ puts "Making request to: #{uri}"
57
+ end
58
+
59
+ # Setup the HTTP request
60
+ http = Net::HTTP.new(uri.host, uri.port)
61
+ http.use_ssl = (uri.scheme == 'https')
62
+
63
+ # Add proper timeout settings
64
+ http.open_timeout = 10
65
+ http.read_timeout = 60
66
+
67
+ request = Net::HTTP::Post.new(uri.path)
68
+ # Set proper headers
69
+ request['Content-Type'] = 'application/x-www-form-urlencoded'
70
+ request['Accept'] = 'text/plain'
71
+ request['User-Agent'] = 'Inloop-Brain-CLI/0.0.1'
72
+
73
+ # Set form data
74
+ request.set_form_data('prompt' => input)
75
+
76
+ # Send the request and handle the response
77
+ begin
78
+ if options[:debug]
79
+ puts "Request headers:"
80
+ request.each_header { |key, value| puts " #{key}: #{value}" }
81
+ puts "Request body: #{request.body}"
82
+ end
83
+
84
+ response = http.request(request)
85
+
86
+ if options[:debug]
87
+ puts "Response status: #{response.code}"
88
+ puts "Response headers:"
89
+ response.each_header { |key, value| puts " #{key}: #{value}" }
90
+ end
91
+
92
+ if response.code.to_i == 200
93
+ puts response.body
94
+ else
95
+ STDERR.puts "Error: API returned status code #{response.code}"
96
+ STDERR.puts response.body
97
+
98
+ # Additional troubleshooting for 422 errors
99
+ if response.code.to_i == 422
100
+ STDERR.puts "\nThe 422 error typically indicates a validation problem. Possible issues:"
101
+ STDERR.puts "1. The endpoint format may have changed"
102
+ STDERR.puts "2. The access key format may be incorrect"
103
+ STDERR.puts "3. The prompt may be in an invalid format"
104
+ STDERR.puts "\nTry running with --debug for more information."
105
+ end
106
+ exit 1
107
+ end
108
+ rescue => e
109
+ STDERR.puts "Error: Failed to connect to the API: #{e.message}"
110
+ STDERR.puts e.backtrace.join("\n") if options[:debug]
111
+ exit 1
112
+ end
@@ -0,0 +1,32 @@
1
+
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "inloop-brain"
5
+ spec.version = "0.0.6"
6
+ spec.authors = ["Abhishek Parolkar"]
7
+ spec.email = ["abhishek@inloop.studio"]
8
+
9
+ spec.summary = "Command-line interface for the Inloop Brain Access Kit"
10
+ spec.description = "A simple command-line tool that sends prompts to the Inloop Brain Access Kit API and returns responses"
11
+ spec.homepage = "https://inloop.studio"
12
+ spec.license = "Nonstandard"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/parolkar/inloop-brain" # Replace with actual repository URL
17
+ spec.metadata["changelog_uri"] = "https://github.com/parolkar/inloop-brain/blob/main/CHANGELOG.md" # Replace with actual changelog URL
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "bin"
25
+ spec.executables = ["inloop-brain"]
26
+
27
+
28
+ # Dependencies
29
+ spec.add_development_dependency "bundler", "~> 2.0"
30
+ spec.add_development_dependency "rake", "~> 13.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inloop-brain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhishek Parolkar
@@ -61,7 +61,11 @@ executables:
61
61
  extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
64
67
  - bin/inloop-brain
68
+ - inloop-brain.gemspec
65
69
  homepage: https://inloop.studio
66
70
  licenses:
67
71
  - Nonstandard