Package: mdgpt
mdGPT - Markdown General Purpose TransformerTranslate markdown files using OpenAI ChatGPT, and generate localized copies of each file.InstallationUsing pippipinstallmdgptSet environment variableOPENAI_API_KEYor create it in a.envfileexportOPENAI_API_KEY=YOUR_API_KEYDownload example prompts:curl-oexample.yamlhttps://raw.githubusercontent.com/Djarnis/mdGPT/main/prompts.yamlUse the exampleWEBSITE_BUILDERoption from the prompts to build some example files;mdgptbuildexampleTranslate these newly created markdown files into Finish (fi) versions:mdgpttranslateexample--targetfior Danish (da):mdgpttranslateexample--targetdaor German (de):mdgpttranslateexample--targetdeOr whatever. Just make sure it is an ISO 639-1 two-letter language code, and all should be fine.Adjust theexample.yamlprompts to suit your needs.MODELYou can change theMODELto any engine supported by OpenAI, change the default temperature, and adjust max tokens.Default values are:MODEL:temperature:0.2engine:gpt-3.5-turbomax_tokens:2048WEBSITE_BUILDERThis option is used for building mark down documents, given the example instructions below:WEBSITE_BUILDER:variables:title:the fictive product "AI Markdown Translator"tone:sarcastic passive aggressiveyear_founded:2019major_milestones:3system_prompt:|Only reply in valid markdown with frontmatter.No explanations. No notes.Language: {lang[name]}Markdown Document:---# Frontmatter attributes:title: Title of webpagedescription: Short meta description---<!-- markdown content --># This will be appended as a last line to all step promptsuser_suffix:|Respond in valid markdown format including all provided frontmatter attributes.It should be in a {tone} tone.steps:-prompt:|Write the homepage content for {title} in {lang_name} ({lang_code}).destination:index.md-prompt:|Write the "About Us" page content for a fictive team behind {title} in {lang_name} ({lang_code}).destination:about.md-prompt:|Write the history for {title} in {lang_name} ({lang_code}), starting in {year_founded} with {major_milestones} major milestones.destination:history.md-prompt:|Write a contact page for {title} in {lang_name} ({lang_code}). Make the headquarter be at some fancy addres in Silicon Valley.destination:contact.mdURL_PROMPTThis prompt is used when translating file paths.URL_PROMPT:-role:systemprompt:|Only reply in valid json.No explanations. No notes.Language: {lang_name}JSON document:{content}-role:userprompt:|Translate all keys in the JSON document.The keys are in {lang_name} ({lang_code}).They are url paths for a website in {lang_name}.I need you to fill out the missing values with a translated {target_lang[name]} ({target_lang_code}) version.Should contain no special characters (hyphens and slashes are ok, as are dots in file extensions (like .md) if any).Respond in the same format as the JSON input given, with the `key` as the json key and the (translated) `value` as the value.Example translating from English to Danish:"about-us.md": "om-os.md"MARKDOWN_PROMPTThis prompt is used when translating markdown files.MARKDOWN_PROMPT:-role:systemprompt:|Only reply in valid markdown with frontmatter.No explanations. No notes.Language: {lang_name}Markdown Document:---# Frontmatter can be anything or nothing, but always make sure to include the frontmatter dashes.{frontmatter}---{content}-role:userprompt:|Translate all given values from {lang_name} ({lang_code}) to {target_lang[name]} ({target_lang_code}).Respond in valid markdown format.ONLY_INDEXESOptional boolean value, if you only wantindex.mdfiles translated when translating URL's.ONLY_INDEXES:TrueFIELD_KEYSOptional list of frontmatter keys you want to translate.Per default, all keys will be translated, but you can define selected ones here.FIELD_KEYS:-title-description-keywords-heading-teaserTARGET_LANGUAGESList of languages you want to target.TARGET_LANGUAGES:-da-de-fr-es-it-zhYou can run translations on all target languages by not specifying--target.mdgpttranslateexampleUsing repo source and Poetry:Step 1: Install PoetryOn Unix-based systems like Linux and MacOS, you can install Poetry by using the following command in your terminal:curl-sSLhttps://install.python-poetry.org|python-On Windows, you can use PowerShell to install Poetry with the following command:(Invoke-WebRequest-Urihttps://install.python-poetry.org-UseBasicParsing).Content|python-You can check if Poetry was installed correctly by running:poetry--versionStep 2: Rename .env.tpl to .envIn your project directory, you have a file named .env.tpl which serves as a template for environment variables. To use this file, you should rename it to .env.On Unix-based systems, use the following command:mv.env.tpl.envOn Windows, use the following command:rename.env.tpl.envStep 3: Add OPENAI_API_KEY value to .envOpen your .env file in a text editor. You should see a line that looks something like this:OPENAI_API_KEY=After the equal sign, add your OpenAI API key in quotes. It should look something like this:OPENAI_API_KEY="your-api-key-goes-here"Save the .env file and close it.Please note:Make sure to replace "your-api-key-goes-here" with your actual OpenAI API key.Do not share your .env file or post it online, as it contains sensitive information.Step 4: Install mdGPTFrom the project directory, build and install mdGPT and its dependencies:poetrybuildpoetryinstallThis installs mdGPT and all its dependencies, and you can now follow the example below.ExampleBuild Markdown filesThe example website (./example/en) was created using theWEBSITE_BUILDERoption included in theprompts.yamlfile.poetryrunmdgptbuildexampleWhich will create these files in the ./example/en directory:index.mdabout.mdcontact.mdhistory.mdTranslate websiteTo translate the markdown files into Finish (fi) versions, run this command:poetryrunmdgpttranslateexample--targetfiAnd you should get a/fisubdirectory ./example/fi/ containing these files, translated from their original English (en) source:index.mdtietoja.mdyhteystiedot.mdhistoria.md