openai-term 3.0 → 3.0.2

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/openai +38 -20
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c95f00a48589ec290dd7f1ac09f33d9ccf4672220cd8f4c7081d0ca3eab3151
4
- data.tar.gz: 07f25366a6efd7d51c2c5e1e29bdbd5ce068076fa4857977d049320ec1821245
3
+ metadata.gz: 3fb2544c45742c1bd784318ce02cc766f8724ef9a1d51827fb4efbf64559447c
4
+ data.tar.gz: 41f43c059ace1ca015899fc01ac59592eb7558f24b313588b6b25d27280f56b1
5
5
  SHA512:
6
- metadata.gz: 0c4e0cd5e1f296bc2f7898c2ecb562571f2b480ea78b307704218fa5747279769b1690234b85b108d1441c3052c9bc214f63b7f463ddb58e9aee4f59f394a9aa
7
- data.tar.gz: a575ceb6d31b93d69876b407b4007ea087e0f4d6f3641cde22f41d47d394680739448d3824c757b09e1bc3e3c9a16c90c6607e12bd93668b8ae197b6229de844
6
+ metadata.gz: 7b362f3fb442ad40d3154d5e969d02b8fed6b15b74caed1fadff50d62da4968cc4da4379cce731e10d83672a2c412e3985dbf1dc1eea614b69044b434705899d
7
+ data.tar.gz: abaa7268da5b0d47be8aa554fbab1b1e9043455a2f5d5d864bf732c6f9559fcd6e8c044379af28a72e91ea1abf8724a84897fbb59db76bf908407dab1292119d
data/bin/openai CHANGED
@@ -9,17 +9,16 @@ require 'ruby/openai'
9
9
  require 'rcurses'
10
10
  require 'json'
11
11
  require 'fileutils'
12
+ require 'io/console'
12
13
 
13
- include Rcurses
14
14
  include Rcurses::Input
15
- include Rcurses::Cursor
16
15
 
17
16
  # Constants
18
17
  CONFIG_FILE = File.join(Dir.home, '.openai.conf')
19
18
  HISTORY_FILE = File.join(Dir.home, '.openai_history.json')
20
19
  DEFAULT_MODEL = "gpt-4-turbo-preview"
21
20
  DEFAULT_MAX_TOKENS = 2048
22
- VERSION = "3.0"
21
+ VERSION = "3.0.2"
23
22
 
24
23
  # Global variables
25
24
  @model = DEFAULT_MODEL
@@ -59,7 +58,7 @@ def parse_options
59
58
  opts.on('-c', '--config FILE', 'Config file path') { |c| options[:config] = c }
60
59
  opts.on('-q', '--quiet', 'Skip TUI and output to stdout directly') { options[:quiet] = true }
61
60
  opts.on('-h', '--help', 'Display help') { puts opts; exit }
62
- opts.on('-v', '--version', 'Display version') { puts "OpenAI Terminal 2.1"; exit }
61
+ opts.on('-v', '--version', 'Display version') { puts "OpenAI Terminal #{VERSION}"; exit }
63
62
  end
64
63
 
65
64
  optparse.parse!
@@ -76,15 +75,30 @@ def load_config(config_path = nil)
76
75
  else
77
76
  FileUtils.mkdir_p(File.dirname(config_file))
78
77
  File.write(config_file, "@ai = 'your-secret-openai-key'")
79
- puts "Created config file: #{config_file}"
80
- puts "Please edit it and add your OpenAI API key."
81
- puts "Get your key from: https://platform.openai.com/api-keys"
78
+ puts "\nOpenAI Terminal - Configuration Required"
79
+ puts "=" * 50
80
+ puts "\nCreated config file: #{config_file}"
81
+ puts "\nPlease edit it and add your OpenAI API key:"
82
+ puts " @ai = \"sk-...\""
83
+ puts "\nGet your API key from:"
84
+ puts " https://platform.openai.com/api-keys"
85
+
86
+ # Only mention RTFM if it exists
87
+ rtfm_config = File.join(Dir.home, '.rtfm/conf')
88
+ if File.exist?(rtfm_config)
89
+ puts "\nTip: If you use RTFM, you can copy the @ai value from:"
90
+ puts " #{rtfm_config}"
91
+ end
92
+ puts "\nThen run 'openai' again to start the terminal interface."
82
93
  exit 1
83
94
  end
84
95
 
85
96
  unless @api_key && @api_key != 'your-secret-openai-key'
86
- puts "Error: Invalid API key in #{config_file}"
87
- puts "Please add your OpenAI API key to the config file."
97
+ puts "\nError: Invalid API key in #{config_file}"
98
+ puts "\nPlease edit the file and add your OpenAI API key:"
99
+ puts " @ai = \"sk-...\""
100
+ puts "\nGet your API key from:"
101
+ puts " https://platform.openai.com/api-keys"
88
102
  exit 1
