| 
									
										
										
										
											2024-10-02 11:42:27 -07:00
										 |  |  | // Copyright (c) Microsoft Corporation. All rights reserved. | 
					
						
							| 
									
										
										
										
											2024-05-23 21:14:29 -07:00
										 |  |  | // Chat_With_LLaMA.cs | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-28 14:55:40 -07:00
										 |  |  | #region Using | 
					
						
							| 
									
										
										
										
											2024-05-23 21:14:29 -07:00
										 |  |  | using AutoGen.Core; | 
					
						
							|  |  |  | using AutoGen.Ollama.Extension; | 
					
						
							| 
									
										
										
										
											2024-05-28 14:55:40 -07:00
										 |  |  | #endregion Using | 
					
						
							| 
									
										
										
										
											2024-05-23 21:14:29 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace AutoGen.Ollama.Sample; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public class Chat_With_LLaMA | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     public static async Task RunAsync() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2024-05-28 14:55:40 -07:00
										 |  |  |         #region Create_Ollama_Agent | 
					
						
							| 
									
										
										
										
											2024-05-23 21:14:29 -07:00
										 |  |  |         using var httpClient = new HttpClient() | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-05-28 14:55:40 -07:00
										 |  |  |             BaseAddress = new Uri("http://localhost:11434"), | 
					
						
							| 
									
										
										
										
											2024-05-23 21:14:29 -07:00
										 |  |  |         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         var ollamaAgent = new OllamaAgent( | 
					
						
							|  |  |  |             httpClient: httpClient, | 
					
						
							|  |  |  |             name: "ollama", | 
					
						
							|  |  |  |             modelName: "llama3:latest", | 
					
						
							|  |  |  |             systemMessage: "You are a helpful AI assistant") | 
					
						
							|  |  |  |             .RegisterMessageConnector() | 
					
						
							|  |  |  |             .RegisterPrintMessage(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         var reply = await ollamaAgent.SendAsync("Can you write a piece of C# code to calculate 100th of fibonacci?"); | 
					
						
							| 
									
										
										
										
											2024-05-28 14:55:40 -07:00
										 |  |  |         #endregion Create_Ollama_Agent | 
					
						
							| 
									
										
										
										
											2024-05-23 21:14:29 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | } |