Skip to content

Forum in maintenance, we will back soon 🙂

Story Generator
 
Notifications
Clear all

Story Generator

16 Posts
4 Users
5 Reactions
157 Views
(@azplaz2)
Posts: 14
Eminent Member
Topic starter
 

I am so excited by what Hasan has done for us - amazing. I did the Story Generator and decided to customize it. I got it so it now writes in various lengths(though i cannot figure out how it went from writing 3 sentences to 3 words??? Anyway, I wanted to be able to post the results to one or more post categories and/or get a shortcode. I have tried and tried using chatgpt and I cannot figure it out, any ideas??? https://savebobandcarol.com/tools-you-can-use/

This topic was modified 7 months ago by Robert
 
Posted : 04/29/2024 12:53 pm
(@husein)
Posts: 529
Member Moderator
 

@azplaz2 Hello,as it seems the tool is based on a dynamic prompt, please show us the prompt you're using for when the user picks 3 sentence story, the problem would be that the prompt is "write a 3 word story"

 
Posted : 04/29/2024 6:48 pm
Hasan Aboul Hasan
(@admin)
Posts: 1252
Member Admin
 

Thanks, what do you mean by "post the results to one or more post categories and/or get a shortcode"

for the 3 word problem, it is probably a prompt issue or maybe you are cutting words in someway in your code.

 
Posted : 04/30/2024 8:14 am
(@azplaz2)
Posts: 14
Eminent Member
Topic starter
 

When the story is generated - I want it to automatically be posted to my blog in a category I choose, but I cannot figure out how to do it. I would also like to be able to post it anywhere else using shortcode...

 
Posted : 04/30/2024 11:26 am
(@azplaz2)
Posts: 14
Eminent Member
Topic starter
 

@husein here is my script - I apologize I do not know how to add just the parts you named(prompts) all this is so new to me - you folks are awesome) <script>
document.addEventListener("DOMContentLoaded", function() {
const generateButton = document.getElementById("generate-button");
const loadingIndicator = document.getElementById("loading");
const resultTextarea = document.getElementById("result");
const resultContainer = document.getElementById("result-container");
const copyButton = document.getElementById("copy-button");

generateButton.addEventListener("click", function(e) {
e.preventDefault();
if (generateButton.disabled) return;
generateButton.disabled = true;

const topic = document.getElementById("topic").value;
const storyLength = document.getElementById("story-length").value;
const categories = Array.from(document.querySelectorAll('input[name="categories"]:checked')).map(elt => elt.value);
const prompt = `Generate a ${storyLength} word story about ${topic}`;

loadingIndicator.style.display = 'block';
resultTextarea.style.display = 'none';
resultContainer.style.display = 'none';

const formData = new FormData();
formData.append('action', 'openai_generate_text');
formData.append('prompt', prompt);
formData.append('categories', JSON.stringify(categories));

fetch('/wp-admin/admin-ajax.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
loadingIndicator.style.display = 'none';
if (data.success) {
resultTextarea.value = data.data.choices[0].message.content;
resultTextarea.style.display = 'block';
resultContainer.style.display = 'block';
} else {
resultTextarea.value = `An error occurred: ${data.data}`;
resultTextarea.style.display = 'block';
resultContainer.style.display = 'block';
}
generateButton.disabled = false;
})
.catch(error => {
loadingIndicator.style.display = 'none';
resultTextarea.value = `An error occurred: ${error.message}`;
resultTextarea.style.display = 'block';
resultContainer.style.display = 'block';
generateButton.disabled = false;
});
});

copyButton.addEventListener("click", function() {
navigator.clipboard.writeText(resultTextarea.value)
.then(() => alert('Copied to clipboard!'))
.catch(err => console.error('Could not copy text: ', err));
});
});
</script>

 
Posted : 04/30/2024 11:36 am
(@husein)
Posts: 529
Member Moderator
 

@azplaz2 no that's not what i meant. It seems there's a problem with the prompt you're using so I need to check the prompt ur using to help you.

 
Posted : 04/30/2024 2:07 pm
(@azplaz2)
Posts: 14
Eminent Member
Topic starter
 

