ai-chat 0.4.0 → 0.5.1

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.
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ai-chat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raghu Betina
8
+ - Jelani Woods
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-01-29 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: openai
@@ -143,11 +144,12 @@ dependencies:
143
144
  version: '11.1'
144
145
  email:
145
146
  - raghu@firstdraft.com
147
+ - jelani@firstdraft.com
146
148
  executables: []
147
149
  extensions: []
148
150
  extra_rdoc_files:
149
- - LICENSE
150
151
  - README.md
152
+ - LICENSE
151
153
  files:
152
154
  - LICENSE
153
155
  - README.md
@@ -155,7 +157,8 @@ files:
155
157
  - lib/ai-chat.rb
156
158
  - lib/ai/amazing_print.rb
157
159
  - lib/ai/chat.rb
158
- - lib/ai/http.rb
160
+ - lib/ai/items.rb
161
+ - lib/ai/message.rb
159
162
  - lib/prompts/schema_generator.md
160
163
  homepage: https://github.com/firstdraft/ai-chat
161
164
  licenses:
@@ -181,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
184
  - !ruby/object:Gem::Version
182
185
  version: '0'
183
186
  requirements: []
184
- rubygems_version: 3.7.1
187
+ rubygems_version: 3.6.2
185
188
  specification_version: 4
186
189
  summary: A beginner-friendly Ruby interface for OpenAI's API
187
190
  test_files: []
data/lib/ai/http.rb DELETED
@@ -1,45 +0,0 @@
1
- require "net/http"
2
- module AI
3
- module Http
4
- def send_request(uri, method:, content_type: nil, parameters: nil)
5
- Net::HTTP.start(uri.host, 443, use_ssl: true) do |http|
6
- headers = {
7
- "Authorization" => "Bearer #{@api_key}"
8
- }
9
- if content_type
10
- headers.store("Content-Type", "application/json")
11
- end
12
- net_http_method = "Net::HTTP::#{method.downcase.capitalize}"
13
- client = Kernel.const_get(net_http_method)
14
- request = client.new(uri, headers)
15
-
16
- if parameters
17
- request.body = parameters.to_json
18
- end
19
- response = http.request(request)
20
-
21
- # Handle proxy server 503 HTML response
22
- begin
23
- if content_type
24
- return JSON.parse(response.body, symbolize_names: true)
25
- else
26
- return response.body
27
- end
28
- rescue JSON::ParserError, TypeError => e
29
- raise JSON::ParserError, "Failed to parse response from proxy: #{e.message}"
30
- end
31
- end
32
- end
33
-
34
- def create_deep_struct(value)
35
- case value
36
- when Hash
37
- OpenStruct.new(value.transform_values { |hash_value| send __method__, hash_value })
38
- when Array
39
- value.map { |element| send __method__, element }
40
- else
41
- value
42
- end
43
- end
44
- end
45
- end