Hacker News new | ask | show | jobs
by jackmpcollins 766 days ago
I'm building magentic https://github.com/jackmpcollins/magentic which has basically this syntax, though it queries the LLM to generate the answer rather than writing + running code.

  from magentic import prompt
  from pydantic import BaseModel
  
  class Superhero(BaseModel):
      name: str
      age: int
      power: str
      enemies: list[str]
  
  @prompt("Create a Superhero named {name}.")
  def create_superhero(name: str) -> Superhero: ...

I do have plans to also solve the case you're talking about of generating code once and executing that each time.