openai-term 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/openai +9 -9
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cbbff6f66b0be7142ea17264913d04d81bff65ccb7dcd907078cd20d0cecab7
4
- data.tar.gz: c78fd899435b84207c0dfbd0dbcd0d7338ba3a39d9d6fe363bb5561a6c12a3ca
3
+ metadata.gz: d8d8a11333a11c485b026674918f685ec1b0f5e0e085ffe9b36789cab50205dd
4
+ data.tar.gz: 40d4fd48a98cd3134f7ba4ad19d8347246564aa6651fd2fb96202763d590e375
5
5
  SHA512:
6
- metadata.gz: 7be5cf192e04651ac07ccc27761a0790db85aa14beb0106d8dab93a9483bd0155d471371eabc0a46e6f8c96d1bb019437bc6365d824536ced020a2edf76f1e6f
7
- data.tar.gz: 34a9532402510e670340c8b1bef5632649368342bc2309f632fdeeb55eb6c2e877206a315e2b7381b9bbffada1c1b3c46f23a088f631a2c55289b69a2a539c8f
6
+ metadata.gz: 4b0a2e19261526b96af25f4015091a07091409325268b8816e2f2c8e95472b28cd318c84777dda8dca1009a8b2b96d309251320c8a2e0427ad21fc3749e2aa87
7
+ data.tar.gz: e23f349349b402873ffc421c610fdb489c7db531bb533ba277cfb8ae140b1ba3277fbf67de01111dd796b999c35934f015893a69777c322bd204a2690fee5f28
data/bin/openai CHANGED
@@ -7,16 +7,10 @@ require 'tty-prompt'
7
7
  require "ruby/openai"
8
8
 
9
9
  # INITIALIZE CONSTANTS
10
- @x = 200
10
+ @x = 500
11
11
  @m = "gpt-3.5-turbo-instruct"
12
12
  @prompt = TTY::Prompt.new
13
13
 
14
- def model
15
- c = %w(text-davinci-003 code-cushman-001 text-curie-001 text-ada-001)
16
- m = @prompt.select("What AI model do you want to use? (see https://beta.openai.com/docs/models/codex for details)", c, cycle: true)
17
- return m
18
- end
19
-
20
14
  # HANDLE COMMAND LINE OPTIONS
21
15
  options = {}
22
16
  optparse = OptionParser.new do |opts|
@@ -27,7 +21,8 @@ optparse = OptionParser.new do |opts|
27
21
  opts.on('-f', '--file textfile', 'A file to process') { |f| @f = f }
28
22
  opts.on('-t', '--text text', 'The text to process') { |t| @t = t }
29
23
  opts.on('-x', '--max max_tokens', 'Specify max number of words in response') { |x| @x = x.to_i }
30
- opts.on('-m', '--model', 'The AI model to use (default = gpt-3.5-turbo-instruct') { @m = model }
24
+ opts.on('-m', '--model', 'The AI model to use (default = gpt-3.5-turbo-instruct)') { |m| @m = m }
25
+ opts.on('-M', '--listmodels', 'List available models, pick and use') { @m = "list" }
31
26
  opts.on('-i', '--image', 'Create an image with the text supplied by -t or -f') { @i = true }
32
27
  opts.on('-h', 'Display SHORT help text') { puts opts; exit }
33
28
  opts.on('-v', '--version', 'Display the version number') { puts "Version: 0.1"; exit }
@@ -53,7 +48,12 @@ unless @f or @t
53
48
  end
54
49
 
55
50
  # REQUEST AND PRINT RESPONSE
56
- client = OpenAI::Client.new(access_token: @ai)
51
+ client = OpenAI::Client.new(access_token: @ai, log_errors: true)
52
+
53
+ if @m == "list"
54
+ c = client.models.list["data"].map.each { |i| i["id"] }
55
+ @m = @prompt.select("What AI model do you want to use? (see https://beta.openai.com/docs/models/codex for details)", c, cycle: true)
56
+ end
57
57
 
58
58
  begin
59
59
  if @i
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openai-term
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-27 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai
@@ -42,7 +42,8 @@ description: 'This is a pretty straight forward interface to OpenAI with the opt
42
42
  to select the AI model and the maximum token length (number of maximum words in
43
43
  the AI''s response). You will use the -t option to supply the query to OpenAI or
44
44
  the -f option to read the query from a text file instead. New in 1.3: Updated default
45
- model to gpt-3.5-turbo-instruct.'
45
+ model to gpt-3.5-turbo-instruct. 1.4: Added option -M to list available model and
46
+ use the one selected.'
46
47
  email: g@isene.com
47
48
  executables:
48
49
  - openai