diff --git a/docs/README.md b/docs/README.md index 54c80cd..f7adfed 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,32 +1,43 @@ -# GPT-4 Session to Markdown Converter +# GPT-4 Session to Markdown -This repository contains a JQ script called `gpt4-session-to-md.jq` that converts GPT-4 chat session JSON data into a more readable Markdown format. +This script converts GPT-4 chat session JSON data to markdown format and adds YAML front matter to the top of the file to prepare it for publishing on a Jekyll site. ## Requirements -- [JQ](https://stedolan.github.io/jq/) command-line utility. +- [jq](https://stedolan.github.io/jq/) - A lightweight and flexible command-line JSON processor. ## Usage -1. Ensure the `gpt4-session-to-md.jq` script has executable permissions: - ```bash - chmod +x gpt4-session-to-md.jq - ``` -2. Use the script to convert your GPT-4 chat session JSON data into Markdown format: +1. Clone the repository: +```shell +git clone https://github.com/rabestro/gpt4-session-to-markdown.git +cd gpt4-session-to-markdown +``` - ```bash - ./gpt4-session-to-md.jq input.json > output.md - ``` +2. Make the script executable: +```shell +chmod +x post +``` -Replace input.json with the name of your input JSON file containing the GPT-4 chat session data and output.md with the desired name for the output Markdown file. +3. Run the script with the JSON file as an argument: +```shell +./post +``` + Replace `` with the path to your GPT-4 chat session JSON file. -## Example -For an example of input JSON data and the corresponding Markdown output, please refer to the following: +## Configuration -- [Sample Input JSON Data](sample-input.json) -- [Sample Output Markdown](sample-output.md) +You can customize the script by modifying the following variables at the beginning of the `post` script: -- [Sample Session with AI](github-pages.md) +- `POSTS_DIR`: The directory where the generated markdown files will be saved. Default is `../_posts`. +- `TIMEZONE`: The timezone to be used in the YAML front matter. Default is `+0300`. +- `CATEGORIES`: The categories to be used in the YAML front matter. Default is `AI`. +- `TAGS`: The tags to be used in the YAML front matter. Default is `ai`. ## License -This project is open-source and released under the [MIT License](LICENSE). + +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. + +## Showcases + +- [My Tech Blog](https://rabestro.github.io/) - My personal tech blog where I publish my GPT-4 chat sessions. diff --git a/docs/_posts/2023-08-24-binary-tree-maximum-path-sum.md b/docs/_posts/2023-08-24-binary-tree-maximum-path-sum.md deleted file mode 100644 index e333df6..0000000 --- a/docs/_posts/2023-08-24-binary-tree-maximum-path-sum.md +++ /dev/null @@ -1,527 +0,0 @@ ---- -layout: post -title: "Binary Tree Maximum Path Sum" -date: 2023-08-24 00:00:00 -0000 -categories: [ai, unit test, java, gpt-4] ---- - -# Binary Tree Maximum Path Sum - -
-Model: GPT-4, Temperature: 0 -# Act as an experienced Java developer. -- use Java 17 and all the features that this version has. - -## When implementing unit tests, use the following rules: -- use JUnit 5 framework with AssertJ assertions -- use `assertThat` instead of `assertEquals` or `assertTrue` -- add messages for assertions -- generate self-documenting, best-practice, parameterized, readable test code -- when using parameterized tests, always customize display names -- proactively use techniques such as Edge Coverage, Branch Coverage, Condition Coverage, Multiple Condition coverage, Path coverage, and State coverage -- use `@DisplayName` annotation to provide a display name for the test class or test method -- the test class name must end with the suffix `C4Test` -- inside test methods, use `var` keyword instead of the fully qualified type name -- the test class should be in the same package as the tested code. - -## When you use @CsvSource annotation in tests follow these rules: -- use `delimiter` = '|' -- use `textBlock` -- use default quote character: a single quote (') -- align delimiters inside text block to improve readability. Example: -```java -@DisplayName("Calculates the sum of:") -@ParameterizedTest(name = "[{index}] calculates the sum of {0}: ({1}, {2})") -@CsvSource(delimiter = '|', textBlock = """ - positive numbers | 10 | 6 | 16 - positive and negative | -4 | 2 | -2 - negative numbers | -6 | -100 | -106 - """) -void calculatesSum(String scenario, int a, int b, int expectedResult) { - var actual = calculator.sum(a, b); - assertThat(actual) - .as("The sum of %d and %d should be %d", a, b, expectedResult) - .isEqualTo(expectedResult); - } -``` - -## When I ask you to implement a test, follow these rules: -- If there is a class unknown to you, ask me for a description of this class before you proceed. -- analyze the provided code and suggest test cases before generating the test code -- wait for confirmation that these test cases are good -- once I have confirmed the test cases are satisfactory, please generate the test code. - -Problem statement: """"{task}"""" -Method signature: """"{code}"""" - -Your task is to generate unit tests based on the method signature and task description. -Please do not respond until both variables have been set. -
- -___ - -πŸ‘€ Hello! - -πŸ€– Hello! How can I help you today? Are you looking for assistance with Java development or testing? Please provide me with the task description and method signature so I can assist you better. - -πŸ‘€ -```plain -A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once. Note that the path does not need to pass through the root. - -The path sum of a path is the sum of the node's values in the path. - -Given the root of a binary tree, return the maximum path sum of any non-empty path. - -Example 1: - -Input: root = [1,2,3] -Output: 6 -Explanation: The optimal path is 2 -> 1 -> 3 with a path sum of 2 + 1 + 3 = 6. - -Example 2: - -Input: root = [-10,9,20,null,null,15,7] -Output: 42 -Explanation: The optimal path is 15 -> 20 -> 7 with a path sum of 15 + 20 + 7 = 42. -``` - -πŸ€– Thank you for providing the problem statement. To generate unit tests for this problem, I need to know the class and method signature. Please provide the class name and method signature for the given problem. - -πŸ‘€ -```java -class Solution { - public int maxPathSum(TreeNode root) -``` - -πŸ€– Thank you for providing the class and method signature. Based on the problem statement and the method signature, I suggest the following test cases: - -1. Test case with a single node tree. -2. Test case with a tree containing only positive values. -3. Test case with a tree containing both positive and negative values. -4. Test case with a tree containing only negative values. -5. Test case with a tree containing zero values. - -Please confirm if these test cases are satisfactory, and I will generate the test code for you. - -πŸ‘€ please print test cases in a table format with description, input data and the expected result - -πŸ€– Here are the test cases in a table format: - -| Test Case Description | Input Data (Tree) | Expected Result | -|----------------------------------------|--------------------------------------------|-----------------| -| Single node tree | root = [1] | 1 | -| Tree with only positive values | root = [1, 2, 3] | 6 | -| Tree with positive and negative values | root = [-10, 9, 20, null, null, 15, 7] | 42 | -| Tree with only negative values | root = [-1, -2, -3, -4, -5, -6, -7] | -1 | -| Tree with zero values | root = [0, -2, 3, null, null, -1, 4] | 7 | - -Please confirm if these test cases are satisfactory, and I will generate the test code for you. - -πŸ‘€ print graph for case #3 - -πŸ€– Here is the graphical representation of the tree for test case #3: - -``` - -10 - / \ - 9 20 - / \ - 15 7 -``` - -In this tree, the optimal path is 15 -> 20 -> 7 with a path sum of 15 + 20 + 7 = 42. - -πŸ‘€ print graph for case #4 - -πŸ€– Here is the graphical representation of the tree for test case #4: - -``` - -1 - / \ - -2 -3 - / \ / \ - -4 -5 -6 -7 -``` - -In this tree, the optimal path is -1 (single node) with a path sum of -1. - -πŸ‘€ please print case #5 - -πŸ€– Here is the graphical representation of the tree for test case #5: - -``` - 0 - / \ - -2 3 - / \ - -1 4 -``` - -In this tree, the optimal path is -1 -> 3 -> 4 with a path sum of -1 + 3 + 4 = 6. - -πŸ‘€ may be the best path 3 -> 4? - -πŸ€– You are correct. I apologize for the mistake. The optimal path for test case #5 should be 3 -> 4. Here is the updated table with the correct expected result: - -| Test Case Description | Input Data (Tree) | Expected Result | -|----------------------------------------|--------------------------------------------|-----------------| -| Single node tree | root = [1] | 1 | -| Tree with only positive values | root = [1, 2, 3] | 6 | -| Tree with positive and negative values | root = [-10, 9, 20, null, null, 15, 7] | 42 | -| Tree with only negative values | root = [-1, -2, -3, -4, -5, -6, -7] | -1 | -| Tree with zero values | root = [0, -2, 3, null, null, -1, 4] | 7 | - -Please confirm if these test cases are satisfactory, and I will generate the test code for you. - -πŸ‘€ add one case with more nodes - -πŸ€– I have added an additional test case with more nodes: - -| Test Case Description | Input Data (Tree) | Expected Result | -|----------------------------------------|--------------------------------------------|-----------------| -| Single node tree | root = [1] | 1 | -| Tree with only positive values | root = [1, 2, 3] | 6 | -| Tree with positive and negative values | root = [-10, 9, 20, null, null, 15, 7] | 42 | -| Tree with only negative values | root = [-1, -2, -3, -4, -5, -6, -7] | -1 | -| Tree with zero values | root = [0, -2, 3, null, null, -1, 4] | 7 | -| Larger tree with mixed values | root = [5, 4, 8, 11, null, 13, 4, 7, 2, null, null, 5, 1] | 48 | - -Here is the graphical representation of the tree for the new test case: - -``` - 5 - / \ - 4 8 - / / \ - 11 13 4 - / \ / \ - 7 2 5 1 -``` - -In this tree, the optimal path is 7 -> 11 -> 4 -> 5 -> 8 -> 13 with a path sum of 7 + 11 + 4 + 5 + 8 + 13 = 48. - -Please confirm if these test cases are satisfactory, and I will generate the test code for you. - -πŸ‘€ the test cases are fine. I would like to discuss what is better - parameterised tests or ordinary tests - -πŸ€– Both parameterized tests and ordinary tests have their advantages and use cases. Let's discuss the benefits and drawbacks of each approach: - -Parameterized tests: -1. Advantages: - - They allow you to run the same test multiple times with different input values, which can help reduce code duplication. - - They can make your test suite more concise and easier to maintain. - - They can help you cover a wide range of input values and edge cases with a single test method. - -2. Disadvantages: - - They can be harder to read and understand, especially if there are many input parameters or complex data structures. - - Debugging can be more challenging since you need to identify which specific input values caused the test to fail. - - They may not be suitable for all scenarios, especially if the test logic varies significantly between different input values. - -Ordinary tests: -1. Advantages: - - They are straightforward to write, read, and understand. - - Debugging is generally easier since each test method is independent and focused on a specific scenario. - - They can be more flexible, allowing you to write custom test logic for each scenario. - -2. Disadvantages: - - They can lead to code duplication if you need to test the same functionality with multiple input values. - - They can make your test suite longer and harder to maintain if you have many similar test methods. - -In summary, parameterized tests are a great choice when you need to test the same functionality with multiple input values, and the test logic is consistent across those values. Ordinary tests are better suited for scenarios where the test logic varies significantly between different input values or when the test cases are easier to understand and maintain as separate methods. - -For the given problem, since we have multiple test cases with different input trees and expected results, using parameterized tests would be a good choice to reduce code duplication and make the test suite more concise. However, if you prefer ordinary tests, I can generate the test code accordingly. Please let me know your preference. - -πŸ‘€ let's try parameterised tests - -πŸ€– Great! Here's the test code using parameterized tests for the `Solution` class and `maxPathSum` method: - -```java -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.stream.Stream; - -class SolutionC4Test { - - static Stream maxPathSumTestCases() { - TreeNode tree1 = new TreeNode(1); - - TreeNode tree2 = new TreeNode(1, new TreeNode(2), new TreeNode(3)); - - TreeNode tree3 = new TreeNode(-10, new TreeNode(9), new TreeNode(20, new TreeNode(15), new TreeNode(7))); - - TreeNode tree4 = new TreeNode(-1, new TreeNode(-2, new TreeNode(-4), new TreeNode(-5)), new TreeNode(-3, new TreeNode(-6), new TreeNode(-7))); - - TreeNode tree5 = new TreeNode(0, new TreeNode(-2), new TreeNode(3, new TreeNode(-1), new TreeNode(4))); - - TreeNode tree6 = new TreeNode(5, new TreeNode(4, new TreeNode(11, new TreeNode(7), new TreeNode(2)), null), new TreeNode(8, new TreeNode(13), new TreeNode(4, new TreeNode(5), new TreeNode(1)))); - - return Stream.of( - Arguments.of(tree1, 1), - Arguments.of(tree2, 6), - Arguments.of(tree3, 42), - Arguments.of(tree4, -1), - Arguments.of(tree5, 7), - Arguments.of(tree6, 48) - ); - } - - @DisplayName("Max Path Sum:") - @ParameterizedTest(name = "[{index}] tree: {0}, max path sum: {1}") - @MethodSource("maxPathSumTestCases") - void maxPathSum(TreeNode root, int expectedResult) { - Solution solution = new Solution(); - int actualResult = solution.maxPathSum(root); - - assertThat(actualResult) - .as("The max path sum of the tree should be %d", expectedResult) - .isEqualTo(expectedResult); - } -} -``` - -This test code uses JUnit 5 with AssertJ assertions and parameterized tests. The `maxPathSumTestCases` method provides the input trees and expected results for each test case. The `maxPathSum` test method takes these inputs and runs the `Solution.maxPathSum` method, asserting that the actual result matches the expected result. - -Please let me know if you have any questions or need further assistance. - -πŸ‘€ Please add test case descriptions - -πŸ€– I have added test case descriptions to the `maxPathSumTestCases` method. Here's the updated test code: - -```java -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.stream.Stream; - -class SolutionC4Test { - - static Stream maxPathSumTestCases() { - TreeNode tree1 = new TreeNode(1); - - TreeNode tree2 = new TreeNode(1, new TreeNode(2), new TreeNode(3)); - - TreeNode tree3 = new TreeNode(-10, new TreeNode(9), new TreeNode(20, new TreeNode(15), new TreeNode(7))); - - TreeNode tree4 = new TreeNode(-1, new TreeNode(-2, new TreeNode(-4), new TreeNode(-5)), new TreeNode(-3, new TreeNode(-6), new TreeNode(-7))); - - TreeNode tree5 = new TreeNode(0, new TreeNode(-2), new TreeNode(3, new TreeNode(-1), new TreeNode(4))); - - TreeNode tree6 = new TreeNode(5, new TreeNode(4, new TreeNode(11, new TreeNode(7), new TreeNode(2)), null), new TreeNode(8, new TreeNode(13), new TreeNode(4, new TreeNode(5), new TreeNode(1)))); - - return Stream.of( - Arguments.of(tree1, 1, "Single node tree"), - Arguments.of(tree2, 6, "Tree with only positive values"), - Arguments.of(tree3, 42, "Tree with positive and negative values"), - Arguments.of(tree4, -1, "Tree with only negative values"), - Arguments.of(tree5, 7, "Tree with zero values"), - Arguments.of(tree6, 48, "Larger tree with mixed values") - ); - } - - @DisplayName("Max Path Sum:") - @ParameterizedTest(name = "[{index}] {2}: tree: {0}, max path sum: {1}") - @MethodSource("maxPathSumTestCases") - void maxPathSum(TreeNode root, int expectedResult, String description) { - Solution solution = new Solution(); - int actualResult = solution.maxPathSum(root); - - assertThat(actualResult) - .as("The max path sum of the tree should be %d", expectedResult) - .isEqualTo(expectedResult); - } -} -``` - -Now, the `maxPathSumTestCases` method includes a description for each test case, and the `maxPathSum` test method displays the description in the test name. This makes the test output more informative and easier to understand. - -Please let me know if you have any questions or need further assistance. - -πŸ‘€ Could you please review the test that was created to ensure that it meets the initial requirements that I specified? - -πŸ€– I apologize for the oversight in my previous response. I noticed that I didn't follow the initial requirements you specified for the `@CsvSource` annotation. I will now update the test code to meet those requirements. - -Here's the updated test code using the `@CsvSource` annotation with the specified requirements: - -```java -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; -import static org.assertj.core.api.Assertions.assertThat; - -class SolutionC4Test { - - @DisplayName("Max Path Sum:") - @ParameterizedTest(name = "[{index}] {0}: tree: {1}, max path sum: {2}") - @CsvSource(delimiter = '|', textBlock = """ - Single node tree | 1 - Tree with only positive values | 6 - Tree with positive and negative values | 42 - Tree with only negative values | -1 - Tree with zero values | 7 - Larger tree with mixed values | 48 - """) - void maxPathSum(String description, String treeStr, int expectedResult) { - TreeNode root = TreeNode.fromString(treeStr); - Solution solution = new Solution(); - int actualResult = solution.maxPathSum(root); - - assertThat(actualResult) - .as("The max path sum of the tree should be %d", expectedResult) - .isEqualTo(expectedResult); - } -} -``` - -In this updated test code, I have replaced the `@MethodSource` annotation with the `@CsvSource` annotation, as per your initial requirements. The `@CsvSource` annotation now uses the specified delimiter `|` and a text block for the input data. The test method `maxPathSum` takes the tree as a string and converts it to a `TreeNode` object using a custom `fromString` method (not shown here). - -Please note that this approach requires a custom method to convert the string representation of the tree to a `TreeNode` object. If you need help implementing this method, please let me know. - -I hope this updated test code meets your initial requirements. If you have any questions or need further assistance, please don't hesitate to ask. - -πŸ‘€ The first variant was much better. Please return to it, but ensure that you use `var` - -πŸ€– I apologize for the confusion. I have reverted to the first variant using `@MethodSource` and updated the test code to use the `var` keyword as per your request: - -```java -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.stream.Stream; - -class SolutionC4Test { - - static Stream maxPathSumTestCases() { - var tree1 = new TreeNode(1); - - var tree2 = new TreeNode(1, new TreeNode(2), new TreeNode(3)); - - var tree3 = new TreeNode(-10, new TreeNode(9), new TreeNode(20, new TreeNode(15), new TreeNode(7))); - - var tree4 = new TreeNode(-1, new TreeNode(-2, new TreeNode(-4), new TreeNode(-5)), new TreeNode(-3, new TreeNode(-6), new TreeNode(-7))); - - var tree5 = new TreeNode(0, new TreeNode(-2), new TreeNode(3, new TreeNode(-1), new TreeNode(4))); - - var tree6 = new TreeNode(5, new TreeNode(4, new TreeNode(11, new TreeNode(7), new TreeNode(2)), null), new TreeNode(8, new TreeNode(13), new TreeNode(4, new TreeNode(5), new TreeNode(1)))); - - return Stream.of( - Arguments.of(tree1, 1, "Single node tree"), - Arguments.of(tree2, 6, "Tree with only positive values"), - Arguments.of(tree3, 42, "Tree with positive and negative values"), - Arguments.of(tree4, -1, "Tree with only negative values"), - Arguments.of(tree5, 7, "Tree with zero values"), - Arguments.of(tree6, 48, "Larger tree with mixed values") - ); - } - - @DisplayName("Max Path Sum:") - @ParameterizedTest(name = "[{index}] {2}: tree: {0}, max path sum: {1}") - @MethodSource("maxPathSumTestCases") - void maxPathSum(TreeNode root, int expectedResult, String description) { - var solution = new Solution(); - var actualResult = solution.maxPathSum(root); - - assertThat(actualResult) - .as("The max path sum of the tree should be %d", expectedResult) - .isEqualTo(expectedResult); - } -} -``` - -Now, the test code uses the `var` keyword for local variables in the `maxPathSumTestCases` method and the `maxPathSum` test method. - -Please let me know if you have any questions or need further assistance. - -πŸ‘€ Could you print the custom `fromString` method that you mentioned before? - -πŸ€– Certainly! Here's a possible implementation of the `fromString` method for the `TreeNode` class. This method assumes that the input string represents a tree in level-order traversal, with nodes separated by commas and null nodes represented by the string "null". - -```java -import java.util.LinkedList; -import java.util.Queue; - -public class TreeNode { - int val; - TreeNode left; - TreeNode right; - - TreeNode() {} - - TreeNode(int val) { this.val = val; } - - TreeNode(int val, TreeNode left, TreeNode right) { - this.val = val; - this.left = left; - this.right = right; - } - - public static TreeNode fromString(String treeStr) { - if (treeStr == null || treeStr.isEmpty()) { - return null; - } - - String[] nodes = treeStr.split(","); - TreeNode root = new TreeNode(Integer.parseInt(nodes[0].trim())); - Queue queue = new LinkedList<>(); - queue.offer(root); - - for (int i = 1; i < nodes.length; i += 2) { - TreeNode current = queue.poll(); - - String leftNode = nodes[i].trim(); - if (!leftNode.equals("null")) { - current.left = new TreeNode(Integer.parseInt(leftNode)); - queue.offer(current.left); - } - - if (i + 1 < nodes.length) { - String rightNode = nodes[i + 1].trim(); - if (!rightNode.equals("null")) { - current.right = new TreeNode(Integer.parseInt(rightNode)); - queue.offer(current.right); - } - } - } - - return root; - } -} -``` - -This `fromString` method uses a queue to perform a level-order traversal of the tree, constructing the `TreeNode` objects as it goes. It handles null nodes and creates the tree structure accordingly. - -Please note that this implementation assumes a valid input string. You may need to add error handling and validation checks depending on your specific use case. - -Let me know if you have any questions or need further assistance. - -πŸ‘€ Do you think using a similar method with `@CsvSource` for our case is justified instead of the `@MethodSource`? - -πŸ€– Using a `fromString` method with `@CsvSource` can be justified in certain situations, but it has some trade-offs compared to using `@MethodSource`. Here are some points to consider: - -Advantages of using `fromString` with `@CsvSource`: -1. The test cases are more compact and easier to read in the `@CsvSource` text block. -2. It can be more convenient to represent trees as strings when writing test cases. - -Disadvantages of using `fromString` with `@CsvSource`: -1. The string representation of the tree may not be as clear and intuitive as the `TreeNode` constructor calls used in `@MethodSource`. -2. The `fromString` method assumes a valid input string and may require additional error handling and validation checks. -3. Debugging test cases can be more challenging since you need to convert the string representation back to the tree structure to understand the test case. - -In the case of the `maxPathSum` test, using `@MethodSource` with explicit `TreeNode` constructor calls provides a clearer representation of the tree structure and makes it easier to understand the test cases. However, if you prefer a more compact representation of the test cases and are willing to handle the trade-offs mentioned above, using `fromString` with `@CsvSource` can be a viable option. - -In summary, both approaches have their pros and cons, and the choice depends on your specific requirements and preferences. If you would like to see the test code using `fromString` with `@CsvSource`, please let me know, and I will provide it for you. - -πŸ‘€ Thanks for the clarification. Let's leave it at that, great job. - -πŸ€– You're welcome! I'm glad I could help. If you have any more questions or need further assistance in the future, please don't hesitate to ask. Good luck with your project, and have a great day! diff --git a/post b/post new file mode 100644 index 0000000..17e3a93 --- /dev/null +++ b/post @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2023 Jegors Čemisovs +# License: MIT +# Repository: https://github.com/rabestro/gpt4-session-to-markdown +# +# Converts GPT-4 chat session JSON data to markdown format and +# adds YAML front matter to the top of the file to prepare it +# for publishing on the Jekyll site. +# +# Usage: +# ./post +# + +# set these variables as needed for your environment +readonly POSTS_DIR="../_posts" +readonly TIMEZONE="+0300" +readonly CATEGORIES="AI" +readonly TAGS="ai" + +create_file_name() { + jq --raw-output '.history[0].name | ascii_downcase | gsub("[^a-z0-9]+"; "-")' "$1" +} + +conversation() { + local -r file_json="$1" + cat < "$file_post" +--- +title: "$title" +date: $current_date $current_time $TIMEZONE +categories: [$CATEGORIES] +tags: [$TAGS] +mermaid: $(has_mermaid "$file_json") +--- +{% raw %} + +## The system prompt used + +$prompt + +$(conversation "$file_json") + +{% endraw %} +EOF +} + +main "$1"