Spaces:
Runtime error
Runtime error
Download app.py from manasmaskar/Customer-Support-AI-Agent: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/manasmaskar/Customer-Support-AI-Agent/resolve/main/app.py
- Command line
-
hf download hf://spaces/manasmaskar/Customer-Support-AI-Agent/app.py
-
curl -L -o app.py https://huggingface.co/spaces/manasmaskar/Customer-Support-AI-Agent/resolve/main/app.py
1.21 kB
| from flask import Flask, render_template, request, jsonify | |
| from hybrid_search import ArloRAGPipeline | |
| import threading | |
| app = Flask(__name__) | |
| # Initialize RAG on startup (happens once) | |
| print("🚀 Initializing RAG Pipeline...") | |
| rag = ArloRAGPipeline(enable_web_search=True) | |
| rag.build() | |
| print("✅ RAG Ready!") | |
| def home(): | |
| return render_template('index.html') | |
| def health(): | |
| return jsonify({"status": "healthy", "rag_ready": rag.vectorstore is not None}) | |
| def query(): | |
| question = request.json.get('question', '') | |
| if not question: | |
| return jsonify({"error": "No question provided"}), 400 | |
| # Capture RAG output | |
| import io | |
| import sys | |
| old_stdout = sys.stdout | |
| sys.stdout = buffer = io.StringIO() | |
| rag.query(question) | |
| output = buffer.getvalue() | |
| sys.stdout = old_stdout | |
| # Extract answer | |
| if "💡 Answer:" in output: | |
| answer = output.split("💡 Answer:")[1].strip() | |
| else: | |
| answer = output | |
| return jsonify({ | |
| "question": question, | |
| "answer": answer | |
| }) | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860) | |