@husein I apologize. I gues I don't know what you mean. I copied Hasan's code completely then I added the following to customise it (I did not put in prompts that I know of...)and that is it - the other story lengths mostly work, they are short sometimes: <label for="story-length">Choose story length:</label>
<select id="story-length">
<option value="3">3 Sentence Story</option>
<option value="250">250 Word Story</option>
<option value="500">500 Word Story</option>
<option value="1000">1000 Word Story</option>
<option value="2000">2000 Word Story</option>
</select>
</div>

<!-- Category selection section -->
<div class="category-selection-container" style="text-align: left; margin-bottom: 20px;">
<label>Select Categories:</label><br>
<input type="checkbox" id="adventure" name="categories" value="Adventure">
<label for="adventure">Adventure</label><br>
<input type="checkbox" id="mystery" name="categories" value="Mystery">
<label for="mystery">Mystery</label><br>
<input type="checkbox" id="sci-fi" name="categories" value="Sci-Fi">
<label for="sci-fi">Sci-Fi</label><br>
<input type="checkbox" id="romance" name="categories" value="Romance">
<label for="romance">Romance</label><br>
<input type="checkbox" id="fantasy" name="categories" value="Fantasy">
<label for="fantasy">Fantasy</label>
</div>

 

 
Posted : 04/30/2024 10:22 pm
(@husein)
Posts: 529
Member Moderator
 

@azplaz2 this code is the HTML which is the design of the tool. I see you're still a beginner in this field, please tell which blog/youtube video ur implementing so I can check it and help you.

 
Posted : 05/01/2024 11:27 am
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@azplaz2 I suggest that you take a look at Hasan's courses to learn a little about programming. He even gives you the code to his website in the SaaS course but don't skip the other courses as he builds upon previous courses.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 05/01/2024 12:05 pm
(@azplaz2)
Posts: 14
Eminent Member
Topic starter
 

@ssadvisor that is what I am working on now. Thanks!

 

 
Posted : 05/01/2024 2:16 pm
(@azplaz2)
Posts: 14
Eminent Member
Topic starter
 

@husein I hope this is what you mean - https://savebobandcarol.com/tools-you-can-use/. If you put in something like peaches or movie studio it gives 3 words like Lights, camera, action. I greatly appreciate your help I am such a noob at this...until now I could never do anything in programming but you folks are so good I have done a couple things like the chatbot, I have struggled with others for so long...thank you.

 
Posted : 05/01/2024 2:20 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@azplaz2 it seems you've confused the word "sentence" for the word "words". It did a great job with a 2000 word story. I'm guessing there is a translation error for the word sentence.

However, @Husein was asking for a link to what example you are using to code your tools.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 05/01/2024 11:20 pm
(@azplaz2)
Posts: 14
Eminent Member
Topic starter
 

@ssadvisor the only sample I can provide is the exact coding Hasan did - the html, css, script - all I did was ask ChatGPT to do was add the drop down and the ability to make each part of the drop down the number of words in the output. I can pastes the entire code here if you want??

 
Posted : 05/02/2024 1:19 pm
(@azplaz2)
Posts: 14
Eminent Member
Topic starter
 

@ssadvisor OMG!!! You were right! I changed from 3 word sentence to 50 word story and it worked perfectly!!! Thank you again!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 
Posted : 05/02/2024 1:29 pm
(@husein)
Posts: 529
Member Moderator
 

@azplaz2 Learning a bit of HTML, CSS, Javascript, and Python from youtube will help you a lot in understanding the codes. Plus, it will help you explain the problem you're facing in a better way so that we can help you more effectively. I really advise you to do so!

 
Posted : 05/02/2024 7:48 pm
(@azplaz2)
Posts: 14
Eminent Member
Topic starter
 

@husein I have tried. 40 years ago I used to write html. I went to college to try to write programs like using fortran and cobal but could never figure them out. For the first time in my life I am beggining to understand a bit with what you folks taught with Python - it is the first time in my life I have ever understood programming at all - THANK you. HTML I have not done in so long, I have forgotten most and of course all the changes but I am working on it and will also start learning css and javascript or at least try. Thank you for what I have learned so far.

 
Posted : 05/03/2024 3:15 am
Share: