inloop-brain 0.0.10 → 0.0.12

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/bin/inloop-brain +40 -22
  4. metadata +18 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af66fbbb5672cf09b9b5eb5d4ae4d018adc4dd7f2a5be343dae2c93a74732bac
4
- data.tar.gz: 21efedeaa7f002463d145091df3772c0839db24cbfc762d797a8344f657b85ec
3
+ metadata.gz: 5f176e6091ddf3dd8c04abd0e693dbde1ad2151832f56ae0662c7eb8a83f9e43
4
+ data.tar.gz: 0d92f3cf02bdca00ae092314ecd137ede5c6743cda542122f6e62fc558c24767
5
5
  SHA512:
6
- metadata.gz: 03b35d39d7f88c6d788cace6ba09cd524bb4fed2bb3ca6ca4080d23a2d33877a4da7ba7b106db57d596e8aa7f0f3499a0eda25529beacf1731c4968a4390f824
7
- data.tar.gz: b198e63d50a928d4e7095598795437aae57071e7bf2003bf7bfb9ec6544286cd50f137f3d41f48401c2c2d61a6b7811edf7b927ab03d072811d88a579b833fbc
6
+ metadata.gz: b4d126455788c3879674df89b3ba85266e200b68f3509d6f8eebbf373df72b2624f0e908cdfca7d3ea98108d59466b79a84f4ec12feb0059e3491790515ddd99
7
+ data.tar.gz: 26aa271479335d9a53ab499f2b533a917ee2984ac9ea95a658e6c7314a4648788aee6c3368185a974108dc028513eee2e7654685fc26f8be4779eb67b512fea4
data/README.md CHANGED
@@ -29,7 +29,7 @@ echo "What can you do?" | inloop-brain -k YOUR_API_KEY > output.txt
29
29
  Use an API key generated from the Brain API share link in app.inloop.studio. The API uses the published `llms.txt` context when available.
30
30
 
31
31
  - `INLOOP_BRAIN_API_KEY`: API key used for Authorization (recommended)
