2024-03-18 19:27:53 +00:00
|
|
|
|
// Copyright 2023 Google LLC
|
|
|
|
|
|
//
|
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
//
|
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
//
|
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
2025-02-26 10:25:50 -08:00
|
|
|
|
protocol GenerativeAIRequest: Sendable, Encodable {
|
2025-06-09 19:38:37 -04:00
|
|
|
|
associatedtype Response: Sendable, Decodable
|
2024-03-18 19:27:53 +00:00
|
|
|
|
|
2025-10-31 16:48:46 -07:00
|
|
|
|
func getURL() throws -> URL
|
2024-03-18 19:27:53 +00:00
|
|
|
|
|
|
|
|
|
|
var options: RequestOptions { get }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Configuration parameters for sending requests to the backend.
|
2026-06-04 20:56:54 -04:00
|
|
|
|
public struct RequestOptions: Sendable, Hashable {
|
2024-03-18 19:27:53 +00:00
|
|
|
|
/// The request’s timeout interval in seconds; if not specified uses the default value for a
|
|
|
|
|
|
/// `URLRequest`.
|
2024-09-26 11:35:04 -04:00
|
|
|
|
let timeout: TimeInterval
|
2024-03-18 19:27:53 +00:00
|
|
|
|
|
2025-01-30 17:57:06 -05:00
|
|
|
|
/// Initializes a request options object.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// - Parameters:
|
|
|
|
|
|
/// - timeout: The request’s timeout interval in seconds; defaults to 180 seconds.
|
|
|
|
|
|
public init(timeout: TimeInterval = 180.0) {
|
2025-03-05 16:50:54 -05:00
|
|
|
|
self.timeout = timeout
|
2024-03-18 19:27:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-12-06 17:50:56 -05:00
|
|
|
|
|
|
|
|
|
|
extension RequestOptions: Equatable {}
|