Skip to content

hkoziolek/LLM-CodeGen-RAG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLM-based and Retrieval-augmented Control Code Generation

This repository contains a LangChain program (CodeGen.py) to generate IEC 61131-3 ST control logic from natural language prompts using a large language model (LLM). After installing the required dependencies and entering your LLM API-key in line 7 of CodeGen.py, you can enter your control logic prompt in line 32, and run the generator. It performs a similarity search on a FAISS database with vector encodings of the OSCAT function block library for IEC 61131-3 ST and augments the results to the prompt. Then it queries the configured LLM and should retrieve as answer the source code for an IEC 61131-3 ST function block. This source code can be saved into an .st text file and be imported into the OpenPLC PLC Editor.

In the folder OpenPLC, there are three OpenPLC projects, which can be directly opened and compiled in OpenPLC. They contain ST code generated with GPT-4 based on natural language prompts. The code uses OSCAT function blocks from an open-source implementation of the library.

About

LLM-based and retrieval-augmented Control Code Generation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published