32
- - `INLOOP_BRAIN_API_URL`: Full API URL (default: https://app.inloop.studio/api/v1/chat/completions)
32
+ - `INLOOP_BRAIN_API_URL`: Full API URL (default: https://app.inloop.studio/v1/chat/completions)
33
33
  - `INLOOP_BRAIN_MODEL`: Model name to send (default: inloop-brain)
34
34
  - `INLOOP_BRAIN_HOST`: Host override (default: app.inloop.studio)
35
35
  - `INLOOP_BRAIN_PROTOCOL`: Protocol override (default: https)
data/bin/inloop-brain CHANGED
@@ -8,8 +8,11 @@ require 'optparse'
8
8
  require 'net/http'
9
9
  require 'uri'
10
10
  require 'json'
11
+ require 'dotenv'
11
12
  require 'inloop_brain/ssl'
12
13
 
14
+ Dotenv.load
15
+
13
16
  # Parse command line options
14
17
  options = {}
15
18
  parser = OptionParser.new do |opts|
@@ -23,7 +26,7 @@ parser = OptionParser.new do |opts|
23
26
  opts.on('--system=TEXT', 'System prompt to prepend to the conversation') do |text|
24
27
  options[:system] = text
25
28
  end
26
- opts.on('--api-url=URL', 'Override API URL (default: https://app.inloop.studio/api/v1/chat/completions)') do |url|
29
+ opts.on('--api-url=URL', 'Override API URL (default: https://app.inloop.studio/v1/chat/completions)') do |url|
27
30
  options[:api_url] = url
28
31
  end
29
32
  opts.on('-d', '--debug', 'Enable debug mode') do
@@ -65,7 +68,7 @@ api_url = options[:api_url] || ENV['INLOOP_BRAIN_API_URL']
65
68
  if api_url.nil? || api_url.strip.empty?
66
69
  host = ENV['INLOOP_BRAIN_HOST'] || 'app.inloop.studio'
67
70
  protocol = ENV['INLOOP_BRAIN_PROTOCOL'] || 'https'
68
- api_url = "#{protocol}://#{host}/api/v1/chat/completions"
71
+ api_url = "#{protocol}://#{host}/v1/chat/completions"
69
72
  end
70
73
  uri = URI.parse(api_url)
71
74
 
@@ -103,7 +106,7 @@ request = Net::HTTP::Post.new(uri)
103
106
  request['Content-Type'] = 'application/json'
104
107
  request['Accept'] = 'application/json'
105
108
  request['Authorization'] = "Bearer #{options[:key]}"
106
- request['User-Agent'] = 'Inloop-Brain-CLI/0.0.10'
109
+ request['User-Agent'] = 'Inloop-Brain-CLI/0.0.11'
107
110
 
108
111
  messages = []
109
112
  messages << { role: 'system', content: options[:system] } if options[:system].to_s.strip != ''
@@ -134,25 +137,40 @@ begin
134
137
  payload = JSON.parse(response.body.to_s)
135
138
  rescue JSON::ParserError
136
139
  payload = nil
137
- end
138
-
139
- if response.code.to_i == 200
140
- content = payload.dig("choices", 0, "message", "content") if payload
141
- content ||= payload.dig("choices", 0, "text") if payload
142
- if content
143
- puts content
144
- else
145
- STDERR.puts "Error: Unexpected response format"
146
- STDERR.puts response.body
147
- exit 1
148
- end
149
- else
150
- message = payload.dig("error", "message") if payload
151
- STDERR.puts "Error: API returned status code #{response.code}"
152
- STDERR.puts(message || response.body)
153
- exit 1
154
- end
155
- rescue => e
140
+ end
141
+
142
+ if response.code.to_i == 200
143
+ content = nil
144
+ if payload.is_a?(Hash)
145
+ content = payload.dig("choices", 0, "message", "content")
146
+ content ||= payload.dig("choices", 0, "text")
147
+ content ||= payload["content"]
148
+ content ||= payload["message"]
149
+ content ||= payload["text"]
150
+ elsif payload.is_a?(String)
151
+ content = payload
152
+ end
153
+ if content
154
+ puts content
155
+ else
156
+ STDERR.puts "Error: Unexpected response format"
157
+ STDERR.puts response.body.to_s
158
+ exit 1
159
+ end
160
+ else
161
+ message = nil
162
+ if payload.is_a?(Hash)
163
+ message = payload.dig("error", "message") if payload["error"].is_a?(Hash)
164
+ message ||= payload["error"] if payload["error"].is_a?(String)
165
+ message ||= payload["message"]
166
+ elsif payload.is_a?(String)
167
+ message = payload
168
+ end
169
+ STDERR.puts "Error: API returned status code #{response.code}"
170
+ STDERR.puts(message || response.body.to_s)
171
+ exit 1
172
+ end
173
+ rescue => e
156
174
  STDERR.puts "Error: Failed to connect to the API: #{e.message}"
157
175
  STDERR.puts e.backtrace.join("\n") if options[:debug]
158
176
  exit 1
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inloop-brain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhishek Parolkar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-06 00:00:00.000000000 Z
11
+ date: 2026-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dotenv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -61,7 +75,7 @@ dependencies:
61
75
  description: A simple command-line tool that sends prompts to the Inloop Brain Access
62
76
  Kit API and returns responses
63
77
  email:
64
- - abhishek@inloop.studio
78
+ - abhishek@parolkar.com
65
79
  executables:
66
80
  - inloop-brain
67
81
  extensions: []
@@ -93,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
107
  - !ruby/object:Gem::Version
94
108
  version: '0'
95
109
  requirements: []
96
- rubygems_version: 3.4.19
110
+ rubygems_version: 3.5.22
97
111
  signing_key:
98
112
  specification_version: 4
99
113
  summary: Command-line interface for the Inloop Brain Access Kit