Skip to content

Codehive Genie is an AI-powered coding assistant integrated into the Codehive platform, designed to simplify coding tasks such as code generation, bug fixing, and optimization. Powered by Llama 3.1 and deployed on Vercel, it supports multiple programming languages, including Python, C, Java, JavaScript, TypeScript, and C++.

License

Notifications You must be signed in to change notification settings

abhaydixit07/codehive-genie

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codehive Genie 🧞‍♂️✨

An AI-driven coding assistant integrated into the Codehive platform.

Codehive Genie is a Python-based Flask API that leverages advanced Large Language Models (LLMs) to provide coding assistance within the Codehive collaborative platform. It specializes in generating, debugging, and optimizing code, designed to empower developers with seamless and accurate coding support.


✨ Features

🌟 Core Capabilities

  • 🚀 Code Assistance: Generate, debug, and optimize code snippets.
  • 🌐 Supported Languages: Python, C, JavaScript, Java, TypeScript, and C++ (CPP).
  • 🔧 High-Quality Output: Delivers well-structured, production-ready code with inline comments and concise explanations.
  • 🌀 Streaming Responses: Enables real-time responses to ensure minimal latency.
  • Strict Query Handling: Ignores non-coding-related queries with polite and concise error messages.

🔒 Security Enhancements

  • 🌍 Language Detection: Ensures input is in English for consistency and accuracy.
  • 🛡️ Authentication: API access secured with an Authorization header.
  • 📜 Robust Logging: Detailed query and response logging for improved monitoring and debugging.

🌐 Deployment

  • 🖥️ Hosted on Vercel: Optimized deployment using Vercel's Flask template for high performance and scalability.

💻 Tech Stack

Backend

  • 🐍 Flask: Lightweight and efficient framework for API development.
  • 🤖 Groq AI Cloud: LLM parameterization using Llama 3.1-70B Versatile.
  • 📚 Python Libraries:
    • 🔄 flask-cors: To handle cross-origin requests.
    • 🔐 dotenv: For secure environment variable management.
    • 🧩 langdetect: For detecting input language.

Deployment

  • 🚀 Vercel: Optimized and scalable deployment with Flask templates.

🌐 API Overview

🌍 Base URL

Deployed on Vercel:

📜 Endpoints

1. Home Endpoint

  • GET /
  • Description: Basic health check for the server.
  • Response:
Hello, World!  

2. Codehive Genie Endpoint

  • POST /genie

  • Description: Processes user queries to provide AI-generated coding assistance.

  • Headers:

    • 🔐 Authorization: The authorization secret key for secure access.
  • Request Body:

    {
      "query": "Write a Python function to reverse a string."
    }  
  • Response:

    • For Valid Queries (Streamed Response):

      def reverse_string(s):  
          # Return the string in reverse order  
          return s[::-1]
      
    • 🚫 For Invalid Queries:

      {
        "error": "Invalid authorization secret."
      }
    • ⚠️ For Non-Coding Queries:

      Sorry, I am an AI assistant tuned for coding and programming purposes only. I cannot assist with this query.  
      

🛠️ Installation

Prerequisites

  • 🐍 Python: 3.8 or higher
  • 🤖 Groq API Key: Available from Groq Cloud Platform
  • 🌟 Node.js (optional for integration testing with Codehive)

🚀 Clone the Repository

git clone https://github.com/codehiveofficial/codehive-genie.git  
cd codehive-genie  

🔐 Set Up Environment Variables

Create a .env file in the root directory and add the following:

AUTH_SECRET=<your_auth_secret>  
GROQ_API_KEY=<your_groq_api_key>  

📦 Install Dependencies

pip install -r requirements.txt  

🚦 Usage

▶️ Start the Server Locally

python api/index.py  

Let me know if you need further adjustments! 🚀

🔄 Test the API

  • Use tools like Postman or cURL to test the /genie endpoint.
  • Include the required Authorization header and send a JSON body with your query.

🤝 Integration with Codehive

Codehive Genie is integrated as the AI assistant within the Codehive platform. It powers the AI-driven Codehive Genie feature, enabling users to receive coding assistance directly within collaborative rooms.


📜 License

Codehive Genie is licensed under the MIT License.

About

Codehive Genie is an AI-powered coding assistant integrated into the Codehive platform, designed to simplify coding tasks such as code generation, bug fixing, and optimization. Powered by Llama 3.1 and deployed on Vercel, it supports multiple programming languages, including Python, C, Java, JavaScript, TypeScript, and C++.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%