,

多智能体分析落地页

liangdabiao

·

,

·

落地页分析助手

案例和代码来源于: https://learnwithhasan.com/optimize-landing-pages-ai/

https://github.com/liangdabiao/AI-Marketing-Army-Tester

这里展示一下最简单的利用多个智能体来生成有用的分析结果,例子是由多个专业Agent评判来分析落地页的质量情况。最后把这个API封装成微型SaaS,给大众公开使用:

多个智能体专家:

persona_prompts_small = [
    {"Young Entrepreneur": "As a young, tech-savvy entrepreneur interested in the latest market trends and innovations, "},
    {"Freelance Graphic Designer": "As a freelance graphic designer, "},
    {"Small Business Owner": "As a small business owner of a local café, "},
    {"Professional Blogger": "As a professional blogger, "},
]

让多个智能体分析,汇总起来再分析落地页:

url = "https://learnwithhasan.com"

captured_image_path = web_screenshot.capture_web_page_image(url,"screenshot_test.jpg")
image_url = web_screenshot.upload_to_imgur(captured_image_path)

# Initialize an empty list to store all the results
all_persona_results = []

#loop through the list or personas and ask for evaluation
for persona in persona_prompts_small:
    for title, prompt in persona.items():
        print(f"Analyzing With: {title}...")
        persona_prompt = f"{prompt} {anlysis_prompt}"
        result = analyze_image_basic(image_url,persona_prompt)
        all_persona_results.append(result)
        print("Done------")

#get  the overaall results
results_string = '\n'.join(all_persona_results)
final_prompt = f"Act as a Landing Page Expert Analyzer, please checkout the following feedback from different people about a landing page, extract 7-10 unique suggestions, and return them in a list in JSON format. Feedback: {results_string}"
overall_analysis = generate_with_response_model(final_prompt,SuggestionsModel)
print(overall_analysis.result)

下面我这里展示一下,把这个微型AI应用封装在这个wordpress,变成微型SaaS给大众使用,一个小时的工作量就可以微型SaaS创业了,希望能够帮助35+程序员摆脱职业困境,提供一点儿帮助。

具体流程参考: https://saas.liangdabiao.com/archives/1482

代码参考: https://github.com/hassancs91/AI-Marketing-Army-Tester

wordpress后端调用我们写的python AI功能接口, 下面是代码:

function send_post_request_to_analyze_image($landingUrl) {
    $url = 'http://127.0.0.1:3000/analyze_image';
    $body = array(
        'image_url' => $landingUrl
    );

    $args = array(
        'body' => json_encode($body),
        'headers' => array(
            'Content-Type' => 'application/json'
        ),
        'timeout' => 130 // 增加超时时间到20秒
    );

    $response = wp_remote_post($url, $args);

    if (is_wp_error($response)) {
        $error_message = $response->get_error_message();
        wp_send_json_error("Something went wrong: $error_message");
	wp_die();
    } else {
        $body = wp_remote_retrieve_body($response);
        return $body;
    }
}

function openai_generate_landingpage() {
 
    // Get the topic from the AJAX request
    $landingUrl = $_POST['prompt'];

    $datas = send_post_request_to_analyze_image($landingUrl);
 
	
	$current_user_id = get_current_user_id();
	if ( $current_user_id ) {
    //echo 'Current User ID: ' . $current_user_id;
    mycred_subtract( 'mycred_default', $current_user_id, -1, 'SaaS使用!' );
	} else {
    //echo 'No user is currently logged in.';
	}

    // Handle the response
      
        $data = json_decode($datas, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            wp_send_json_error('Invalid JSON in API response');
        }else {
		// 我们在 成功访问的时候,增加 扣减 功能使用需要的积分
		//mycred_subtract( 'mycred_default', $user_id, -1, 'Penalty!' );
            wp_send_json_success($data);
        }

    // Always die in functions echoing AJAX content
   wp_die();
}

add_action('wp_ajax_openai_generate_landingpage', 'openai_generate_landingpage');
add_action('wp_ajax_nopriv_openai_generate_landingpage', 'openai_generate_landingpage');

哈!这样就完成一个微型SaaS的完整流程了。

我们可以利用这个方法,一个小时就出一个AI微型SaaS,快速创业快速迭代,程序员/产品经理,35岁,不要开滴滴了,不如开发微型SaaS.

效果图: