Problem Building ACTION

While Building ACTIONS

1. pickaxe forces to use environment, and when I add it, it adds second import os. which I can not delete manually. 2. when I try to save with both import statements it shows error that I have two imports. 3. If I try to leave the environment blank it, doesn’t allow me to save the ACTION. So this is the whole problem.

Am I doing anything wrong? I also wonder why it is still showing error of having two import statements in the code where I can only find one?

Anyone kindly help.

Any help will be highly appreciated.

1 Like

Hey @tptp

The quick answer is that you have to remove the import statement seen at the bottom of the image. You can’t remove the one at the top as its hardcoded and un-editable within the Pickaxe ecosystem (and it’s essential for Python code scripts to run).

If you can paste your code here, I can fix it for you

Hey @Ned.Malki Thanks for the response. Following is the code along with the FUNCTION and ENVIRONMENT inputs. Kindly look in to it.

Function Input

  • plan_text

  • “The full formatted diet plan text and tables”

  • “”

Environ Input

  • PDF_BASENAME

  • Default filename for generated PDF

  • diet-plan

Code:

# ===== Diet plan → HTML/PDF (no external services) =====

base = os.environ.get("PDF_BASENAME", "diet-plan")

pdf_filename = f"{base}.pdf"

html_filename = f"{base}.html"

\# Escape helper for safe HTML when we can't convert markdown

def \_escape(txt: str) -> str:

    return (txt.replace("&", "&")

               .replace("<", "&lt;")

               .replace(">", "&gt;"))

\# Try to use pandoc to convert the bot's markdown/tables into HTML

pandoc_available = False

try:

    import pypandoc  # noqa: F401

    pandoc_available = True

except Exception:

    pandoc_available = False

if pandoc_available:

    try:

        import pypandoc

        html_fragment = pypandoc.convert_text(plan_text, "html", format="md")

    except Exception:

        html_fragment = f"<pre style='white-space:pre-wrap;font-family:ui-monospace,monospace'>{\_escape(plan_text)}</pre>"

else:

    html_fragment = f"<pre style='white-space:pre-wrap;font-family:ui-monospace,monospace'>{\_escape(plan_text)}</pre>"

\# Minimal, print-friendly CSS

css = """

<style>

  :root { --fg:#1a1a1a; --muted:#555; --line:#ddd; --bg:#fff; }

  body { margin:0; padding:24px; color:var(--fg); background:var(--bg);

         font:14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Inter,Arial,sans-serif; }

  h1 { font-size:20px; margin:0 0 8px; }

  .sub { color:var(--muted); font-size:12px; margin-bottom:8px; }

  table { width:100%; border-collapse:collapse; margin:8px 0 14px; font-size:12px; }

  th, td { border:1px solid var(--line); padding:6px 8px; vertical-align:top; }

  th { background:#f6f7fb; text-align:left; }

  @media print { body { padding:0 } a\[href\]:after { content:"" } }

</style>

"""

full_html = f"""<!doctype html>
Personalized Diet Plan

{css}

Personalized Diet Plan

Generated by DSA’s Diet Planner

{html_fragment}

"""
\# Always save HTML so a download is available even if PDF fails

with open(html_filename, "w", encoding="utf-8") as f:

    f
1 Like

Thanks for adding the code @tptp I need more context regarding the Pickaxe’s function and system prompt. Feel free to DM me details if you prefer. Thx