sujalrajpoot commited on
Commit
fbc6ce1
·
verified ·
1 Parent(s): cc6b7b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -10,15 +10,17 @@ app = Flask(__name__)
10
  # 🔑 Secret key for API authentication (Load from environment in production)
11
  SECRET_KEY = os.getenv("SECRET_KEY")
12
  GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
13
- endpoint = "https://models.inference.ai.azure.com"
14
- client = OpenAI(base_url=endpoint,api_key=GITHUB_TOKEN)
 
 
 
15
 
16
  # Track API statistics
17
  api_usage = {} # Stores {api_key: {"count": X, "reset_time": timestamp}}
18
 
19
  # ✅ Request Limit Configuration
20
  REQUEST_LIMIT = 10 # Max requests per day
21
- SPECIAL_API_KEY = "TrueSyncAI-888d3e23fa5801834aa385118e05bd72-394215579bc4e6ac" # The restricted API key
22
 
23
  # Track API statistics
24
  request_count = 0
@@ -38,7 +40,7 @@ def generate_response(query:str) -> str:
38
  try:
39
  model_name = "gpt-4o"
40
  response = client.chat.completions.create(
41
- messages=[{"role": "system","content": "You are TrueSyncAI, a pioneering AI startup founded by Sujal Rajpoot and Anuj Rajpoot. As TrueSyncAI, you are designed to be intelligent, engaging, and helpful in conversations. You should provide insightful, accurate, concise and context-aware responses while maintaining a friendly and professional tone. Your goal is to enhance the user’s experience by adapting to their needs, assisting with various tasks, and learning from interactions to improve over time. Always ensure clarity, relevance, concise and accuracy in your responses, and align with TrueSyncAI’s vision of bridging the gap between virtual intelligence and reality."},{"role": "user","content": query}],temperature=0.7,max_tokens=4096,top_p=0.9,model=model_name,stream=False)
42
  return response.choices[0].message.content
43
  except:
44
  return "API Server is under maintenance. Please Try After Some Time Thank You for using TrueSyncAI Chat API. Have a great day."
 
10
  # 🔑 Secret key for API authentication (Load from environment in production)
11
  SECRET_KEY = os.getenv("SECRET_KEY")
12
  GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
13
+ SPECIAL_API_KEY = os.getenv("SPECIAL_API_KEY")
14
+ ENDPOINT = os.getenv("ENDPOINT")
15
+ SYSTEM_PROMPT = os.getenv("SYSTEM_PROMPT")
16
+
17
+ client = OpenAI(base_url=ENDPOINT,api_key=GITHUB_TOKEN)
18
 
19
  # Track API statistics
20
  api_usage = {} # Stores {api_key: {"count": X, "reset_time": timestamp}}
21
 
22
  # ✅ Request Limit Configuration
23
  REQUEST_LIMIT = 10 # Max requests per day
 
24
 
25
  # Track API statistics
26
  request_count = 0
 
40
  try:
41
  model_name = "gpt-4o"
42
  response = client.chat.completions.create(
43
+ messages=[{"role": "system","content": SYSTEM_PROMPT},{"role": "user","content": query}],temperature=0.7,max_tokens=4096,top_p=0.9,model=model_name,stream=False)
44
  return response.choices[0].message.content
45
  except:
46
  return "API Server is under maintenance. Please Try After Some Time Thank You for using TrueSyncAI Chat API. Have a great day."