PTENES
MODULE 3.3

🧰 Problems & best practices

Almost every problem has a simple solution — and almost every good result comes from a few good habits. This final module brings together the most common errors with each one’s fix, plus best practices, the cost, and the ethics of using the tool.

7
Topics
40
Minutes
5
Common errors
🛠️
Practical
⚠️ Error 401 / 429 / module 🔎 Diagnostics what's the cause? 🔧 Fix simple and fast ✅ It works back to work Most errors follow this path: identify the cause, and the fix almost always takes a minute.

Illustrative diagram — from error to solution in four steps.

Detailed content

1

🔑 API key errors (401)

The error 401 means "unauthorized": the key is incorrect or missing. It’s the number one issue for people getting started — and it’s almost always a small oversight.

📝 What your .env should look like

# Certo — sem espaços, chave completa
PERPLEXITY_API_KEY=pplx-xxxxxxxxxxxxxxxx
GEMINI_API_KEY=AIzaSyxxxxxxxxxxxxxxxx

# Errado — espaço ou chave pela metade
PERPLEXITY_API_KEY = pplx-xxx   ← espaços!
GEMINI_API_KEY=AIzaSy           ← incompleta!

After fixing it, restart the app so it rereads the file.

✓ Check

  • ✓The .env file exists in the project folder
  • ✓Format: pplx-... and AIzaSy...
  • ✓No spaces before or after the “=”

✗ Common causes

  • ✗API key pasted only halfway
  • ✗Extra space at the beginning or end
  • ✗You forgot to save the .env

💡 Tip — restart after editing

The app only reads .env when it starts. Fixed the key? Stop and restart the app — otherwise, it keeps using the old version and the 401 persists.

2

📦 "Module not found"

This error almost always means one thing: the virtual environment (venv) is not active. Without it, Python can’t see the installed libraries.

⌨️ The fix, step by step

# 1) Ative o ambiente virtual
source venv/bin/activate        # Mac / Linux
.\venv\Scripts\activate         # Windows

# 2) (Re)instale as dependências
pip install -r requirements.txt

# 3) Rode de novo o que deu erro

On Windows, also check that Python is on the PATH (selected during installation).

🧠 Why it happens

Each new terminal opens "clean." It's easy to forget to activate the venv when you open a new window—and then Python looks for the libraries in the wrong place. Always activate it before running.

3

🔌 Port 8888 in use

Good to know: this "problem" almost never stops you. If port 8888 is already in use, the app automatically finds another available port.

⌨️ If you want to choose the port

# Deixar o app escolher (padrão)
python -m strategy_factory.webapp

# Forçar uma porta específica
python -m strategy_factory.webapp --port 9000

If the address in your browser shows a different number, the app simply found an available port — everything is working normally.

💡 Tip — it’s not a serious error

Unlike a 401 or “module not found,” a busy port is just a warning. If you see a port other than 8888, open that address and continue.

4

⏳ Rate limits (429)

The error 429 means "too many requests" — you hit the API rate limit. The good news: you don’t lose the work already done.

🔁 How to recover

1. Stop and wait — 5 to 10 minutes

2. Pick up where you left off — use the resume command

3. Ready — it reuses what’s already been generated

# Continuar de onde parou, sem refazer tudo
python -m strategy_factory.main resume "Stripe"

There’s already a delay of about 5s built in between Gemini calls, specifically to avoid 429 errors.

🧠 Why it happens

APIs limit how many requests you can make per minute. Waiting a little usually solves the problem—and the resume ensures you don’t start from scratch.

5

🖼️ Diagrams don't render

If the diagrams are generated as Blank PNG, Chrome is usually missing—it’s used by Puppeteer, which "takes the picture" of the Mermaid diagram.

✓ Solutions

  • ✓Install Google Chrome on your computer
  • ✓Run the tool via Docker
  • ✓Edit the code in document 03 and generate it again

✗ What is NOT the problem

  • ✗The API keys (the texts turned out well)
  • ✗The research or synthesis
  • ✗The document contents

💡 Tip — it’s an isolated problem

The documents may turn out perfectly while only the images fail — a problem limited to the Generation phase. Knowing the cause keeps you from thinking that "everything went wrong": just install Chrome and generate them again.

6

💡 Best practices for good results

The difference between a mediocre draft and a great one usually comes down to four simple habits. They save money and greatly improve quality.

✓ Do

  • ✓Start in quick mode (quick)
  • ✓Give it a good --context (industry, size, model)
  • ✓Run several in quick mode, then dig deeper into the one you choose
  • ✓Always review the outputs before using them

✗ Avoid

  • ✗Go straight to the in-depth analysis for everything (costs more)
  • ✗Leave the context blank
  • ✗Delivering the draft without reading it
  • ✗Trust the numbers without checking
# Bom contexto = pesquisa mais precisa
python -m strategy_factory.main run "Acme" \
  --mode quick \
  --context "fintech B2B, 200 funcionários, Brasil"

Specific context makes a huge difference for companies that aren’t well known or have ambiguous names.

💡 Tip — scan cheaply, then dig deeper with care

Run ten companies in quick mode (pennies each) and spend on the in-depth analysis only for the one that really matters. It's the tool's best value.

7

⚖️ Cost & ethics

Use the tool with responsibility protects you and the company. Three principles and a simple way to track spending.

🌐

Uses public data

The research is based on public information—not confidential company data. Don’t paste internal secrets into the context.

✍️

It’s a draft, not the final truth

The result needs human review. Treat it as a quality starting point — not the final word.

⚖️

Not legal or financial advice

The recommendations are no substitute for an expert. For serious legal or financial decisions, check with a professional.

⌨️ Track spending

# Ver o estado de uma análise, em detalhe
python -m strategy_factory.main status "Empresa" --detailed

# Listar todas as análises já feitas
python -m strategy_factory.main list

Remember: quick ~US$ 0,05 · comprehensive ~US$ 0,50 per company · local generation is free.

🎯 In short

Public data, drafts with human review, no claim to be definitive advice, and closely monitored spending. This lets you use the tool responsibly and sustainably.

🧰 Module Summary

✓
401 — incorrect or missing key; check .env (pplx-... / AIzaSy..., no spaces) and restart.
✓
Module not found — venv inactive; activate it and reinstall with pip.
✓
Port in use — the app finds another one automatically, or use --port 9000.
✓
429 — wait 5–10 min and use resume; there’s a built-in ~5s delay.
✓
Blank PNG — Chrome/Puppeteer is missing; install Chrome or use Docker.
✓
Best practices & ethics — quick + good context + review; public data, human draft, track progress with status/list.

🎉 You’ve reached the end of the course!

From installation to deliverables: you now know how to generate the package, understand each document, present it to leadership, and solve the most common problems. All that's left is to put it into practice.