Has anyone established a good workflow to work wit...
# hamilton-help
g
Has anyone established a good workflow to work with an AI editor like Cursor/Windsurf and Hamilton in Jupyter Notebooks? I'm struggling with the lack of native support for notebooks in these editors + having some difficulties "teaching" these AI how to use Hamilton properly @Thierry Jean
s
Can you provide them with some “markdown context”? It might be that we need to create some file that helps them understand the paradigm with some examples.
g
Yes. That would help. If I'll find something that works as one-shot I'll post it here. In addition, most AI IDEs don't support AI in their jupyter notebooks, which makes the whole development with hamilton magic a pain 😔
i
Wasn't there someone who asked for a pdf version of the docs for an air-gapped system? Maybe a recent build of that could help LLMs... @Stefan Krawczyk
s
@Iliya R I suspect the token count might be a bit large 😆
but yes there’s a PDF version of the docs - you just click the bottom right box in the docs to show the menu.
i
We have a claude subscription from work, and it allows uploading files to "project context", which supports fairly big pdfs (from experience). I can give it a try with the hamilton docs and see what happens
👍 1
Computer says no 😐
😆 2
t
Notebooks are poorly supported because
.ipynb
are just JSON files. Tokenizing JSON is super expensive with
" [ ] { }
each taking a token. Sadly, I don't have any silver bullet here
For providing context to LLM, we could work on a "Hamilton LLM docs" that's a shortened version of the docs with straightforward examples. You can look at Jina AI and FastHTML for some ideas • Jina AI docs: https://docs.jina.ai/ • FastHTML: https://docs.fastht.ml/llms-ctx.txt
You might find inspiration in this blog for building dlt pipelines with Cursor: https://dlthub.com/blog/mooncoon
Also, to clarify, these large context documents shouldn't be passed as "context" (typically the
@
symbol in Cursor or Continue), but rather be embedded as
Docs
in the IDE. This will automatically chunk and embed the large document for RAG. Then the IDE usually allows to call
@Docs
to enable RAG over the docs (or it will automatically do it) to retrieve the relevant code snippets for the question. For example, ask the IDE to parameterize a node in Hamilton and it will pickup the
@parameterize
documentation (excuse me for spamming comments)
g
The problem with that is that it doesn't know when to use parameterize (or anything else) given a description that doesn't mention that explicitly
t
A challenge with LLMs and AI-enhanced IDEs, is determining what kind of prompts should work and how to collaborate with the LLM efficiently. For context, what type of prompts did you try and what were the results (the good and the bad)? # Generating the DAG Queries like "create a DAG to load web pages, chunk them, and embedded them" are very challenging. With good prompts and examples, we could work towards "generate function signatures for a valid Hamilton DAG". # Filling the node functions IMO, writing the skeleton of the DAG is a "human-first" job. I had good success writing function signatures + docstrings and then using LLMs to generate the body of the functions. (this could be a 2nd step after a successful 'Generating the DAG' operation) # Function modifiers, materializers, etc. Once you have the DAG and the filled body, LLMs with relevant context should be able to answer "parameterize the function
monthly_sales()
to be applied per team and per department". This follows the idea that it's mostly human's role to specify the DAG shape On the Hamilton side, our best effort is to create an LLM-friendly version of the docs + improve the docstrings of public interfaces
v
Hi @Thierry Jean Are there any updates on this?
t
Sadly, no 😕
j
You might want to consider a plain text notebook format like Quarto. That's mostly just markdown, which LLMs like. Note though that the state of your document is not embedded in the document itself like with ipynb, so you'll likely also want caching enabled in Hamilton.
v
@Thierry Jean What about a Hamilton mcp server? Here is one for polars. Should be easy to adapt to hamilton https://github.com/HotTechStack/polars-docs-mcp/tree/main
t
@Volker Lorrmann ooh, that's a cool repo! I had a similar idea of using Python runtime to inspect objects. Will try to implement something similar
🙏 1