@@ -196,12 +196,12 @@ public final class GenerativeModel: Sendable {
196196
197197 @discardableResult
198198 public final nonisolated ( nonsending)
199- func respond( to prompt: any PartsRepresentable , schema: JSONSchema ,
199+ func respond( to prompt: any PartsRepresentable , schema: FirebaseGenerationSchema ,
200200 includeSchemaInPrompt: Bool = true , options: GenerationConfig ? = nil )
201- async throws -> GenerativeModel . Response < ModelOutput > {
201+ async throws -> GenerativeModel . Response < FirebaseGeneratedContent > {
202202 return try await respond (
203203 to: prompt,
204- generating: ModelOutput . self,
204+ generating: FirebaseGeneratedContent . self,
205205 schema: schema,
206206 includeSchemaInPrompt: includeSchemaInPrompt,
207207 options: options
@@ -217,7 +217,7 @@ public final class GenerativeModel: Sendable {
217217 return try await respond (
218218 to: prompt,
219219 generating: type,
220- schema: type. jsonSchema ,
220+ schema: type. firebaseGenerationSchema ,
221221 includeSchemaInPrompt: includeSchemaInPrompt,
222222 options: options
223223 )
@@ -230,11 +230,12 @@ public final class GenerativeModel: Sendable {
230230 includeSchemaInPrompt: false , options: options)
231231 }
232232
233- public final func streamResponse( to prompt: any PartsRepresentable , schema: JSONSchema ,
233+ public final func streamResponse( to prompt: any PartsRepresentable ,
234+ schema: FirebaseGenerationSchema ,
234235 includeSchemaInPrompt: Bool = true ,
235236 options: GenerationConfig ? = nil )
236- -> sending GenerativeModel. ResponseStream < ModelOutput > {
237- return streamResponse ( to: prompt, generating: ModelOutput . self, schema: schema,
237+ -> sending GenerativeModel. ResponseStream < FirebaseGeneratedContent > {
238+ return streamResponse ( to: prompt, generating: FirebaseGeneratedContent . self, schema: schema,
238239 includeSchemaInPrompt: includeSchemaInPrompt, options: options)
239240 }
240241
@@ -243,7 +244,7 @@ public final class GenerativeModel: Sendable {
243244 includeSchemaInPrompt: Bool = true ,
244245 options: GenerationConfig ? = nil )
245246 -> sending GenerativeModel. ResponseStream < Content > where Content: FirebaseGenerable {
246- return streamResponse ( to: prompt, generating: type, schema: type. jsonSchema ,
247+ return streamResponse ( to: prompt, generating: type, schema: type. firebaseGenerationSchema ,
247248 includeSchemaInPrompt: includeSchemaInPrompt, options: options)
248249 }
249250 #endif // compiler(>=6.2)
@@ -455,15 +456,15 @@ public final class GenerativeModel: Sendable {
455456 #if compiler(>=6.2)
456457 final nonisolated ( nonsending)
457458 func respond< Content> ( to prompt: any PartsRepresentable , generating type: Content . Type ,
458- schema: JSONSchema ? , includeSchemaInPrompt: Bool ,
459+ schema: FirebaseGenerationSchema ? , includeSchemaInPrompt: Bool ,
459460 options: GenerationConfig ? )
460461 async throws -> GenerativeModel . Response < Content > where Content: FirebaseGenerable {
461462 let parts = [ ModelContent ( parts: prompt) ]
462463
463464 let generationConfig : GenerationConfig ?
464465 if let schema {
465466 generationConfig = GenerationConfig . merge (
466- self . generationConfig, with: options, enforcingJSONSchema : schema
467+ self . generationConfig, with: options, enforcingFirebaseGenerationSchema : schema
467468 )
468469 } else {
469470 generationConfig = GenerationConfig . merge ( self . generationConfig, with: options)
@@ -475,15 +476,23 @@ public final class GenerativeModel: Sendable {
475476 throw GenerationError . decodingFailure ( . init( debugDescription: " No text in response. " ) )
476477 }
477478 let responseID = response. responseID. map { ResponseID ( responseID: $0) }
478- let modelOutput : ModelOutput
479+ let firebaseGeneratedContent : FirebaseGeneratedContent
479480 if schema == nil {
480- modelOutput = ModelOutput ( kind: . string( text) , id: responseID, isComplete: true )
481+ firebaseGeneratedContent = FirebaseGeneratedContent (
482+ kind: . string( text) ,
483+ id: responseID,
484+ isComplete: true
485+ )
481486 } else {
482- modelOutput = try ModelOutput ( json: text, id: responseID, streaming: false )
487+ firebaseGeneratedContent = try FirebaseGeneratedContent (
488+ json: text,
489+ id: responseID,
490+ streaming: false
491+ )
483492 }
484493 return try GenerativeModel . Response< Content> (
485- content: Content ( modelOutput ) ,
486- rawContent: modelOutput ,
494+ content: Content ( firebaseGeneratedContent ) ,
495+ rawContent: firebaseGeneratedContent ,
487496 rawResponse: response
488497 )
489498 } catch let error as GenerationError {
@@ -499,15 +508,16 @@ public final class GenerativeModel: Sendable {
499508 }
500509
501510 final func streamResponse< Content> ( to prompt: any PartsRepresentable ,
502- generating type: Content . Type , schema: JSONSchema ? ,
511+ generating type: Content . Type ,
512+ schema: FirebaseGenerationSchema ? ,
503513 includeSchemaInPrompt: Bool , options: GenerationConfig ? )
504514 -> sending GenerativeModel. ResponseStream < Content > where Content: FirebaseGenerable {
505515 let parts = [ ModelContent ( parts: prompt) ]
506516
507517 let generationConfig : GenerationConfig ?
508518 if let schema {
509519 generationConfig = GenerationConfig . merge (
510- self . generationConfig, with: options, enforcingJSONSchema : schema
520+ self . generationConfig, with: options, enforcingFirebaseGenerationSchema : schema
511521 )
512522 } else {
513523 generationConfig = GenerationConfig . merge ( self . generationConfig, with: options)
@@ -521,11 +531,15 @@ public final class GenerativeModel: Sendable {
521531 if let text = response. text {
522532 json += text
523533 let responseID = response. responseID. map { ResponseID ( responseID: $0) }
524- let modelOutput = try ModelOutput ( json: json, id: responseID, streaming: true )
534+ let firebaseGeneratedContent = try FirebaseGeneratedContent (
535+ json: json,
536+ id: responseID,
537+ streaming: true
538+ )
525539 try await context. yield (
526540 GenerativeModel . ResponseStream< Content> . Snapshot(
527- content: Content . Partial ( modelOutput ) ,
528- rawContent: modelOutput ,
541+ content: Content . Partial ( firebaseGeneratedContent ) ,
542+ rawContent: firebaseGeneratedContent ,
529543 rawResponse: response
530544 )
531545 )
0 commit comments