Skip to content

Instantly share code, notes, and snippets.

@elecnix
Created March 1, 2025 19:03
Show Gist options
  • Save elecnix/c676380b0906912b7b50ecd5857a7064 to your computer and use it in GitHub Desktop.
Save elecnix/c676380b0906912b7b50ecd5857a7064 to your computer and use it in GitHub Desktop.
AI Engineer
Write a python program that reads a software spec prompt, writes a python implementation that satisfies this spec and a test suite, then runs the tests, inspects the test results, and re-generates the implementation & tests, runs the tests again, until all the tests pass.
The prompt can be passed as a string arg to the program, as a file name argument, or else read from standard input.
The program must invoke ollama to generate the implementation for the prompt. Use deepseek-coder.
The ollama model must decide whether the tests were successful, by reading the user's prompt, the code, and the test output.
The program should not keep all history of the iterations; instead, once it has a first implementation and test results, it should only add a "memory" file that it rewrites on each iteration, using a separate prompt that is aimed at "memorizing any learnings". The goal with this memory is to avoid overloading the context window of the LLM after hundreds of iterations.
The code generated by ollama will likely include
```python
#code
```
markers that should be parsed to extract the implementation.
The implementation file should be self-contained in a single file, and include all the tests.
When updating the memory, pass the code implementation in addition to the test output also, never sys.exit, as we REALLY want a solution to the prompt
I have langfuse running:
load_dotenv()
langfuse = Langfuse(
secret_key=os.getenv("LANGFUSE_SECRET_KEY"),
public_key=os.getenv("LANGFUSE_PUBLIC_KEY"),
host="http://localhost:3000"
)
Use OpenAI SDK with Ollama running on localhost.
Use uv instead of pip.
Write the code for this AI software engineer loop in python.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment