@@ -29,18 +29,18 @@ public final class TemplateGenerativeModel: Sendable {
2929 /// Generates content from a prompt template and inputs.
3030 ///
3131 /// - Parameters:
32- /// - template : The prompt template to use.
33- /// - variables : A dictionary of variables to substitute into the template.
32+ /// - templateID : The ID of the prompt template to use.
33+ /// - inputs : A dictionary of variables to substitute into the template.
3434 /// - Returns: The content generated by the model.
3535 /// - Throws: A ``GenerateContentError`` if the request failed.
36- public func generateContent( template : String ,
36+ public func generateContent( templateID : String ,
3737 inputs: [ String : Any ] ,
3838 options: RequestOptions = RequestOptions ( ) ) async throws
3939 -> GenerateContentResponse {
4040 let templateInputs = try inputs. mapValues { try TemplateInput ( value: $0) }
4141 return try await generateContentWithHistory (
4242 history: [ ] ,
43- template: template ,
43+ template: templateID ,
4444 inputs: templateInputs,
4545 options: options
4646 )
@@ -51,7 +51,7 @@ public final class TemplateGenerativeModel: Sendable {
5151 /// - Parameters:
5252 /// - history: The conversation history to use.
5353 /// - template: The prompt template to use.
54- /// - variables : A dictionary of variables to substitute into the template.
54+ /// - inputs : A dictionary of variables to substitute into the template.
5555 /// - Returns: The content generated by the model.
5656 /// - Throws: A ``GenerateContentError`` if the request failed.
5757 func generateContentWithHistory( history: [ ModelContent ] , template: String ,
@@ -72,13 +72,20 @@ public final class TemplateGenerativeModel: Sendable {
7272 return response
7373 }
7474
75- public func generateContentStream( template: String ,
75+ /// Generates content from a prompt template and inputs, with streaming responses.
76+ ///
77+ /// - Parameters:
78+ /// - templateID: The ID of the prompt template to use.
79+ /// - inputs: A dictionary of variables to substitute into the template.
80+ /// - Returns: An `AsyncThrowingStream` that yields `GenerateContentResponse` objects.
81+ /// - Throws: A ``GenerateContentError`` if the request failed.
82+ public func generateContentStream( templateID: String ,
7683 inputs: [ String : Any ] ,
7784 options: RequestOptions = RequestOptions ( ) ) throws
7885 -> AsyncThrowingStream < GenerateContentResponse , Error > {
7986 let templateInputs = try inputs. mapValues { try TemplateInput ( value: $0) }
8087 let request = TemplateGenerateContentRequest (
81- template: template ,
88+ template: templateID ,
8289 inputs: templateInputs,
8390 history: [ ] ,
8491 projectID: generativeAIService. firebaseInfo. projectID,
@@ -108,14 +115,14 @@ public final class TemplateGenerativeModel: Sendable {
108115 /// Creates a new chat conversation using this model with the provided history and template.
109116 ///
110117 /// - Parameters:
111- /// - template : The prompt template to use.
118+ /// - templateID : The ID of the prompt template to use.
112119 /// - history: The conversation history to use.
113120 /// - Returns: A new ``TemplateChatSession`` instance.
114- public func startChat( template : String ,
121+ public func startChat( templateID : String ,
115122 history: [ ModelContent ] = [ ] ) -> TemplateChatSession {
116123 return TemplateChatSession (
117124 model: self ,
118- template : template ,
125+ templateID : templateID ,
119126 history: history
120127 )
121128 }
0 commit comments