Skip to content

Commit

Permalink
Release 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sgusakovsky committed Mar 5, 2023
1 parent b75c8fc commit be2a859
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion OpenAIService.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'OpenAIService'
spec.version = '1.1.9'
spec.version = '1.2.0'
spec.homepage = 'https://github.com/sgusakovsky/OpenAIService'
spec.license = {
:type => 'MIT',
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenAIService/Configuration/OpenAIConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import Foundation

public struct OpenAIConfiguration {
/// The organization ID of the user.
public let organizationId: String
public let organizationId: String?

/// The API key associated with the user.
let apiKey: String

public init(organizationId: String, apiKey: String) {
public init(organizationId: String? = nil, apiKey: String) {
self.organizationId = organizationId
self.apiKey = apiKey
}
Expand Down
7 changes: 7 additions & 0 deletions Sources/OpenAIService/Networking/OpenAIApiClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class OpenAIApiClient {
request.setValue("Bearer \(config.apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

if let organizationId = config.organizationId {
request.setValue(organizationId, forHTTPHeaderField: "OpenAI-Organization")
}

let encoder = JSONEncoder()
if let encoded = try? encoder.encode(body) {
request.httpBody = encoded
Expand Down Expand Up @@ -101,6 +105,9 @@ class OpenAIApiClient {
}

request.setValue("Bearer \(config.apiKey)", forHTTPHeaderField: "Authorization")
if let organizationId = config.organizationId {
request.setValue(organizationId, forHTTPHeaderField: "OpenAI-Organization")
}
return request
}

Expand Down

0 comments on commit be2a859

Please sign in to comment.