simple-openai-client 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72926afa553102dd0afd14cdfd2e046745a7f3c86a5f7e54363a179215c1cfd9
4
- data.tar.gz: 7cb6614a86e51425d4b8062c758d10fd1d628401260f51e4fccc3d94f1faa2fe
3
+ metadata.gz: c14118266582c1aab20eaf87badf7ecbd547e97040eabe674ce7b118d1945352
4
+ data.tar.gz: 1b3f51fac5d7be0160aeb5f5939e78ad175a414824081d20c2401765ae47a675
5
5
  SHA512:
6
- metadata.gz: 7cf0dbff473cc71c5375856bcae107af3cc5769f49afe7c8ec950465839830ce6a68875bb237c8c9c8290afa37a4178f1b1de119d3c6da7e5cd4877b423c6452
7
- data.tar.gz: efb36b72044ac6f8b69e0d0fdb93530186329fe1415c5bdbd5fbcb2c3e0a05149bc88dafbd039a0da91e33c3761a6a3429265f757825c8f4fecdc010992f7509
6
+ metadata.gz: 8e082c4e9176c5a87d7d56d1ceb7756473b280cf84eb93d7f375a018dbf64dfe24969e6ecd9efe3b0366592c6ec0ef8692e73ebc198f0b37195f22c89e0f7163
7
+ data.tar.gz: 2a9eeb217d03d5e5d90a4855601bc69903398bfc40354a628c4abd65a8fb6d24c2818d848e6bed1f0fbbf461fbc6704177acb79fc44c592236a339ff76f5422b
@@ -5,6 +5,7 @@
5
5
  require 'net/http'
6
6
  require 'uri'
7
7
  require 'json'
8
+ require 'colorize'
8
9
 
9
10
  class OpenAIClient
10
11
  attr_accessor :api_key, :model, :messages, :functions, :callbacks, :version
@@ -69,7 +70,11 @@ class OpenAIClient
69
70
  # If you want the model to call a function explicitly, you can add: "function_call" => "auto"
70
71
  }
71
72
 
72
- request_body["functions"] = self.functions if self.functions.size > 0
73
+ if self.functions.size > 0
74
+ request_body["functions"] = self.functions
75
+ # Important: enable function-calling
76
+ request_body["function_call"] = "auto"
77
+ end
73
78
 
74
79
  http = Net::HTTP.new(uri.host, uri.port)
75
80
  http.use_ssl = true
@@ -121,7 +126,7 @@ class OpenAIClient
121
126
 
122
127
  follow_up_request = Net::HTTP::Post.new(follow_up_uri.path, {
123
128
  "Content-Type" => "application/json",
124
- "Authorization" => "Bearer #{OPENAI_API_KEY}",
129
+ "Authorization" => "Bearer #{self.api_key}",
125
130
  "OpenAI-Beta" => "assistants=#{version}"
126
131
  })
127
132
  follow_up_request.body = JSON.dump(follow_up_request_body)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'simple-openai-client'
3
- s.version = '1.0.2'
4
- s.date = '2025-01-05'
3
+ s.version = '1.0.4'
4
+ s.date = '2025-01-18'
5
5
  s.summary = "Very simple Ruby library for operating OpenAI API for building Agents."
6
6
  s.description = "Very simple Ruby library for operating OpenAI API for building Agents."
7
7
  s.authors = ["Leandro Daniel Sardi"]
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-openai-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-01-05 00:00:00.000000000 Z
10
+ date: 2025-01-18 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: uri
@@ -142,7 +141,6 @@ homepage: https://github.com/leandrosardi/simple-openai-client
142
141
  licenses:
143
142
  - MIT
144
143
  metadata: {}
145
- post_install_message:
146
144
  rdoc_options: []
147
145
  require_paths:
148
146
  - lib
@@ -157,8 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
155
  - !ruby/object:Gem::Version
158
156
  version: '0'
159
157
  requirements: []
160
- rubygems_version: 3.3.7
161
- signing_key:
158
+ rubygems_version: 3.6.3
162
159
  specification_version: 4
163
160
  summary: Very simple Ruby library for operating OpenAI API for building Agents.
164
161
  test_files: []