# **Durgaai Solutions (India First AI Assistant)** # **A Flask API for generating text using the Mixtral-7B-Instruct-v0.2 model** import uvicorn from flask import Flask, request, jsonify, render_template_string from huggingface_hub import InferenceClient import logging # Configure logging logging.basicConfig(level=logging.INFO) # Defining Application app = Flask(__name__) # Defining Model Used used_model = "https://api-inference.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1" # Defining Prompt def customize_prompt(message, final_instructions=None): prompt = "" if final_instructions: prompt += f"[INST] {final_instructions} [/INST]" prompt += f"[INST] {message} [/INST]" return prompt # Main Application def public_model(prompt, instructions, api, temperature=0.90, max_new_tokens=256, top_p=0.95, repetition_penalty=1.2): global used_model try: temperature = float(temperature) if temperature < 1e-2: temperature = 1e-2 top_p = float(top_p) generate_kwargs = dict( temperature=temperature, max_new_tokens=max_new_tokens, top_p=top_p, repetition_penalty=repetition_penalty, do_sample=True, seed=69, ) final_instructions = instructions result = customize_prompt(prompt, final_instructions) head = {"Authorization": f"Bearer {api}"} client = InferenceClient(used_model, headers=head) response = client.text_generation(result, **generate_kwargs) return response except Exception as e: logging.error(f"Error generating text: {e}") return str(e) # Running Application @app.route("/run-application", methods=["POST"]) def run_application(): data = request.json prompt = data.get("prompt") instructions = data.get("instructions") api_key = data.get("api_key") if not prompt or not instructions or not api_key: return jsonify({"Error": "Missing Required Fields"}), 400 try: # Validate API key if not api_key.startswith("hf_"): return jsonify({"Error": "Invalid API key"}), 401 response = public_model(prompt, instructions, api_key) return jsonify({"Response": response}), 200 except Exception as e: logging.error(f"Error processing request: {e}") return jsonify({"Error": "Internal Server Error"}), 500 # Basic HTML Interface html = ''' Mixtral 7b Instruct v0.1 = Public Server For API Usage

Mixtral 7b Instruct v0.1 = Public Server

Welcome To Durgaai Solutions Organisation ( To Use This Server Follow Given Steps )

1. Create Your Hugging Face Access Token From Your HF Account

2. Go To Our { Github Organisation | Source Code } Page By Link Given Below

3. Download The Respository Do Suggested Changes To (Main-Application.py)

Github Link : Now Use It As Free With Unlimited Access To This AI Model
''' # Launching Interface @app.route("/", methods=["GET"]) def index(): return render_template_string(html) # Launch Application if __name__ == "__main__": app.run(debug=True)