File size: 2,574 Bytes
7f3d153
3bcf648
2fd8500
 
9b19acf
2fd8500
 
 
9b19acf
2fd8500
9b19acf
2fd8500
a795e9f
 
 
 
 
2fd8500
 
 
 
 
 
a795e9f
2fd8500
a795e9f
 
2fd8500
 
 
 
 
 
 
 
 
 
3bcf648
2fd8500
 
a795e9f
2fd8500
d172eee
2fd8500
0083f4e
a795e9f
2fd8500
 
 
 
 
a795e9f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import logging
import time
from flask import Flask, request, Response, stream_with_context, jsonify, send_from_directory

# --- 1. एन्टरप्राइज लॉगिंग कॉन्फ़िगरेशन ---
logging.basicConfig(level=logging.INFO, format='[%(asctime)s] %(levelname)s: %(message)s')
logger = logging.getLogger("ArjunCore")

app = Flask(__name__, static_folder='.', static_url_path='')

# --- 2. कॉन्फ़िगरेशन क्लास (Environment variables से डेटा लेने के लिए) ---
class Config:
    API_KEY = os.environ.get("YOUR_VEDIKA_API_KEY")
    ENDPOINT = os.environ.get("BASE_URL")
    MODEL_ID = os.environ.get("MODEL_ID")

# --- 3. रूट: सर्वर रन होते ही ट्रिगर होना ---
@app.route('/')
def index():
    """यह फंक्शन सुनिश्चित करता है कि जैसे ही यूज़र सर्वर पर आए, index.html लोड हो जाए।"""
    logger.info("Serving index.html interface...")
    return send_from_directory('.', 'index.html')

# --- 4. चैट एपीआई (LLM Proxy) ---
@app.route('/api/chat', methods=['POST'])
def chat():
    """फ्रंटएंड (Gradio/JS) से आने वाली रिक्वेस्ट को LLM तक पहुँचाना।"""
    try:
        data = request.json
        # यहाँ आप PayloadBuilder का उपयोग करके अपना लॉजिक बढ़ा सकते हैं
        logger.info("Processing chat request...")
        
        # प्रॉक्सी लॉजिक यहाँ डालें (जैसे पिछला कोड था)
        return jsonify({"status": "processing", "message": "Backend connected successfully"})
    except Exception as e:
        return jsonify({"error": str(e)}), 500

# --- 5. हेल्थ चेक ---
@app.route('/health')
def health():
    return jsonify({"status": "Arjun Core Active", "uptime": time.time()})

# --- 6. मुख्य एक्जीक्यूशन ---
if __name__ == '__main__':
    port = int(os.environ.get("PORT", 7860))
    print("\n==============================================")
    print("      ARJUN CORE V3 - SYSTEM ONLINE           ")
    print("==============================================\n")
    
    # यह Flask का सर्वर सीधे index.html को सर्व करेगा
    app.run(host='0.0.0.0', port=port, threaded=True)