@@ -88,47 +88,17 @@ public struct GeminiLanguageModel: LanguageModel {
8888 /// (URL context), code execution, and location services (Google Maps).
8989 public var serverTools : [ ServerTool ] ?
9090
91- /// Configures JSON mode for structured output.
92- ///
93- /// Use this type to enable JSON mode,
94- /// which constrains the model to output a valid JSON.
95- /// Optionally provide a schema for typed JSON output.
96- public enum JSONMode : Sendable , Hashable , ExpressibleByBooleanLiteral {
97- /// JSON mode is disabled (default text output).
98- case disabled
99-
100- /// JSON mode is enabled without a schema constraint.
101- case enabled
102-
103- /// JSON mode is enabled with a schema constraint for typed output.
104- case schema( JSONSchema )
105-
106- public init ( booleanLiteral value: Bool ) {
107- self = value ? . enabled : . disabled
108- }
109- }
110-
111- /// The JSON mode configuration for structured output.
112- ///
113- /// When set to `.enabled`, the model will output valid JSON.
114- /// When set to `.schema(_:)`, the model will output JSON
115- /// conforming to the provided schema.
116- public var jsonMode : JSONMode ?
117-
11891 /// Creates custom generation options for Gemini models.
11992 ///
12093 /// - Parameters:
12194 /// - thinking: The thinking mode configuration. When `nil`, uses the model's default.
12295 /// - serverTools: Server-side tools to enable. When `nil`, uses the model's default.
123- /// - jsonMode: The JSON mode configuration. When `nil`, uses the model's default.
12496 public init (
12597 thinking: Thinking ? = nil ,
126- serverTools: [ ServerTool ] ? = nil ,
127- jsonMode: JSONMode ? = nil
98+ serverTools: [ ServerTool ] ? = nil
12899 ) {
129100 self . thinking = thinking
130101 self . serverTools = serverTools
131- self . jsonMode = jsonMode
132102 }
133103 }
134104
@@ -270,7 +240,6 @@ public struct GeminiLanguageModel: LanguageModel {
270240 let customOptions = options [ custom: GeminiLanguageModel . self]
271241 let effectiveThinking = customOptions? . thinking ?? _thinking
272242 let effectiveServerTools = customOptions? . serverTools ?? _serverTools
273- let effectiveJsonMode = customOptions? . jsonMode
274243
275244 let url =
276245 baseURL
@@ -293,8 +262,7 @@ public struct GeminiLanguageModel: LanguageModel {
293262 contents: contents,
294263 tools: geminiTools,
295264 options: options,
296- thinking: effectiveThinking,
297- jsonMode: effectiveJsonMode
265+ thinking: effectiveThinking
298266 )
299267
300268 let body = try JSONEncoder ( ) . encode ( params)
@@ -382,7 +350,6 @@ public struct GeminiLanguageModel: LanguageModel {
382350 let customOptions = options [ custom: GeminiLanguageModel . self]
383351 let effectiveThinking = customOptions? . thinking ?? _thinking
384352 let effectiveServerTools = customOptions? . serverTools ?? _serverTools
385- let effectiveJsonMode = customOptions? . jsonMode
386353
387354 let userSegments = extractPromptSegments ( from: session, fallbackText: prompt. description)
388355 let contents = [
@@ -408,8 +375,7 @@ public struct GeminiLanguageModel: LanguageModel {
408375 contents: contents,
409376 tools: geminiTools,
410377 options: options,
411- thinking: effectiveThinking,
412- jsonMode: effectiveJsonMode
378+ thinking: effectiveThinking
413379 )
414380
415381 let body = try JSONEncoder ( ) . encode ( params)
@@ -494,8 +460,7 @@ private func createGenerateContentParams(
494460 contents: [ GeminiContent ] ,
495461 tools: [ GeminiTool ] ? ,
496462 options: GenerationOptions ,
497- thinking: GeminiLanguageModel . CustomGenerationOptions . Thinking ,
498- jsonMode: GeminiLanguageModel . CustomGenerationOptions . JSONMode ?
463+ thinking: GeminiLanguageModel . CustomGenerationOptions . Thinking
499464) throws -> [ String : JSONValue ] {
500465 var params : [ String : JSONValue ] = [
501466 " contents " : try JSONValue ( contents)
@@ -535,18 +500,6 @@ private func createGenerateContentParams(
535500 }
536501 generationConfig [ " thinkingConfig " ] = . object( thinkingConfig)
537502
538- if let jsonMode {
539- switch jsonMode {
540- case . disabled:
541- break
542- case . enabled:
543- generationConfig [ " responseMimeType " ] = . string( " application/json " )
544- case . schema( let schema) :
545- generationConfig [ " responseMimeType " ] = . string( " application/json " )
546- generationConfig [ " responseSchema " ] = try JSONValue ( schema)
547- }
548- }
549-
550503 if !generationConfig. isEmpty {
551504 params [ " generationConfig " ] = . object( generationConfig)
552505 }
0 commit comments