https://github.com/ammarlodhi255/self-healing-llm-pipeline
This repo contains the code written primarily in Golang for a self-healing large language model (LLM) pipeline that iteratively corrects errors in its own generated code.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.8%) to scientific vocabulary
Keywords
Repository
This repo contains the code written primarily in Golang for a self-healing large language model (LLM) pipeline that iteratively corrects errors in its own generated code.
Basic Info
Statistics
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
Self-Healing LLM Pipeline
Self-Healing LLM Pipeline uses open-source Large Language Models (LLMs), like llama3.1, to iteratively generate, test, and refine code. It automates the process of identifying and fixing issues in generated code through a feedback loop, minimizing the need for human intervention. This application supports integration with Ollama for model management and API interactions.
- The LLM validates its generated main code by writing three test cases.
- Separates the main code and test code, saving them in respective files.
- The main code is compiled first; if it fails, the errors are fed back to the LLM.
- If the main code compiles, the test cases are compiled and executed, and if any error within the test file or any failed tests exists, they are returned as feedback.
- This loop continues until the code:
- Compiles successfully
- Passes all three test cases.
Features
- Iterative Self-Healing Loop: Automatically generates, tests, and refines code until it compiles successfully.
- Flexible Model Selection: Choose between models like
llama3.1,codellama, andcodellama:13b. - Dual Modes of Operation:
- Single Prompt: Submit a single prompt and observe the LLM's iterative process.
- Prompt List: Upload a list of prompts to process sequentially.
- Detailed Metrics: Tracks elapsed time, number of iterations, and results for each prompt.
- Persistent Model Management: Integrates with Ollama for managing models and API requests.
Prerequisites
Before setting up the project, ensure the following are installed on your machine:
- Go 1.19+
- Docker
- Ollama (running on the host machine)
- Access to the required LLM models, such as
llama3.1.
Installation
Clone the Repository
bash
git clone https://github.com/your-username/llm-self-healing-pipeline.git
cd llm-self-healing-pipeline
Run the application locally:
To run the application locally without Docker:
1. Install Go dependencies:
bash
go mod tidy
2. Run the application:
bash
go run main.go
- Access the application at http://localhost:8080.
Build and Run with Docker
bash
docker build -t llm-pipeline .
Run the Docker Container
Mount your host’s Ollama directory to the container for model access:
```bash docker run -d \ -p 8080:8080 \ -p 11434:11434 \ -v /Users/username/.ollama:/root/.ollama \ --name llm-pipeline \ llm-pipeline
``` • p 8080:8080: Exposes the web interface for interacting with the application. • -p 11434:11434: Exposes Ollama’s API for model interactions. • -v /Users/ammarahmed/.ollama:/root/.ollama: Maps the Ollama model directory for persistent access.
Verify the Setup:
- Access the web interface at http://localhost:8080.
- Use the Single Prompt or Prompt List mode to interact with the application.
Usage
Single Prompt Mode
- Navigate to the Single Prompt section in the UI.
- Enter a prompt and select a model from the dropdown.
- Click Submit to start the iterative process.
- Observe:
- The generated code.
- Compiler output.
- Progress metrics such as iterations and elapsed time.
Prompt List Mode
- Navigate to the Prompt List section in the UI.
- Upload a .txt file containing prompts, one per line.
- Select a model from the dropdown and start processing.
- The application will process each prompt sequentially and display results.
Monitoring Metrics
- Elapsed Time: Total time spent on processing.
- Iterations: Number of iterations performed for the current prompt.
Technical Details
Project Structure
project-root/
├── Dockerfile # Containerization setup
├── main.go # Backend Go application
├── static/ # Frontend assets (CSS, JS)
├── imgs/
├── templates/
│ └── index.html # Frontend HTML template
├── go.mod # Go module dependencies
├── go.sum # Go module checksums
└── modules/ # Core modules for LLM processing and utilities
├── compiler/
├── compiler_v2/
│ ├── consts/ # Constants for compiler configurations
│ ├── go_compiler_v2/ # Go-specific compiler logic
│ ├── platform/ # Cross-platform handling
│ ├── rust_compiler_v2/ # Rust-specific compiler logic
│ └── utils/ # Utility functions for compiler operations
├── database/
│ ├── db.go # Database logic and configuration
│ └── test_db.go # Unit tests for database interactions
├── display-indicator/
│ └── indicator.go # Display indicators and loading animations
├── extraction/
│ ├── extract.go # Extraction logic for code from LLM response
│ └── extract_test.go # Unit tests for extraction functions
└── ollama-implementation/
├── ollama.go # Ollama API interaction logic
└── ollama_test.go # Unit tests for Ollama API functions
Screenshots
Main Interface with Prompt Input and Model Selection

