|
1 | 1 | using Microsoft.SemanticKernel; |
| 2 | +using System; |
| 3 | +using System.Threading.Tasks; |
| 4 | +using Microsoft.SemanticKernel.Plugins.Core; |
| 5 | +//using RepoUtils; |
2 | 6 |
|
3 | 7 | namespace GeneralUpdate.Bowl |
4 | 8 | { |
5 | 9 | public class BowlBootstrap |
6 | 10 | { |
7 | | - public async Task Launch() |
| 11 | + public void test() |
8 | 12 | { |
9 | | - var builder = new KernelBuilder(); |
| 13 | + Console.WriteLine("======== Functions ========"); |
10 | 14 |
|
11 | | - builder.WithAzureChatCompletionService( |
12 | | - "gpt-35-turbo", // Azure OpenAI Deployment Name |
13 | | - "https://contoso.openai.azure.com/", // Azure OpenAI Endpoint |
14 | | - "...your Azure OpenAI Key..."); // Azure OpenAI Key |
| 15 | + // Load native plugin |
| 16 | + var text = new TextPlugin(); |
15 | 17 |
|
16 | | - // Alternative using OpenAI |
17 | | - //builder.WithOpenAIChatCompletionService( |
18 | | - // "gpt-3.5-turbo", // OpenAI Model name |
19 | | - // "...your OpenAI API Key..."); // OpenAI API Key |
20 | | - |
21 | | - var kernel = builder.Build(); |
22 | | - |
23 | | - var prompt = @"{{$input}} |
24 | | -
|
25 | | -One line TLDR with the fewest words."; |
26 | | - |
27 | | - var summarize = kernel.CreateSemanticFunction(prompt, maxTokens: 100); |
28 | | - |
29 | | - string text1 = @" |
30 | | -1st Law of Thermodynamics - Energy cannot be created or destroyed. |
31 | | -2nd Law of Thermodynamics - For a spontaneous process, the entropy of the universe increases. |
32 | | -3rd Law of Thermodynamics - A perfect crystal at zero Kelvin has zero entropy."; |
33 | | - |
34 | | - string text2 = @" |
35 | | -1. An object at rest remains at rest, and an object in motion remains in motion at constant speed and in a straight line unless acted on by an unbalanced force. |
36 | | -2. The acceleration of an object depends on the mass of the object and the amount of force applied. |
37 | | -3. Whenever one object exerts a force on another object, the second object exerts an equal and opposite on the first."; |
38 | | - |
39 | | - Console.WriteLine(await summarize.InvokeAsync(text1)); |
40 | | - |
41 | | - Console.WriteLine(await summarize.InvokeAsync(text2)); |
42 | | - |
43 | | - // Output: |
44 | | - // Energy conserved, entropy increases, zero entropy at 0K. |
45 | | - // Objects move in response to forces. |
| 18 | + // Use function without kernel |
| 19 | + var result = text.Uppercase("Ai4c research institute!"); |
| 20 | + Console.WriteLine(result); |
46 | 21 | } |
47 | 22 | } |
48 | 23 | } |
0 commit comments