This python script uses langchain and OpenAI to create an index.html file containing ZIM code. It takes the whole zimdocs.txt file (thanks to Dr. Abstract - https://zimjs.com/docs.html), splits it into smaller pieces that are embedded in a vectorsore. The query is placed in the same vectorstore and returns similar chunks from the documentation, from which a ZIM code is generated using some very clever 😉 prompt engineering.
- Git Clone:
git clone https://github.com/ajerni/langchain-zim-generator.git
- Move to the new directory:
cd langchain-zim-generator
- Create Virtual Environment:
python -m venv env
orpython3 -m venv env
(on Windows:python -m venv c:\path\to\env
) - Activate Virtual Environment:
source env/bin/activate
on Mac orenv\Scripts\activate
on Windows - Install Dependencies:
pip install -r requirements.txt
- Create a .env file containing your OpenAI Key:
echo "OPENAI_API_KEY=xyz" > .env
(replace xyz with your own OpenAI Key) - In main.py line 19 change the query string to whatever you want (use ZIM terms circle, label, etc.) like:
3 circles within each other. Biggest red, middle green, smallest black
- Run it:
python main.py
orpython3 main.py
- Copy and paste the output into your own
index.html
--> open it as your usual ZIM file! - Fork my repo and start developing until we have the ultimate ZIM-Auto-Pilot 🚀
- Dr. Abstract for his amazing ZIM: https://zimjs.com
- create a FastAPI endpoint to run it on Vercel, Google Cloud or so...
- Prompts need further finetuning (i.e. make positioning work as a next step etc.)
- later on I can think of using langchain agents to include google search for pictures which can be added to the stage etc.