| 
									
										
										
										
											2024-10-02 11:42:27 -07:00
										 |  |  | // Copyright (c) Microsoft Corporation. All rights reserved. | 
					
						
							| 
									
										
										
										
											2024-06-10 10:31:45 -07:00
										 |  |  | // Chat_With_Vertex_Gemini.cs | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-13 01:01:16 -07:00
										 |  |  | #region Using | 
					
						
							| 
									
										
										
										
											2024-06-10 10:31:45 -07:00
										 |  |  | using AutoGen.Core; | 
					
						
							| 
									
										
										
										
											2024-06-13 01:01:16 -07:00
										 |  |  | #endregion Using | 
					
						
							| 
									
										
										
										
											2024-06-10 10:31:45 -07:00
										 |  |  | using FluentAssertions; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace AutoGen.Gemini.Sample; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public class Chat_With_Vertex_Gemini | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     public static async Task RunAsync() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2024-06-13 01:01:16 -07:00
										 |  |  |         #region Create_Gemini_Agent | 
					
						
							| 
									
										
										
										
											2024-06-10 10:31:45 -07:00
										 |  |  |         var projectID = Environment.GetEnvironmentVariable("GCP_VERTEX_PROJECT_ID"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (projectID is null) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             Console.WriteLine("Please set GCP_VERTEX_PROJECT_ID environment variable."); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         var geminiAgent = new GeminiChatAgent( | 
					
						
							|  |  |  |                 name: "gemini", | 
					
						
							|  |  |  |                 model: "gemini-1.5-flash-001", | 
					
						
							|  |  |  |                 location: "us-east1", | 
					
						
							|  |  |  |                 project: projectID, | 
					
						
							|  |  |  |                 systemMessage: "You are a helpful C# engineer, put your code between ```csharp and ```, don't explain the code") | 
					
						
							|  |  |  |             .RegisterMessageConnector() | 
					
						
							|  |  |  |             .RegisterPrintMessage(); | 
					
						
							|  |  |  |         #endregion Create_Gemini_Agent | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-13 01:01:16 -07:00
										 |  |  |         #region Chat_With_Vertex_Gemini | 
					
						
							| 
									
										
										
										
											2024-06-10 10:31:45 -07:00
										 |  |  |         var reply = await geminiAgent.SendAsync("Can you write a piece of C# code to calculate 100th of fibonacci?"); | 
					
						
							| 
									
										
										
										
											2024-06-13 01:01:16 -07:00
										 |  |  |         #endregion Chat_With_Vertex_Gemini | 
					
						
							| 
									
										
										
										
											2024-06-10 10:31:45 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         #region verify_reply | 
					
						
							|  |  |  |         reply.Should().BeOfType<TextMessage>(); | 
					
						
							|  |  |  |         #endregion verify_reply | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |