promptspec 0.0.4 → 0.0.5

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/lib/promptspec.rb +12 -16
  3. data/promptspec.gemspec +1 -2
  4. metadata +1 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 022ef82dfab3a71fccb829c8358442d8ef7f77026d637bfad15586adef3dfce5
4
- data.tar.gz: 990779a5f40d7baffe57dbc186198541ea96bd316328741e352b823f6e3b587c
3
+ metadata.gz: b8344f339aa0ef8a57c14422dc2f50046a203076ec9c2daee525c4432f57f6bf
4
+ data.tar.gz: 96014c0bc00da57d4b0289df8c39fa4a3c8505dc6a0b6814a717a31f735ad591
5
5
  SHA512:
6
- metadata.gz: 391028f8084149662b27a3bca42bf6a7e8d1ff06e0ad043e9c5b82390186d6804416d153be55160d096b4e9fafa0239cd74d1777d74a46ad48276b6d045c23e4
7
- data.tar.gz: 5fb14570770bf048e695ee101a5a8043d5eec74dcb245f1ac369573a4c1f10cb796d2c5d4c35f8ac4aa97505e4c798978e48b86590bba05e8fbc278d16a2f88f
6
+ metadata.gz: 1516fbdb9607f0724faa3c10081269b3d99c243145b1f31a19588faec6a5b7602120d536acba56fd1629b7afc1b6bd9f2d25f7cd18e4491687bceb66964c0534
7
+ data.tar.gz: 611b943f18480666c2d9da0a157eb186f0a4392ee876897af67d4c026829391a701882abcf19c1e9343eca7e8d35aee2131de888887537fbbf0fd96e075caf37
data/lib/promptspec.rb CHANGED
@@ -6,12 +6,6 @@ require 'net/http'
6
6
  require 'uri'
7
7
 
8
8
  class PromptSpec
9
- class Error < StandardError; end
10
- class FileNotFoundError < Error; end
11
- class ParseError < Error; end
12
- class RequiredParameterError < Error; end
13
- class EndpointError < Error; end
14
-
15
9
  attr_reader :file_path, :validate_required_params
16
10
 
17
11
  def initialize(file_path, validate_required_params: true)
@@ -21,7 +15,7 @@ class PromptSpec
21
15
  end
22
16
 
23
17
  def call(**parameters)
24
- validate_required_inputs!(parameters) if validate_required_params
18
+ validate_required_inputs!(parameters) if @validate_required_params
25
19
  parse_prompt_messages(parameters)
26
20
  construct_endpoint_request
27
21
  end
@@ -75,9 +69,7 @@ class PromptSpec
75
69
  def construct_default_endpoint
76
70
  @model = @yaml_content['prompt']['model']
77
71
  case @model
78
- when 'gpt-4'
79
- 'https://api.openai.com/v1/chat/completions'
80
- when 'gpt-3.5-turbo'
72
+ when 'gpt-4', 'gpt-4-0613', 'gpt-4-32k', 'gpt-4-32k-0613', 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-3.5-turbo-0613', 'gpt-3.5-turbo-16k-0613'
81
73
  'https://api.openai.com/v1/chat/completions'
82
74
  else
83
75
  raise EndpointError, "Unknown model: #{model}"
@@ -85,14 +77,18 @@ class PromptSpec
85
77
  end
86
78
 
87
79
  def construct_headers
88
- # Placeholder logic for constructing headers
89
80
  headers = @yaml_content['headers'] || {}
90
- if @model == 'gpt-4' && headers.empty?
91
- api_key = ENV['OPENAI_API_KEY']
92
- raise EndpointError, "Missing OpenAI API Key" unless api_key
93
- headers['Authorization'] = "Bearer #{api_key}"
81
+
82
+ if headers.empty?
83
+ case @model
84
+ when 'gpt-4', 'gpt-4-0613', 'gpt-4-32k', 'gpt-4-32k-0613', 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-3.5-turbo-0613', 'gpt-3.5-turbo-16k-0613'
85
+ api_key = ENV['OPENAI_API_KEY']
86
+ headers['Authorization'] = "Bearer #{api_key}" if api_key
87
+ # Add more cases here for other providers
88
+ end
94
89
  end
95
- headers['Content-Type'] = 'application/json'
90
+
91
+ headers['Content-Type'] = 'application/json' unless headers.key?('Content-Type')
96
92
  headers
97
93
  end
98
94
  end
data/promptspec.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # promptspec.gemspec
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "promptspec"
4
- spec.version = "0.0.4"
4
+ spec.version = "0.0.5"
5
5
  spec.authors = ["Hyperaide, John Paul, Daniel Paul"]
6
6
  spec.email = ["jp@hyperaide.com"]
7
7
 
@@ -14,7 +14,6 @@ Gem::Specification.new do |spec|
14
14
  spec.require_paths = ["lib"]
15
15
 
16
16
  spec.add_runtime_dependency "yaml", "~> 0.1.0"
17
- spec.add_runtime_dependency "erb", "~> 2.2.0"
18
17
 
19
18
  spec.add_development_dependency "bundler", "~> 2.0"
20
19
  spec.add_development_dependency "rake", "~> 13.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promptspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hyperaide, John Paul, Daniel Paul
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.0
27
- - !ruby/object:Gem::Dependency
28
- name: erb
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 2.2.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 2.2.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement