Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevNest(Novathon) #1124

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added hackathon/DevNest(Novathon)/README.md
Binary file not shown.
61 changes: 61 additions & 0 deletions hackathon/DevNest(Novathon)/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from flask import Flask, request, jsonify
from llmware.models import ModelCatalog
from llmware.gguf_configs import GGUFConfigs

# Set global configurations for the model
GGUFConfigs().set_config("max_output_tokens", 250)

# Initialize Flask app
app = Flask(__name__)

# Load the model with GPU acceleration enabled
MODEL_NAME = "llama-2-7b-chat-gguf"
model = None

try:
model = ModelCatalog().load_model(
MODEL_NAME,
temperature=0.3,
sample=True,
max_output=250,
use_gpu=True # Ensure GPU is used if available
)
print("Model loaded successfully with GPU acceleration.")
except Exception as e:
print(f"Failed to load the model: {e}")
model = None

@app.route("/index")
def index():
"""Health check endpoint"""
return jsonify({"message": "LLM Chat API is running!"})

@app.route("/chat", methods=["POST"])
def chat():
"""
POST endpoint to send a prompt to the model and receive a response.
"""
global model
if not model:
return jsonify({"error": "Model not loaded. Please check server logs."}), 500

try:
# Parse input JSON
input_data = request.get_json()
prompt = input_data.get("prompt", None)

if not prompt:
return jsonify({"error": "Missing 'prompt' in request body."}), 400

# Generate response using the model
model_response = model.inference(prompt)
bot_response = model_response.get("llm_response", "No response generated.")

# Return the response
return jsonify({"prompt": prompt, "response": bot_response})

except Exception as e:
return jsonify({"error": f"Error during inference: {str(e)}"}), 500

if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0", port=5000) # Make it accessible on all network interfaces
Binary file added hackathon/DevNest(Novathon)/images/bg1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hackathon/DevNest(Novathon)/images/bg2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hackathon/DevNest(Novathon)/images/bg3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hackathon/DevNest(Novathon)/images/bg4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hackathon/DevNest(Novathon)/images/bg5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.