{"id":23569052,"url":"https://github.com/devevil99/devevil-ai","last_synced_at":"2025-11-02T00:30:36.684Z","repository":{"id":269802994,"uuid":"908511732","full_name":"DevEvil99/DevEvil-AI","owner":"DevEvil99","description":"DevEvil AI's server source code includes a chat and image model utilizing xAI, OpenAI, HuggingFace and Flux.","archived":false,"fork":false,"pushed_at":"2025-02-11T23:58:17.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T19:18:24.840Z","etag":null,"topics":["ai","ai-assistant","aiimagegenerator","artificial-intelligence","assistant","chatgpt","hugging-face","huggingface","image-generation","xai"],"latest_commit_sha":null,"homepage":"https://ai.devevil.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevEvil99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-26T08:53:17.000Z","updated_at":"2025-02-11T23:01:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"a181cea6-96f7-4460-a747-8cb3c93f9510","html_url":"https://github.com/DevEvil99/DevEvil-AI","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"820bb4c505ef11c03d3704a2604a990fdf66bd86"},"previous_names":["devevil99/devevil-ai"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevEvil99%2FDevEvil-AI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevEvil99%2FDevEvil-AI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevEvil99%2FDevEvil-AI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevEvil99%2FDevEvil-AI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevEvil99","download_url":"https://codeload.github.com/DevEvil99/DevEvil-AI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239349877,"owners_count":19624204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai-assistant","aiimagegenerator","artificial-intelligence","assistant","chatgpt","hugging-face","huggingface","image-generation","xai"],"created_at":"2024-12-26T19:11:56.145Z","updated_at":"2025-02-17T19:18:28.194Z","avatar_url":"https://github.com/DevEvil99.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **DevEvil AI Server - Chat and Image Generation**\n\nThis repository enables you to host a powerful AI backend that supports chat and image generation using **xAI/OpenAI** for conversational AI and **FLUX** for advanced image generation. \n\nThis guide will help you set up, configure, and use the server for your projects.\n\n---\n\n## **Features Not Included in This Repository**\n\n- **Search Functionality**  \n    The search model used in DevEvil AI is not part of this repository.\n\n- **User Usage Limits**  \n This repository does not impose any user usage limits, allowing users to chat or generate images without restrictions. This makes it an excellent choice for testing and development purposes. Additionally, a `userId` parameter has been implemented, providing a foundation for easily adding usage limit functionality if needed in the future.\n\n- **DevEvil API Integration**  \n  DevEvil API is the brain of DevEvil AI and its models, its not included in this repository. This repository utilizes publicly available APIs for chat and image generation models.\n\n---\n\n### **Table of Contents**\n\n1. [Introduction](#devevil-ai-server---chat-and-image-generation)  \n2. [Features Not Included in This Repository](#features-not-included-in-this-repository)  \n3. [Repository Structure](#repository-structure)  \n4. [Features](#features)  \n   - Chat API  \n   - Image Generation API  \n   - FTP Integration  \n5. [Setup Guide](#setup-guide)  \n   - [Prerequisites](#1-prerequisites)  \n   - [Installation](#2-installation)  \n   - [Run the Server](#3-run-the-server)  \n6. [How to Use OpenAI Instead of xAI](#how-to-use-openai-instead-of-xai)  \n7. [Usage](#usage)  \n   - [Chat API](#chat-api)  \n   - [Image Generation API](#image-generation-api)  \n8. [How to Integrate in Your Project](#how-to-integrate-in-your-project)  \n9. [Environment Variables](#environment-variables)  \n10. [License](#license)  \n11. [Support](#support)  \n\n---\n\n## **Repository Structure**\n\n- **`server.js`**  \n  The main server file. Handles API endpoints for chat and image generation.\n  \n- **`.env.example`**  \n  Template for environment variables. Rename this file to `.env` and fill in your credentials.\n\n- **`package.json`**  \n  Contains project metadata and dependencies for setting up the server.\n\n---\n\n## **Features**\n\n1. **Chat API**  \n   A conversational AI model powered by xAI or OpenAI to generate intelligent and context-aware responses.\n\n2. **Image Generation API**  \n   Generate images based on user prompts using the FLUX model.\n\n3. **FTP Integration**  \n   Images are securely stored on an FTP server and accessible via a URL.\n\n---\n\n## **Setup Guide**\n\n### **1. Prerequisites**\n- Node.js (v14 or higher)\n- npm (Node Package Manager)\n- An FTP server for image storage\n- API keys for:\n  - Hugging Face\n  - xAI \n\n---\n\n### **2. Installation**\n\n1. Clone this repository:\n   ```bash\n   git clone https://github.com/DevEvil99/DevEvil-AI.git\n   cd DevEvil-AI\n   ```\n\n2. Install dependencies:\n   ```bash\n   npm install\n   ```\n\n3. Rename `.env.example` to `.env`:\n   ```bash\n   mv .env.example .env\n   ```\n\n4. Fill in the `.env` file with your credentials:\n   ```env\n   XAI_API_KEY=your_xai_api_key\n   HUGGING_FACE_API_KEY=your_hugging_face_api_key\n   ```\n\n---\n\n### **3. Run the Server**\n\nStart the server:\n```bash\nnode server.js\n```\n\nYou should see:\n```\nServer is running on http://localhost:5500\n```\n\n---\n\n### **How to Use OpenAI Instead of xAI**  \n\nIf you'd like to switch from xAI to OpenAI for your project, follow these steps:  \n\n1. **Remove the `baseURL` Property**  \n   In the `const openai` declaration, remove the `baseURL` property:  \n   ```javascript\n   const openai = new OpenAI({\n       apiKey: process.env.XAI_API_KEY, // Replace with your OpenAI API key\n   });\n   ```  \n\n2. **Replace the API Key**  \n   - Update the `apiKey` value to use your OpenAI API key.  \n   - Alternatively, you can create a separate environment variable for the OpenAI API key, e.g., `OPENAI_API_KEY`, and reference it in your code:  \n     ```javascript\n     const openai = new OpenAI({\n         apiKey: process.env.OPENAI_API_KEY, // Use the OpenAI API key from the environment variable\n     });\n     ```  \n\n3. **Update the Model**  \n   In the `chatCompletion` section, change the model to one of OpenAI's chat models, such as `gpt-4o`:  \n   ```javascript\n   const chatCompletion = await openai.chat.completions.create({\n       model: \"gpt-4o\", // Use OpenAI's chat model\n       messages: conversationHistory,\n       temperature: 0,\n       max_tokens: 1024,\n   });\n   ```  \n\n4. **Save and Test**  \n   Save the changes and test your server to ensure it functions correctly with OpenAI.  \n\n---\n\n## **Usage**\n\n### **Chat API**\n\n**Endpoint:**  \n`POST http://localhost:5500/chat`\n\n**Headers:**\n```json\n{\n  \"Content-Type\": \"application/json\"\n}\n```\n\n**Body:**\n```json\n{\n  \"userMessage\": \"Hello, how are you?\",\n  \"userId\": \"unique_user_id\"\n}\n```\n\n**Response:**\n```json\n{\n  \"botResponse\": \"I'm great! How can I assist you today?\"\n}\n```\n\n---\n\n### **Image Generation API**\n\nThe `/chat` endpoint also supports image generation. To generate an image, include a command like **\"Create an image of a sunset over mountains\"** in the `userMessage`.\n\n**Example Request:**\n```json\n{\n  \"userMessage\": \"Create an image of a futuristic city at night.\",\n  \"userId\": \"unique_user_id\"\n}\n```\n\n**Response:**\n```json\n{\n  \"botResponse\": \"\u003cimg class=\\\"ai-image\\\" src=\\\"https://your_ftp_domain/unique_image_name.png\\\" alt=\\\"Generated Image\\\" /\u003e\"\n}\n```\n\n---\n\n## **How to Integrate in Your Project**\n\n1. **Include the API in Your Frontend**  \n   Use `fetch` or any HTTP client (e.g., Axios) to send requests to the server.\n\n   **Example (JavaScript):**\n   ```javascript\n   fetch('http://localhost:5500/chat', {\n       method: 'POST',\n       headers: {\n           'Content-Type': 'application/json',\n       },\n       body: JSON.stringify({\n           userMessage: \"Help me write a function\",\n           userId: \"1\"\n       }),\n   })\n   .then(response =\u003e response.json())\n   .then(data =\u003e console.log(data.botResponse))\n   .catch(error =\u003e console.error('Error:', error));\n   ```\n\n2. **Host the Server Online**  \n   Use a VPS or cloud platform like AWS, Google Cloud, or Heroku to deploy your server and make it publicly accessible.\n\n---\n\n## **Environment Variables**\n\n| Variable              | Description                                      | Example Value               | API Console |\n|-----------------------|--------------------------------------------------|-----------------------------| -----------------------------|\n| `XAI_API_KEY`         | API key for xAI            | `xai-abc123`                |    [console.x.ai](https://console.x.ai)\n| `OPENAI_API_KEY`| API key for OpenAI                         | `sk-abc123`                | [platform.openai.com](https://platform.openai.com/)\n| `HUGGING_FACE_API_KEY`| API key for Hugging Face                         | `hf_abc123`                | [huggingface.co](https://huggingface.co/)\n\n\n\n---\n\n## **License**\n\nThis project is licensed under the MIT License. Feel free to use, modify, and distribute it.\n\n---\n\n## **Support**\n\nFor issues or questions, join our [Discord Community](https://dsc.gg/devevil) or open an issue in this repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevevil99%2Fdevevil-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevevil99%2Fdevevil-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevevil99%2Fdevevil-ai/lists"}