89
103
  end
90
104
  end
@@ -124,45 +138,49 @@ end
124
138
  # Initialize OpenAI client
125
139
  def init_client
126
140
  @client = OpenAI::Client.new(
127
- access_token: @api_key,
128
- log_errors: false
141
+ access_token: @api_key
129
142
  )
130
143
  end
131
144
 
132
145
  # Setup UI
133
146
  def setup_ui
147
+ unless $stdin.tty?
148
+ puts "Error: This program requires a TTY terminal"
149
+ exit 1
150
+ end
151
+
134
152
  rows, cols = IO.console.winsize
135
153
 
136
154
  Rcurses.clear_screen
137
- Cursor.hide
155
+ Rcurses::Cursor.hide
138
156
 
139
157
  # Create panes - accounting for borders being drawn outside pane geometry
140
- @header = Pane.new(1, 1, cols, 1, 255, 24)
158
+ @header = Rcurses::Pane.new(1, 1, cols, 1, 255, 24)
141
159
  @header.border = false # Top pane doesn't need border
142
160
 
143
- @chat_pane = Pane.new(1, 3, cols, rows - 7, 255, 232)
161
+ @chat_pane = Rcurses::Pane.new(1, 3, cols, rows - 7, 255, 232)
144
162
  @chat_pane.border = true
145
163
 
146
- @input_pane = Pane.new(1, rows - 2, cols, 1, 255, 234)
164
+ @input_pane = Rcurses::Pane.new(1, rows - 2, cols, 1, 255, 234)
147
165
  @input_pane.border = true
148
166
 
149
- @status_pane = Pane.new(1, rows, cols, 1, 255, 236)
167
+ @status_pane = Rcurses::Pane.new(1, rows, cols, 1, 255, 236)
150
168
 
151
169
  # Popup panes (created but not displayed initially)
152
170
  help_w = cols * 3 / 4
153
171
  help_h = rows * 3 / 4
154
- @help_pane = Pane.new((cols - help_w) / 2 + 1, (rows - help_h) / 2 + 1, help_w, help_h, 255, 234)
172
+ @help_pane = Rcurses::Pane.new((cols - help_w) / 2 + 1, (rows - help_h) / 2 + 1, help_w, help_h, 255, 234)
155
173
  @help_pane.border = true
156
174
 
157
175
  model_w = cols / 2
158
176
  model_h = rows / 2
159
- @model_list_pane = Pane.new((cols - model_w) / 2 + 1, (rows - model_h) / 2 + 1, model_w, model_h, 255, 233)
177
+ @model_list_pane = Rcurses::Pane.new((cols - model_w) / 2 + 1, (rows - model_h) / 2 + 1, model_w, model_h, 255, 233)
160
178
  @model_list_pane.border = true
161
179
 
162
180
  # Conversation list pane
163
181
  conv_w = cols * 3 / 4
164
182
  conv_h = rows * 3 / 4
165
- @conversation_list_pane = Pane.new((cols - conv_w) / 2 + 1, (rows - conv_h) / 2 + 1, conv_w, conv_h, 255, 235)
183
+ @conversation_list_pane = Rcurses::Pane.new((cols - conv_w) / 2 + 1, (rows - conv_h) / 2 + 1, conv_w, conv_h, 255, 235)
166
184
  @conversation_list_pane.border = true
167
185
 
168
186
  # Popup state tracking
@@ -934,7 +952,7 @@ def main
934
952
 
935
953
  ensure
936
954
  save_history if defined?(@conversation_history)
937
- Cursor.show if defined?(Cursor)
955
+ Rcurses::Cursor.show if defined?(Rcurses::Cursor)
938
956
  Rcurses.clear_screen if defined?(Rcurses)
939
957
  end
940
958
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openai-term
3
3
  version: !ruby/object:Gem::Version
4
- version: '3.0'
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
@@ -40,8 +40,9 @@ dependencies:
40
40
  version: '6.0'
41
41
  description: 'A modern terminal interface to OpenAI with a full TUI using rcurses.
42
42
  Features include interactive chat mode, conversation history, model selection, and
43
- more. Version 3.0: Breaking change - requires rcurses 6.0.0+ with explicit initialization
44
- for Ruby 3.4+ compatibility.'
43
+ more. Version 3.0.2: Complete fix for ruby-openai 3.7.0 compatibility - using ''ruby/openai''
44
+ for backward compatibility, fixed Rcurses::Pane and Rcurses::Cursor references,
45
+ added missing io/console requirement, improved configuration help.'
45
46
  email: g@isene.com
46
47
  executables:
47
48
  - openai