Model Selection Dropdown

Code Generation Process with Main Code and Test Code Sections

Detailed Output with Compiler Messages

License
License
This project is licensed under the MIT License. See the LICENSE file for details.
Owner
- Name: Ammar Ahmed
- Login: ammarlodhi255
- Kind: user
- Location: Sukkur, Pakistan
- Website: https://www.youtube.com/channel/UCAh8QVO85NLQGj_RhYoTU1w/videos
- Repositories: 9
- Profile: https://github.com/ammarlodhi255
A computer scientist at heart, interested in AI, software development, and space.
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: 10 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| ammarlodhi255 | a****8@g****m | 27 |
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- github.com/golang/snappy v0.0.4
- github.com/gorilla/websocket v1.5.3
- github.com/klauspost/compress v1.13.6
- github.com/montanaflynn/stats v0.7.1
- github.com/xdg-go/pbkdf2 v1.0.0
- github.com/xdg-go/scram v1.1.2
- github.com/xdg-go/stringprep v1.0.4
- github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78
- go.mongodb.org/mongo-driver v1.17.1
- golang.org/x/crypto v0.26.0
- golang.org/x/sync v0.8.0
- golang.org/x/text v0.17.0
- github.com/golang/snappy v0.0.4
- github.com/gorilla/websocket v1.5.3
- github.com/klauspost/compress v1.13.6
- github.com/montanaflynn/stats v0.7.1
- github.com/xdg-go/pbkdf2 v1.0.0
- github.com/xdg-go/scram v1.1.2
- github.com/xdg-go/stringprep v1.0.4
- github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78
- github.com/yuin/goldmark v1.4.13
- go.mongodb.org/mongo-driver v1.17.1
- golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
- golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
- golang.org/x/crypto v0.26.0
- golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
- golang.org/x/net v0.0.0-20190620200207-3b0461eec859
- golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
- golang.org/x/net v0.0.0-20220722155237-a158d28d115b
- golang.org/x/sync v0.0.0-20190423024810-112230192c58
- golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
- golang.org/x/sync v0.8.0
- golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
- golang.org/x/sys v0.0.0-20201119102817-f84b799fce68
- golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1
- golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
- golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f
- golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
- golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
- golang.org/x/text v0.3.0
- golang.org/x/text v0.3.3
- golang.org/x/text v0.3.7
- golang.org/x/text v0.3.8
- golang.org/x/text v0.17.0
- golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
- golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
- golang.org/x/tools v0.1.12
- golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
- github.com/joho/godotenv v1.5.1
- github.com/rifaideen/talkative v0.1.2
- github.com/joho/godotenv v1.5.1
- github.com/rifaideen/talkative v0.1.2
- github.com/golang/snappy v0.0.4
- github.com/gorilla/websocket v1.5.3
- github.com/klauspost/compress v1.13.6
- github.com/montanaflynn/stats v0.7.1
- github.com/xdg-go/pbkdf2 v1.0.0
- github.com/xdg-go/scram v1.1.2
- github.com/xdg-go/stringprep v1.0.4
- github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78
- go.mongodb.org/mongo-driver v1.17.1
- golang.org/x/crypto v0.26.0
- golang.org/x/sync v0.8.0
- golang.org/x/text v0.17.0
- github.com/golang/snappy v0.0.4
- github.com/gorilla/websocket v1.5.3
- github.com/klauspost/compress v1.13.6
- github.com/montanaflynn/stats v0.7.1
- github.com/xdg-go/pbkdf2 v1.0.0
- github.com/xdg-go/scram v1.1.2
- github.com/xdg-go/stringprep v1.0.4
- github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78
- github.com/yuin/goldmark v1.4.13
- go.mongodb.org/mongo-driver v1.17.1
- golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
- golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
- golang.org/x/crypto v0.26.0
- golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
- golang.org/x/net v0.0.0-20190620200207-3b0461eec859
- golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
- golang.org/x/net v0.0.0-20220722155237-a158d28d115b
- golang.org/x/sync v0.0.0-20190423024810-112230192c58
- golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
- golang.org/x/sync v0.8.0
- golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
- golang.org/x/sys v0.0.0-20201119102817-f84b799fce68
- golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1
- golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
- golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f
- golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
- golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
- golang.org/x/text v0.3.0
- golang.org/x/text v0.3.3
- golang.org/x/text v0.3.7
- golang.org/x/text v0.3.8
- golang.org/x/text v0.17.0
- golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
- golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
- golang.org/x/tools v0.1.12
- golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7