-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgerar
More file actions
58 lines (47 loc) · 1.84 KB
/
Copy pathgerar
File metadata and controls
58 lines (47 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env node
/**
* Motor de roteiros MOVA
* Uso:
* node gerar.js --nicho "imobiliário" --servico "captação de vídeo" \
* --objetivo "gerar lead no direct" --qtd 5 --formato "reel falado"
*
* Requer:
* npm install @anthropic-ai/sdk
* export ANTHROPIC_API_KEY=sua_chave
*/
import fs from "node:fs";
import Anthropic from "@anthropic-ai/sdk";
// ---- lê argumentos simples --nome valor ----
const args = {};
for (let i = 2; i < process.argv.length; i += 2) {
args[process.argv[i].replace(/^--/, "")] = process.argv[i + 1];
}
const nicho = args.nicho || "geral";
const servico = args.servico || "captação de vídeo";
const objetivo = args.objetivo || "gerar lead no direct";
const qtd = args.qtd || "5";
const formato = args.formato || "reel falado";
// ---- carrega contexto + motor ----
const contexto = fs.readFileSync("contexto-mova.md", "utf8");
const motor = fs.readFileSync("motor-roteiros.md", "utf8");
const systemPrompt = `${motor}\n\n---\n\n# contexto-mova.md\n\n${contexto}`;
const userPrompt = `Gere os roteiros com estas entradas:
- nicho: ${nicho}
- serviço em foco: ${servico}
- objetivo: ${objetivo}
- quantidade: ${qtd}
- formato: ${formato}`;
const client = new Anthropic(); // usa ANTHROPIC_API_KEY do ambiente
const res = await client.messages.create({
model: "claude-sonnet-5", // troque por "claude-opus-4-8" se quiser mais qualidade
max_tokens: 4000,
system: systemPrompt,
messages: [{ role: "user", content: userPrompt }],
});
const texto = res.content.map((b) => (b.type === "text" ? b.text : "")).join("");
// ---- salva num arquivo datado ----
const data = new Date().toISOString().slice(0, 10);
const arquivo = `roteiros-${nicho.replace(/\s+/g, "-")}-${data}.md`;
fs.writeFileSync(arquivo, texto, "utf8");
console.log(`\n✅ ${qtd} roteiros gerados em: ${arquivo}\n`);
console.log(texto);