Tool
var corsHeaders = { "Access-Control-Allow-Origin": "*",//这里控制哪些网站能访问 "Access-Control-Allow-Methods": "POST, OPTIONS, GET", "Access-Control-Allow-Headers": "Content-Type, Authorization" }; var src_default = { async fetch(request, env) { if (request.method === "OPTIONS") { return new Response(null, { headers: corsHeaders }); } const { pathname } = new URL(request.url); const content= decodeURI(pathname.substring(1)) //输入地址栏中的长文字 const prompt = `请总结以下内容,用30字以内的中文表达:\n\n${content},请只回答总结的内容, 不要说其他`; const inputs = { prompt }; const response = await env.AI.run("@cf/meta/llama-3-8b-instruct", inputs);//ai把长文字变成简短的摘要 const txt = new Response(JSON.stringify(response), { headers: { "Content-Type": "application/json", ...corsHeaders } }); const txt2= await txt.json(); const onlytxt = txt2.response; return new Response(` <html> <head> <meta charset="utf-8"> <style> .typing { width: 100em; height: 1.25em; border-right: 1px solid transparent; animation: typing 3.5s steps(200, end); font-family: Consolas, Monaco; word-break: break-all; overflow: hidden; } /* 打印效果 */ @keyframes typing { from { width: 0; } to { width: 100em; } } </style> </head> <body style="background-color:transparent; color:white;"> <p class="typing"> ${onlytxt} </p> </body> </html> `, { headers: { "Content-Type": "text/html", ...corsHeaders } }); } }; export { src_default as default };
<iframe src=`https://aislug.51xmi.com/${postsummary}` />