Forum in maintenance, we will back soon 🙂
Create Viral Content With this Automated System
Hi Hasan,
Thank you for the tutorials, I am learning a lot. I do have a problem with this download: https://us1.make.com/apps/invite/63e61131a4e45809cd5bd864943f4807/accept
It will not allow me to check my name to activate the install button.
Please advise
Christopher
@google-collmandigitalmarketingagency I cannot either. Hmm... this may be a bug with Make but let @Hasan check his app first.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
Thanks, I am looking forward to the solution.
@ssadvisor @google-collmandigitalmarketingagency The problem is from Make's side, we contacted the support and waiting for them to solve it. We'll let you know once the problem is solved.
please use the updated link to install the App, it must work now
Thank you, Hasan. You are the best 😊 . I just completed the Integrated Google Sheet. It's working like a charm.
I am working on building my tools and using Perplexity For the YouTube title generator, but I am having problems with the endpoint. https://www.collmandigitalmarketing.com/my-new-ai-tools/
I am practicing with ChatGPT every day. What is the best plugin to use for a WordPress community?
The first sale I get I am buying lifetime access for $800.
Christopher
@google-collmandigitalmarketingagency What exactly is the problem you're having?
I don't know how to configure the endpoint, the code is already in place.
Integrating the API Key and Endpoint:
Once you have the API key and endpoint, you’ll update the backend PHP code like this:
$apiKey = 'YOUR_ACTUAL_API_KEY'; // Replace with your actual API key
curl_setopt($ch, CURLOPT_URL, 'https://api.perplexity.ai/YOUR_ENDPOINT'); // Replace with the actual endpoint
- YOUR_ACTUAL_API_KEY: Replace
'YOUR_ACTUAL_API_KEY'
with the key you obtained. - YOUR_ENDPOINT: Replace
'https://api.perplexity.ai/YOUR_ENDPOINT'
with the correct API endpoint URL provided by Perplexity.
The UI image is
but the PHP had an error:
// Unique API Key Setter function setUniqueApiKey() { return "xxxxxxxxxxxxxxxx"; // Replace with your Perplexity API key } // Unique Prompt Setter function generateUniquePrompt($input) { return "Generate 5 catchy YouTube titles for a video about " . $input; } // Define a Unique "Model" function createUniqueTitlesModel($titles) { return ["titles" => $titles]; } // Helper JSON Functions with Unique Names function modelToJsonUnique($modelInstance) { return json_encode($modelInstance); } function extractJsonUnique($textResponse) { $pattern = '/{[^{}]*}/'; preg_match_all($pattern, $matches); $jsonObjects = []; foreach ($matches[0] as $jsonStr) { try { $jsonObj = json_decode($jsonStr, true, 512, JSON_THROW_ON_ERROR); array_push($jsonObjects, $jsonObj); } catch (JsonException $e) { $extendedJsonStr = extendSearchUnique($textResponse, $jsonStr); try { $jsonObj = json_decode($extendedJsonStr, true, 512, JSON_THROW_ON_ERROR); array_push($jsonObjects, $jsonObj); } catch (JsonException $e) { continue; } } } return !empty($jsonObjects) ? $jsonObjects : null; } function extendSearchUnique($text, $jsonStr) { $start = strpos($text, $jsonStr); $end = $start + strlen($jsonStr); $nestCount = 0; for ($i = $start; $i < strlen($text); $i++) { if ($text[$i] === '{') { $nestCount++; } elseif ($text[$i] === '}') { $nestCount--; if ($nestCount === 0) { return substr($text, $start, $i - $start + 1); } } } return substr($text, $start, $end - $start); } function jsonToModelUnique($modelClass, $jsonData) { try { return $modelClass($jsonData); } catch (Exception $e) { echo "Validation error: " . $e->getMessage(); return null; } } function validateJsonWithUniqueModel($modelClass, $jsonData) { $validatedData = []; $validationErrors = []; if (is_array($jsonData)) { foreach ($jsonData as $item) { try { $modelInstance = $modelClass($item); array_push($validatedData, $modelInstance); } catch (Exception $e) { array_push($validationErrors, ["error" => $e->getMessage(), "data" => $item]); } } } elseif (is_assoc_unique($jsonData)) { try { $modelInstance = $modelClass($jsonData); array_push($validatedData, $modelInstance); } catch (Exception $e) { array_push($validationErrors, ["error" => $e->getMessage(), "data" => $jsonData]); } } else { throw new ValueError("Invalid JSON data type. Expected associative array or array."); } return [$validatedData, $validationErrors]; } function is_assoc_unique(array $arr) { if (array() === $arr) return false; return array_keys($arr) !== range(0, count($arr) - 1); } // Perplexity API Interaction with Unique Naming function generateResponseWithPerplexityUnique($prompt) { $api_key = "xxxxxxxxxxxxxxxxxxxxxxx"(); $api_url = 'https://api.perplexity.ai/v1/query; // Perplexity API endpoint // Headers for the Perplexity API $headers = [ 'Authorization' => 'Bearer ' . $api_key, 'Content-Type' => 'application/json' ]; // Body for the Perplexity API $body = [ 'prompt' => $prompt, 'max_tokens' => 150 // Adjust this based on your needs ]; // Args for the WordPress HTTP API $args = [ 'method' => 'POST', 'headers' => $headers, 'body' => json_encode($body), 'timeout' => 120 ]; // Send the request $response = wp_remote_request($api_url, $args); // Extract the body from the response $responseBody = wp_remote_retrieve_body($response); // Decode the JSON response body $decoded = json_decode($responseBody, true); // Extract the text if (isset($decoded['choices'][0]['text'])) { $extractedText = $decoded['choices'][0]['text']; return $extractedText; } else { return 'Text not found in response'; } } // Main AJAX Handler with Unique Naming function customToolRunUnique() { // Add CORS headers header('Access-Control-Allow-Origin: *'); // Allows all origins header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); // Specifies the allowed methods header('Access-Control-Allow-Headers: Content-Type, Authorization'); // Specifies the allowed headers // Variables $input = $_POST['input']; $basePrompt = generateUniquePrompt($input); // Creating an instance of your model $titlesModel = createUniqueTitlesModel(['title1', 'title2']); // Convert model instance to JSON $jsonModel = modelToJsonUnique($titlesModel); // Create optimized prompt $optimizedPrompt = $basePrompt . ". Please provide a response in a structured JSON format that matches the following model: " . $jsonModel; // Generate content using the modified prompt $perplexityResponse = generateResponseWithPerplexityUnique($optimizedPrompt); // Extract and validate the JSON from the response $jsonObjects = extractJsonUnique($perplexityResponse); wp_send_json_success($jsonObjects); // Always die in functions echoing AJAX content wp_die(); } add_action('wp_ajax_custom_tool_run_unique', 'customToolRunUnique'); add_action('wp_ajax_nopriv_custom_tool_run_unique', 'customToolRunUnique');
@google-collmandigitalmarketingagency Is this code ChatGPT generated?
The AJAX add_action in the end of the code is calling for a custom_tool_run_unique, however in this code you don't have a function with this name, so it wont work.
Or you have this function in another code snippet? if you do please share that PHP code too.
Yes, ChatGPT generated it Your original PHP works well -AI Blog post generator. If you can modify this to use perplexity that would be great. I tried this by just changing the prompt but it gave me a saying that it is already in use. Also I am getting this error with
Intensive Topic Research with AI and Recursive LLM Calls
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8505
Network URL: http://192.168.0.53:8505
2024-08-24 04:14:18.270 Uncaught app exception
Traceback (most recent call last):
File "/Applications/Python 3.12/Downloads/Make Automation/MakeAutomations/Hasan Automation/Keyword-Research-Graph-main 2/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 85, in exec_func_with_error_handling
result = func()
^^^^^^
File "/Applications/Python 3.12/Downloads/Make Automation/MakeAutomations/Hasan Automation/Keyword-Research-Graph-main 2/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 576, in code_to_exec
exec(code, module.__dict__)
// Your Inputs function setApiKey() { return "xxxxxxx"; } function setPrompt($input) { return "Generate 5 catchy blog titles for a blog post about " . $input; } // Define your "model" as an associative array function createTitlesModel($titles) { return ["titles" => $titles]; } // Helper JSON Functions function modelToJson($modelInstance) { return json_encode($modelInstance); } function extractJson($textResponse) { $pattern = '/{[^{}]*}/'; preg_match_all($pattern, $textResponse, $matches); $jsonObjects = []; foreach ($matches[0] as $jsonStr) { try { $jsonObj = json_decode($jsonStr, true, 512, JSON_THROW_ON_ERROR); array_push($jsonObjects, $jsonObj); } catch (JsonException $e) { // Extend the search for nested structures $extendedJsonStr = extendSearch($textResponse, $jsonStr); try { $jsonObj = json_decode($extendedJsonStr, true, 512, JSON_THROW_ON_ERROR); array_push($jsonObjects, $jsonObj); } catch (JsonException $e) { // Handle cases where the extraction is not valid JSON continue; } } } return !empty($jsonObjects) ? $jsonObjects : null; } function extendSearch($text, $jsonStr) { // Extend the search to try to capture nested structures $start = strpos($text, $jsonStr); $end = $start + strlen($jsonStr); $nestCount = 0; for ($i = $start; $i < strlen($text); $i++) { if ($text[$i] === '{') { $nestCount++; } elseif ($text[$i] === '}') { $nestCount--; if ($nestCount === 0) { return substr($text, $start, $i - $start + 1); } } } return substr($text, $start, $end - $start); } function jsonToModel($modelClass, $jsonData) { try { return $modelClass($jsonData); } catch (Exception $e) { echo "Validation error: " . $e->getMessage(); return null; } } function validateJsonWithModel($modelClass, $jsonData) { $validatedData = []; $validationErrors = []; if (is_array($jsonData)) { foreach ($jsonData as $item) { try { $modelInstance = $modelClass($item); array_push($validatedData, $modelInstance); } catch (Exception $e) { array_push($validationErrors, ["error" => $e->getMessage(), "data" => $item]); } } } elseif (is_assoc($jsonData)) { try { $modelInstance = $modelClass($jsonData); array_push($validatedData, $modelInstance); } catch (Exception $e) { array_push($validationErrors, ["error" => $e->getMessage(), "data" => $jsonData]); } } else { throw new ValueError("Invalid JSON data type. Expected associative array or array."); } return [$validatedData, $validationErrors]; } function is_assoc(array $arr) { if (array() === $arr) return false; return array_keys($arr) !== range(0, count($arr) - 1); } function generate_response_with_gemini($prompt) { $api_key = setApiKey(); $api_url = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=' . $api_key ; // Headers for the Gemini API $headers = [ 'Content-Type' => 'application/json' ]; // Body for the Gemini API $body = [ 'contents' => [ [ 'parts' => [ ['text' => $prompt] ] ] ] ]; // Args for the WordPress HTTP API $args = [ 'method' => 'POST', 'headers' => $headers, 'body' => json_encode($body), 'timeout' => 120 ]; // Send the request $response = wp_remote_request($api_url, $args); // Extract the body from the response $responseBody = wp_remote_retrieve_body($response); // Decode the JSON response body $decoded = json_decode($responseBody, true); // Extract the text if (isset($decoded['candidates'][0]['content']['parts'][0]['text'])) { $extractedText = $decoded['candidates'][0]['content']['parts'][0]['text']; return $extractedText; } else { return 'Text not found in response'; } } function custom_tool_run() { // Add CORS headers header('Access-Control-Allow-Origin: *'); // Allows all origins header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); // Specifies the allowed methods header('Access-Control-Allow-Headers: Content-Type, Authorization'); // Specifies the allowed headers // Variables $input = $_POST['input']; $basePrompt = setPrompt($input); // Creating an instance of your model $titlesModel = createTitlesModel(['title1', 'title2']); // Convert model instance to JSON $jsonModel = modelToJson($titlesModel); // Create optimized prompt $optimizedPrompt = $basePrompt . ". Please provide a response in a structured JSON format that matches the following model: " . $jsonModel; // Generate content using the modified prompt $gemeniResponse = generate_response_with_gemini($optimizedPrompt); // Extract and validate the JSON from the response $jsonObjects = extractJson($gemeniResponse); wp_send_json_success($jsonObjects); // Always die in functions echoing AJAX content wp_die(); } add_action('wp_ajax_custom_tool_run', 'custom_tool_run'); add_action('wp_ajax_nopriv_custom_tool_run', 'custom_tool_run');
@google-collmandigitalmarketingagency There's a problem with the PHP code that ChatGPT generated that's why you're getting errors; why are you using perplexity? If you're looking for a free API for now, you can use Gemini.
Here's a PHP code snippet to use Gemini; edit it a bit so that it fits your tool and it'll work fine.
It works like a charm 😊 . Any info on the Intensive Topic Research with AI Recursive LLM calls?
Thank you. You are the best 😊
@google-collmandigitalmarketingagency
Posted by: @google-collmandigitalmarketingagencyAny info on the Intensive Topic Research with AI Recursive LLM calls?
What info?
this is not working. Also, your module is not showing the content of the video when I run it the way you did in the video.
Create Viral Content With this Automated System
I
@google-collmandigitalmarketingagency please post one problem at a time, for the streamlit app, you need to install the requirements.
for Make, try other URLs, or blogs , and check if it works
Hi, Hasan and team, this is Deborah again, I'm having an issue with all the apps.
So, I'm working on the internal linking. Watching the video, Hasan downloaded a file.
I don't see the file, the downloads are x out and it looks like you want us to use the
HTML code instead.
I'm wondering if it's my website or if this is the case. Most of the downloads are the same way x out etc...
Being that there isn't a file, when I have to edit the process is that correct? Or am I missing Everything?
Please help!
Deborah
@google-deborahpretty Most codes are available attached in a code snippet where you can copy and paste it in your IDE, so scroll a bit up to find the Python code snippet you need.
@google-deborahpretty Plus, make sure you enter your questions in a new thread if you don't find a thread with your topic. For example, this thread is about the viral content generator, not the semantic interlinking tool. So please for next time, enter your questions in threads with the same topic or I'll have to delete them.
Hi Hasan and team, thank you very much for all the content and support.
When I installed the Create Viral Content blueprint, you invited us to install the Extract Web Content, at first it worked fine, but since some time ago it doesn't work.
I have tried to reinstall it from the link you shared with us, but it doesn't work either.