1
- #if NET472_OR_GREATER || NETSTANDARD2_0
2
- using System . Text . Json . Serialization ;
3
- #endif
4
- using System . Collections . Generic ;
5
- using System . Linq ;
6
-
7
- namespace Mscc . GenerativeAI
8
- {
9
- // Todo: Integrate GenerationConfig, SafetySettings, and Tools.
10
- public class GenerateContentRequest
11
-
12
- {
13
- public List < Content > ? Contents { get ; set ; }
14
- [ JsonPropertyName ( "generation_config" ) ]
15
- public GenerationConfig ? GenerationConfig { get ; set ; }
16
- [ JsonPropertyName ( "safety_settings" ) ]
17
- public List < SafetySetting > ? SafetySettings { get ; set ; }
18
- public List < Tool > ? Tools { get ; set ; }
19
-
20
- public GenerateContentRequest ( ) { }
21
-
22
- public GenerateContentRequest ( string prompt , GenerationConfig ? generationConfig = null , List < SafetySetting > ? safetySettings = null , List < Tool > ? tools = null )
23
- {
24
- Contents = new List < Content > { new Content
25
- {
26
- Parts = new List < IPart > { new TextData
27
- {
28
- Text = prompt
29
- } }
30
- } } ;
31
- if ( generationConfig != null ) GenerationConfig = generationConfig ;
32
- if ( safetySettings != null ) SafetySettings = safetySettings ;
33
- if ( tools != null ) Tools = tools ;
34
- }
35
-
36
- public GenerateContentRequest ( List < IPart > parts , GenerationConfig ? generationConfig = null , List < SafetySetting > ? safetySettings = null , List < Tool > ? tools = null )
37
- {
38
- Contents = new List < Content > { new Content
39
- {
40
- Parts = parts
41
- } } ;
42
- if ( generationConfig != null ) GenerationConfig = generationConfig ;
43
- if ( safetySettings != null ) SafetySettings = safetySettings ;
44
- if ( tools != null ) Tools = tools ;
45
- }
46
-
47
- public GenerateContentRequest ( List < Part > parts , GenerationConfig ? generationConfig = null , List < SafetySetting > ? safetySettings = null , List < Tool > ? tools = null )
48
- {
49
- Contents = new List < Content > { new Content
50
- {
51
- Parts = parts . Select ( p => ( IPart ) p ) . ToList ( )
52
- } } ;
53
- if ( generationConfig != null ) GenerationConfig = generationConfig ;
54
- if ( safetySettings != null ) SafetySettings = safetySettings ;
55
- if ( tools != null ) Tools = tools ;
56
- }
57
-
58
- internal void Synchronize ( )
59
- {
60
- foreach ( var content in Contents )
61
- {
62
- content . SynchronizeParts ( ) ;
63
- }
64
- }
65
- }
1
+ #if NET472_OR_GREATER || NETSTANDARD2_0
2
+ using System . Text . Json . Serialization ;
3
+ #endif
4
+ using System . Collections . Generic ;
5
+ using System . Linq ;
6
+
7
+ namespace Mscc . GenerativeAI
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ public class GenerateContentRequest
13
+
14
+ {
15
+ public List < Content > ? Contents { get ; set ; }
16
+ [ JsonPropertyName ( "generation_config" ) ]
17
+ public GenerationConfig ? GenerationConfig { get ; set ; }
18
+ [ JsonPropertyName ( "safety_settings" ) ]
19
+ public List < SafetySetting > ? SafetySettings { get ; set ; }
20
+ public List < Tool > ? Tools { get ; set ; }
21
+
22
+ public GenerateContentRequest ( ) { }
23
+
24
+ public GenerateContentRequest ( string prompt , GenerationConfig ? generationConfig = null , List < SafetySetting > ? safetySettings = null , List < Tool > ? tools = null )
25
+ {
26
+ Contents = new List < Content > { new Content
27
+ {
28
+ Parts = new List < IPart > { new TextData
29
+ {
30
+ Text = prompt
31
+ } }
32
+ } } ;
33
+ if ( generationConfig != null ) GenerationConfig = generationConfig ;
34
+ if ( safetySettings != null ) SafetySettings = safetySettings ;
35
+ if ( tools != null ) Tools = tools ;
36
+ }
37
+
38
+ public GenerateContentRequest ( List < IPart > parts , GenerationConfig ? generationConfig = null , List < SafetySetting > ? safetySettings = null , List < Tool > ? tools = null )
39
+ {
40
+ Contents = new List < Content > { new Content
41
+ {
42
+ Parts = parts
43
+ } } ;
44
+ if ( generationConfig != null ) GenerationConfig = generationConfig ;
45
+ if ( safetySettings != null ) SafetySettings = safetySettings ;
46
+ if ( tools != null ) Tools = tools ;
47
+ }
48
+
49
+ public GenerateContentRequest ( List < Part > parts , GenerationConfig ? generationConfig = null , List < SafetySetting > ? safetySettings = null , List < Tool > ? tools = null )
50
+ {
51
+ Contents = new List < Content > { new Content
52
+ {
53
+ Parts = parts . Select ( p => ( IPart ) p ) . ToList ( )
54
+ } } ;
55
+ if ( generationConfig != null ) GenerationConfig = generationConfig ;
56
+ if ( safetySettings != null ) SafetySettings = safetySettings ;
57
+ if ( tools != null ) Tools = tools ;
58
+ }
59
+ }
66
60
}
0 commit comments