Adapters
English
code

Code generator small

#1
by dnnsdunca - opened

Logical Algorithm

Overview

Logical Algorithm is a code generation model fine-tuned on the CodeParrot dataset using GPT-2 Medium. It generates code snippets based on textual prompts and is designed to assist developers by providing code suggestions and examples.

Features

  • Code Generation: Generates Python code from natural language descriptions.
  • Interactive API: Deployed with FastAPI for real-time interaction.
  • Syntax Highlighting: User interface includes syntax highlighting using CodeMirror for better readability.

Usage

Training

To train the model, run:

python model_training.py

Deployment

To deploy the model, run:

uvicorn app:app --reload

Example

Send a POST request to /generate-code/ with a JSON body:

{
  "prompt": "Write a function to reverse a string"
}

Response:

{
  "generated_code": "def reverse_string(s):\n    return s[::-1]"
}

Files

  • model_training.py: Script to fine-tune the model.
  • app.py: FastAPI server script.
  • index.html, styles.css, script.js: User interface files.
  • requirements.txt: List of dependencies.

Installation

pip install -r requirements.txt

Contributions

Feel free to contribute by submitting issues or pull requests.

Step one in building a coding tool for python development

Sign up or log in to comment