Naposledy aktivní 1755074564

program.cs Raw
1using Aiursoft.GptClient;
2using Aiursoft.GptClient.Services;
3using Microsoft.Extensions.DependencyInjection;
4using Microsoft.Extensions.Logging;
5
6namespace Test
7{
8 public abstract class Program
9 {
10 private static readonly string PromptGetIdea =
11 """
12
13
14 窿
15
16
17
18 湿
19
20
21
22 IPv6取之不尽
23
24 IPv6作为下一代互联网协议2^128"可以为地球上每一粒沙子分配一个IP地址"
25
26 IPv6地址资源如此丰富(ISP)IPv6地址
27
28 西
29
30 耀
31
32
33
34 姿
35
36 姿亿
37
38
39
40
41
42
43
44
45
46
47
48 西
49
50
51 """;
52
53 private static readonly string PromptGetIntroduction =
54 """
55 {0}
56
57
58
59
60
61 仿
62 """;
63
64 private static readonly string PromptGetFullArticle =
65 """
66 {0}
67
68 仿
69 """;
70
71 public static async Task Main()
72 {
73 #region prepare
74 var apiKey = "";
75 var endpoint = "http://localhost:11434/api/chat";
76 var model = "qwen3:30b-a3b-thinking-2507-q8_0";
77 var services = new ServiceCollection();
78 services.AddHttpClient();
79 services.AddLogging(logging => { logging.SetMinimumLevel(LogLevel.Warning); });
80 services.AddGptClient();
81 var serviceProvider = services.BuildServiceProvider();
82 var chatClient = serviceProvider.GetRequiredService<ChatClient>();
83 async Task<string> GetAnswer(string[] prompts)
84 {
85 return (await chatClient.AskString(
86 modelType: model,
87 completionApiUrl: endpoint,
88 token: apiKey,
89 content: prompts,
90 CancellationToken.None)).GetAnswerPart();
91 }
92 #endregion
93
94 for (int i = 0; i < 1000; i++)
95 {
96 var idea = await GetAnswer([PromptGetIdea]);
97 var introduction = await GetAnswer([string.Format(PromptGetIntroduction, idea)]);
98 var fullArticle = await GetAnswer([string.Format(PromptGetFullArticle, introduction)]);
99 await File.WriteAllTextAsync($"article{i}.md", fullArticle);
100 }
101 }
102 }
103}