forked from microsoft/Generative-AI-for-beginners-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.cs
More file actions
22 lines (17 loc) · 1.06 KB
/
Copy pathapp.cs
File metadata and controls
22 lines (17 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#:package OllamaSharp@5.4.18
#:package Microsoft.Extensions.Configuration.UserSecrets@10.0.3
using Microsoft.Extensions.AI;
using OllamaSharp;
using System.Text;
IChatClient client =
new OllamaApiClient(new Uri("http://localhost:11434/"), "phi4-mini");
// here we're building the prompt
StringBuilder prompt = new StringBuilder();
prompt.AppendLine("You will analyze the sentiment of the following product reviews. Each line is its own review. Output the sentiment of each review in a bulleted list including the original text and the sentiment, and then provide a generate sentiment of all reviews. ");
prompt.AppendLine("I bought this product and it's amazing. I love it!");
prompt.AppendLine("This product is terrible. I hate it.");
prompt.AppendLine("I'm not sure about this product. It's okay.");
prompt.AppendLine("I found this product based on the other reviews. It worked for a bit, and then it didn't.");
// send the prompt to the model and wait for the text completion
var response = await client.GetResponseAsync(prompt.ToString());
Console.WriteLine(response.Text);