Added constant state changers to represent singular/repeating states. Added a DownloadContextBuilder to support fluent building patterns. Changed RetryReporter and DownloadReporter to use RetryReport and DownloadReport structs to simplify type declarations. Made MainArchitecture obsolete by supporting a fluent downloads with DownloadBuilder. Created a 'budge' OpenAI bridge for proof-of-concept translation.

This commit is contained in:
qwsdcvghyu89
2025-06-07 00:56:26 +03:00
parent a086cfa02b
commit a9a22ea23d
28 changed files with 809 additions and 145 deletions
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenAI;
using OpenAI.Chat;
namespace Beam.Temporary.Cli {
public class QuickAndDirtyJanitor {
static OpenAIClient client;
static QuickAndDirtyJanitor() {
var key = Environment.GetEnvironmentVariable("OPEN_AI_KEY");
client = new OpenAIClient(key);
}
public static async Task<IDocument> TranslateAsync(IDocument document) {
var chatCompletion = await client.GetChatClient("gpt-4.1").CompleteChatAsync(
ChatMessage.CreateSystemMessage("Translate the following text into english. If any part of the text has no direct English translation, you may choose to leave it as is. In either case, make sure to leave footnotes for any difficult to translate words. You must translate the whole text and output only your translation and footnotes. No other comments are necessary."),
ChatMessage.CreateUserMessage("From UNKNOWN to ENGLISH.\n" + document.ToString()));
return new StringDocument(document.Filename, chatCompletion.Value.Content.DefaultIfEmpty().Select((x) => x?.Text).Aggregate((x,y) => $"{x}{y}"));
}
}
}