Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add baseURL for the proxy #208

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/GoogleAI/CountTokensRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension CountTokensRequest: GenerativeAIRequest {
typealias Response = CountTokensResponse

var url: URL {
URL(string: "\(GenerativeAISwift.baseURL)/\(options.apiVersion)/\(model):countTokens")!
URL(string: "\(options.baseURL ?? GenerativeAISwift.baseURL)/\(options.apiVersion)/\(model):countTokens")!
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/GoogleAI/GenerateContentRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension GenerateContentRequest: GenerativeAIRequest {
typealias Response = GenerateContentResponse

var url: URL {
let modelURL = "\(GenerativeAISwift.baseURL)/\(options.apiVersion)/\(model)"
let modelURL = "\(options.baseURL ?? GenerativeAISwift.baseURL)/\(options.apiVersion)/\(model)"
if isStreaming {
return URL(string: "\(modelURL):streamGenerateContent?alt=sse")!
} else {
Expand Down
7 changes: 6 additions & 1 deletion Sources/GoogleAI/GenerativeAIRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@ public struct RequestOptions {

/// The API version to use in requests to the backend.
let apiVersion: String

/// The Base URL for the proxy.
let baseURL: String?

/// Initializes a request options object.
///
/// - Parameters:
/// - timeout: The request’s timeout interval in seconds; defaults to 300 seconds (5 minutes).
/// - apiVersion: The API version to use in requests to the backend; defaults to "v1beta".
public init(timeout: TimeInterval = 300.0, apiVersion: String = "v1beta") {
/// - baseURL: The Base URL for the proxy.
public init(timeout: TimeInterval = 300.0, apiVersion: String = "v1beta", baseURL: String? = nil) {
self.timeout = timeout
self.apiVersion = apiVersion
self.baseURL = baseURL
}
}
Loading